aboutsummaryrefslogtreecommitdiff
path: root/test/NaCl/Bitcode
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-06-26 09:51:31 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-06-26 09:51:31 -0700
commit69aca3260c03ec742256b5518886f0562a658df2 (patch)
treee48e5c5cf70bb9564a43140dfb89b05036677a3c /test/NaCl/Bitcode
parente635564fe07f78c19fd6022aa105f620e7cad60a (diff)
PNaCl wire format: Clean up representation of "alloca" instruction
For some reason, the size operand of "alloca" was represented using an absolute value ID + type, unlike other instructions where relative value IDs are used. Change the "alloca" representation to be consistent with other instructions, so that we can use PushValueAndType() in the writer and getValue() in the reader. Also take this opportunity to remove the field for alloca's result type, since it's always i8* in PNaCl. This is part of a cleanup to make forward reference handling stricter: it removes a use of getOrCreateFnValueByID(), which isn't strict (that is, it doesn't reject duplicate FORWARDTYPEREF records). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17757004
Diffstat (limited to 'test/NaCl/Bitcode')
-rw-r--r--test/NaCl/Bitcode/alloca-operand.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/NaCl/Bitcode/alloca-operand.ll b/test/NaCl/Bitcode/alloca-operand.ll
new file mode 100644
index 0000000000..49df2fc8b0
--- /dev/null
+++ b/test/NaCl/Bitcode/alloca-operand.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump | FileCheck %s
+
+; Test that alloca's size operand is represented with a relative value
+; ID, the same as other instructions' operands.
+
+define external void @_start(i32 %arg) {
+; CHECK: <FUNCTION_BLOCK
+; CHECK: </CONSTANTS_BLOCK>
+
+ %size = mul i32 %arg, 4
+; CHECK-NEXT: <INST_BINOP
+ alloca i8, i32 %size
+; CHECK-NEXT: <INST_ALLOCA op0=1
+
+ ; Since the operand reference is a relative ID, references to %size
+ ; go up by 1 with each instruction.
+ alloca i8, i32 %size
+; CHECK-NEXT: <INST_ALLOCA op0=2
+ alloca i8, i32 %size
+; CHECK-NEXT: <INST_ALLOCA op0=3
+
+ ; Reference to a Constant operand.
+ alloca i8, i32 256
+; CHECK-NEXT: <INST_ALLOCA op0=5
+
+ ret void
+; CHECK-NEXT: <INST_RET
+}