diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-26 11:04:18 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-26 11:04:18 -0700 |
commit | afa589d27ad90bcfebae9566dd31785d4ba9696f (patch) | |
tree | 30786f10784974d898c902ecda02c8ee2f409831 /test | |
parent | 69aca3260c03ec742256b5518886f0562a658df2 (diff) |
PNaCl wire format: Use FORWARDTYPEREF consistently for all forward references
Before this change, the writer would only emit FORWARDTYPEREF for some
operands, e.g. the first operand of BINOP but not the second, on the
grounds that the type of the second operand can be inferred. However,
that makes the format complicated.
Change the writer so that it always emits FORWARDTYPEREF for a forward
ref. This unifies PushValueAndType() and pushValue(). pushValue()
gains a call to EmitFnForwardTypeRef() so becomes the same as
PushValueAndType().
Change the reader to be stricter, so that it requires a FORWARDTYPEREF
to have been emitted in most cases. This is done by ignoring the
implied type argument.
Tasks still remaining:
* Make reader stricter so that multiple FORWARDTYPEREFs are disallowed.
* Remove now-unused Type arguments in the reader.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507
TEST=new llvm-lit test + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/17806003
Diffstat (limited to 'test')
-rw-r--r-- | test/NaCl/Bitcode/forward-ref-decl.ll | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/NaCl/Bitcode/forward-ref-decl.ll b/test/NaCl/Bitcode/forward-ref-decl.ll new file mode 100644 index 0000000000..2aa344d6ac --- /dev/null +++ b/test/NaCl/Bitcode/forward-ref-decl.ll @@ -0,0 +1,58 @@ +; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump | FileCheck %s + +; Test that FORWARDTYPEREF declarations are emitted in the correct +; places. These are emitted for forward value references inside +; functions. + +define external void @_start(i32 %arg) { +; CHECK: <FUNCTION_BLOCK + + br label %bb1 +; CHECK: <INST_BR + +bb2: + ; This instruction contains two forward references, because %x and + ; %y are defined later in the function. + add i32 %forward1, %forward2 +; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <INST_BINOP abbrevid= + + ; The FORWARDTYPEREF declaration should only be emitted once per + ; value, so the following references will not emit more of them. + add i32 %forward1, %forward2 +; CHECK-NEXT: <INST_BINOP abbrevid= + + ; Test another case of a forward reference. + call void @_start(i32 %forward3) +; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <INST_CALL + + ; Test that FORWARDTYPEREF is generated for phi nodes (since phi + ; node operands are a special case in the writer). + br label %bb3 +bb3: + phi i32 [ %forward4, %bb2 ] +; CHECK-NEXT: <INST_BR +; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <INST_PHI + + ; Test that FORWARDTYPEREF is generated for switch instructions + ; (since switch condition operands are a special case in the + ; writer). + switch i32 %forward5, label %bb4 [i32 0, label %bb4] +bb4: +; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <INST_SWITCH + + ret void +; CHECK-NEXT: <INST_RET + +bb1: + %forward1 = add i32 %arg, 100 + %forward2 = add i32 %arg, 200 + %forward3 = add i32 %arg, 300 + %forward4 = add i32 %arg, 400 + %forward5 = add i32 %arg, 500 + br label %bb2 +} |