diff options
-rw-r--r-- | src/analyzer.js | 3 | ||||
-rw-r--r-- | src/parseTools.js | 8 | ||||
-rw-r--r-- | tests/cases/legalizer_ta2.ll | 7 | ||||
-rw-r--r-- | tests/cases/legalizer_ta2.txt | 1 |
4 files changed, 12 insertions, 7 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 9aa84650..26e0721c 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -319,7 +319,8 @@ function analyzer(data, sidePass) { continue; } case 'invoke': { - // We can't add lines after this, since invoke already modifies control flow. So we handle this in invoke + legalizeFunctionParameters(value.params); + // We can't add lines after this, since invoke already modifies control flow. So we handle the return in invoke i++; continue; } diff --git a/src/parseTools.js b/src/parseTools.js index 5c1dcdac..ff578c0a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -324,7 +324,7 @@ function parseParamTokens(params) { ret.push({ intertype: 'value', type: segment[0].text, - ident: toNiceIdent(parseNumerical(segment[1].text)) + ident: toNiceIdent(parseNumerical(segment[1].text, segment[0].text)) }); Types.needAnalysis[removeAllPointing(ret[ret.length-1].type)] = 0; } @@ -701,8 +701,8 @@ function parseNumerical(value, type) { // Hexadecimal double value, as the llvm docs say, // "The one non-intuitive notation for constants is the hexadecimal form of floating point constants." value = IEEEUnHex(value); - } else if (type == 'i64' && USE_TYPED_ARRAYS == 2) { - value = parseI64Constant(value); + } else if (USE_TYPED_ARRAYS == 2 && isIllegalType(type)) { + return value; // do not parseFloat etc., that can lead to loss of precision } else if (value == 'null') { // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.) value = '0'; @@ -1453,7 +1453,7 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { if (param.type == 'i64' && USE_TYPED_ARRAYS == 2) { ret = parseI64Constant(ret); } - ret = parseNumerical(ret); + ret = parseNumerical(ret, param.type); } else if (param.intertype == 'structvalue') { ret = makeLLVMStruct(param.params.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) })); } else if (param.intertype === 'blockaddress') { diff --git a/tests/cases/legalizer_ta2.ll b/tests/cases/legalizer_ta2.ll index ae6e9b0c..7e17c707 100644 --- a/tests/cases/legalizer_ta2.ll +++ b/tests/cases/legalizer_ta2.ll @@ -4,7 +4,10 @@ target triple = "i386-pc-linux-gnu" @globaliz = global [300 x i8] zeroinitializer -define i64 @retter() { +define i64 @retter(i64 %x) { + store i104 0, i104* bitcast ([300 x i8]* @globaliz to i104*), align 4 ; wipe it out + store i64 %x, i64* bitcast ([300 x i8]* @globaliz to i64*), align 4 + call i32 (i8*)* @puts(i8* bitcast ([300 x i8]* @globaliz to i8*)) ret i64 7017280452245743464 } @@ -152,7 +155,7 @@ a40: ; invoke return value - %inv64 = invoke i64 @retter() + %inv64 = invoke i64 @retter(i64 8174723217654970232) to label %a100 unwind label %a111 a100: diff --git a/tests/cases/legalizer_ta2.txt b/tests/cases/legalizer_ta2.txt index 0075107d..796ee240 100644 --- a/tests/cases/legalizer_ta2.txt +++ b/tests/cases/legalizer_ta2.txt @@ -18,6 +18,7 @@ hello, wor hello, worl 9 hello, war`d +xwvutsrq hgfedcba hello, world hello, w |