diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-04-13 09:27:31 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-04-13 09:27:31 -0700 |
commit | 447c639b3bb7bbf4a37c53243d2948fadfba4ce6 (patch) | |
tree | c27403d389ec54bd28a1486d30282d7cbf646e42 | |
parent | 3868ec7853d6fcdb7c4183b18137f10739ed8b39 (diff) |
fix legalization of nonexistent call return values
-rw-r--r-- | src/analyzer.js | 5 | ||||
-rw-r--r-- | tests/cases/call_i64_noret.ll | 17 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 3921cab8..df5a435e 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -324,12 +324,13 @@ function analyzer(data, sidePass) { } // call, return: Return the first 32 bits, the rest are in temp case 'call': { - bits = getBits(value.type); - var elements = getLegalVars(item.assignTo, bits); var toAdd = [value]; // legalize parameters legalizeFunctionParameters(value.params); + // legalize return value, if any if (value.assignTo && isIllegalType(item.type)) { + bits = getBits(value.type); + var elements = getLegalVars(item.assignTo, bits); // legalize return value value.assignTo = elements[0].ident; for (var j = 1; j < elements.length; j++) { diff --git a/tests/cases/call_i64_noret.ll b/tests/cases/call_i64_noret.ll new file mode 100644 index 00000000..a8a30fc0 --- /dev/null +++ b/tests/cases/call_i64_noret.ll @@ -0,0 +1,17 @@ +; ModuleID = 'tests/hello_world.bc' +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-S128" +target triple = "i386-pc-linux-gnu" + +@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +; [#uses=0] +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + store i32 0, i32* %retval + call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0), i64 0) ; [#uses=0 type=i32] + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) |