aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parseTools.js3
-rw-r--r--tests/cases/extendedprecision.ll35
2 files changed, 38 insertions, 0 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 5f94b5cc..1764773b 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -397,6 +397,9 @@ function _IntToHex(x) {
function IEEEUnHex(stringy) {
stringy = stringy.substr(2); // leading '0x';
+ if (stringy.replace(/0/g, '') === '') return 0;
+ while (stringy.length < 16) stringy = '0' + stringy;
+ assert(stringy.length === 16, 'Can only undex 16-digit double numbers, nothing platform-specific');
var top = eval('0x' + stringy[0]);
var neg = !!(top & 8); // sign
if (neg) {
diff --git a/tests/cases/extendedprecision.ll b/tests/cases/extendedprecision.ll
new file mode 100644
index 00000000..2ab74d58
--- /dev/null
+++ b/tests/cases/extendedprecision.ll
@@ -0,0 +1,35 @@
+; ModuleID = '/tmp/emscripten/tmp/src.cpp.o'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+@.str = private constant [14 x i8] c"hello, world!\00", align 1 ; [#uses=1]
+
+; [#uses=2]
+define void @"\01_Z5hellov"() {
+entry:
+ %0 = call i32 bitcast (i32 (i8*)* @puts to i32 (i32*)*)(i8* getelementptr inbounds ([14 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ br label %return
+
+return: ; preds = %entry
+ ret void
+}
+
+; [#uses=1]
+declare i32 @puts(i8*)
+
+; [#uses=0]
+define i32 @main() {
+entry:
+ %retval = alloca i32 ; [#uses=2]
+ %0 = alloca i32 ; [#uses=2]
+ %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
+ call void @"\01_Z5hellov"(x86_fp80 0x00000000000000000000)
+ store i32 0, i32* %0, align 4
+ %1 = load i32* %0, align 4 ; [#uses=1]
+ store i32 %1, i32* %retval, align 4
+ br label %return
+
+return: ; preds = %entry
+ %retval1 = load i32* %retval ; [#uses=1]
+ ret i32 %retval1
+}