diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-08-14 09:08:17 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-08-14 09:08:17 -0700 |
commit | 1e864cc8d25b2cb67d3765bc0f8018278df571bf (patch) | |
tree | 2de6a750c3e2e910480fd8ff8da63f4efe4529bb | |
parent | b1a2aa7439342d336015de1ff7ca8098b562a8b6 (diff) |
Allow record-level printing by pnacl-bcanalyzer.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3627
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/23060004
-rw-r--r-- | test/NaCl/Bitcode/alloca-operand.ll | 5 | ||||
-rw-r--r-- | test/NaCl/Bitcode/bcanalyzer-width.ll | 14 | ||||
-rw-r--r-- | test/NaCl/Bitcode/bitcast-elide.ll | 110 | ||||
-rw-r--r-- | test/NaCl/Bitcode/forward-ref-decl.ll | 19 | ||||
-rw-r--r-- | test/NaCl/Bitcode/globalvars.ll | 66 | ||||
-rw-r--r-- | test/NaCl/Bitcode/inttoptr-elide.ll | 96 | ||||
-rw-r--r-- | test/NaCl/Bitcode/struct-types.ll | 23 | ||||
-rw-r--r-- | tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp | 24 |
8 files changed, 192 insertions, 165 deletions
diff --git a/test/NaCl/Bitcode/alloca-operand.ll b/test/NaCl/Bitcode/alloca-operand.ll index 49df2fc8b0..fcabead6c7 100644 --- a/test/NaCl/Bitcode/alloca-operand.ll +++ b/test/NaCl/Bitcode/alloca-operand.ll @@ -1,4 +1,5 @@ -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump | FileCheck %s +; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \ +; RUN: | FileCheck %s ; Test that alloca's size operand is represented with a relative value ; ID, the same as other instructions' operands. @@ -24,5 +25,5 @@ define external void @_start(i32 %arg) { ; CHECK-NEXT: <INST_ALLOCA op0=5 ret void -; CHECK-NEXT: <INST_RET +; CHECK-NEXT: <INST_RET/> } diff --git a/test/NaCl/Bitcode/bcanalyzer-width.ll b/test/NaCl/Bitcode/bcanalyzer-width.ll index 57899120ef..e9c7c289cc 100644 --- a/test/NaCl/Bitcode/bcanalyzer-width.ll +++ b/test/NaCl/Bitcode/bcanalyzer-width.ll @@ -1,21 +1,23 @@ -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump \ +; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \ ; RUN: | FileCheck %s -check-prefix=BC -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump -operands-per-line=2 \ +; RUN: llvm-as < %s | pnacl-freeze \ +; RUN: | pnacl-bcanalyzer -dump-records -operands-per-line=2 \ ; RUN: | FileCheck %s -check-prefix=BC2 -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump -operands-per-line=8 \ +; RUN: llvm-as < %s | pnacl-freeze \ +; RUN: | pnacl-bcanalyzer -dump-records -operands-per-line=8 \ ; RUN: | FileCheck %s -check-prefix=BC8 ; Test that the command-line option -operands-per-line works as expected. @bytes = internal global [10 x i8] c"abcdefghij" -; BC: <DATA abbrevid=7 op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103 op7=104 op8=105 op9=106/> +; BC: <DATA op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103 op7=104 op8=105 op9=106/> -; BC2: <DATA abbrevid=7 op0=97 op1=98 +; BC2: <DATA op0=97 op1=98 ; BC2: op2=99 op3=100 ; BC2: op4=101 op5=102 ; BC2: op6=103 op7=104 ; BC2: op8=105 op9=106/> -; BC8: <DATA abbrevid=7 op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103 op7=104 +; BC8: <DATA op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103 op7=104 ; BC8: op8=105 op9=106/> diff --git a/test/NaCl/Bitcode/bitcast-elide.ll b/test/NaCl/Bitcode/bitcast-elide.ll index baacfde558..eeee69ffef 100644 --- a/test/NaCl/Bitcode/bitcast-elide.ll +++ b/test/NaCl/Bitcode/bitcast-elide.ll @@ -1,13 +1,15 @@ ; Test how we handle eliding (pointer) bitcast instructions. ; TODO(kschimpf) Expand these tests as further CL's are added for issue 3544. -; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 | pnacl-bcanalyzer -dump \ +; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 \ +; RUN: | pnacl-bcanalyzer -dump-records \ ; RUN: | FileCheck %s -check-prefix=PF1 ; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 | pnacl-thaw \ ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD1 -; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 | pnacl-bcanalyzer -dump \ +; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 \ +; RUN: | pnacl-bcanalyzer -dump-records \ ; RUN: | FileCheck %s -check-prefix=PF2 ; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 | pnacl-thaw \ @@ -30,11 +32,11 @@ define void @SimpleLoad() { ; TD1-NEXT: ret void ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=2 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=11/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=8/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=11/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_RET/> ; PF1-NEXT: </FUNCTION_BLOCK> ; TD2: define void @SimpleLoad() { @@ -43,10 +45,10 @@ define void @SimpleLoad() { ; TD2-NEXT: ret void ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=2 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=8/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_RET/> ; PF2-NEXT: </FUNCTION_BLOCK> ; Test that we elide the simple case of an alloca. @@ -64,14 +66,14 @@ define void @SimpleLoadAlloca() { ; TD1-NEXT: ret void ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> ; PF1-NEXT: <CONSTANTS_BLOCK ; PF1: </CONSTANTS_BLOCK> ; PF1-NEXT: <INST_ALLOCA op0=1 op1=3/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=11/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=8/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=11/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_RET/> ; PF1-NEXT: </FUNCTION_BLOCK> ; TD2: define void @SimpleLoadAlloca() { @@ -81,13 +83,13 @@ define void @SimpleLoadAlloca() { ; TD2-NEXT: ret void ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> ; PF2-NEXT: <CONSTANTS_BLOCK ; PF2: </CONSTANTS_BLOCK> ; PF2-NEXT: <INST_ALLOCA op0=1 op1=3/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=8/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_RET/> ; PF2-NEXT: </FUNCTION_BLOCK> ; Test that we don't elide an bitcast if one of its uses is not a load. @@ -103,11 +105,11 @@ define i32* @NonsimpleLoad(i32 %i) { ; TD1-NEXT: ret i32* %1 ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=2 op1=1 op2=11/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=9 op0=2/> +; PF1-NEXT: <INST_CAST op0=2 op1=1 op2=11/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_RET op0=2/> ; PF1: </FUNCTION_BLOCK> ; TD2: define i32* @NonsimpleLoad(i32 %i) { @@ -116,11 +118,11 @@ define i32* @NonsimpleLoad(i32 %i) { ; TD2-NEXT: ret i32* %1 ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CAST abbrevid=7 op0=2 op1=1 op2=11/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=9 op0=2/> +; PF2-NEXT: <INST_CAST op0=2 op1=1 op2=11/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_RET op0=2/> ; PF2: </FUNCTION_BLOCK> ; Test that we can handle multiple bitcasts. @@ -142,14 +144,14 @@ define i32 @TwoLoads(i32 %i) { ; TD1-NEXT: ret i32 %5 ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=8 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=2 op1=1 op2=11/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=4 op1=1 op2=11/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_BINOP abbrevid=5 op0=3 op1=1 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF1-NEXT: <INST_CAST op0=2 op1=1 op2=11/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_CAST op0=4 op1=1 op2=11/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_BINOP op0=3 op1=1 op2=0/> +; PF1-NEXT: <INST_RET op0=1/> ; PF1: </FUNCTION_BLOCK> ; TD2: define i32 @TwoLoads(i32 %i) { @@ -161,12 +163,12 @@ define i32 @TwoLoads(i32 %i) { ; TD2-NEXT: ret i32 %5 ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=2 op1=3 op2=0/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=3 op1=3 op2=0/> -; PF2-NEXT: <INST_BINOP abbrevid=5 op0=2 op1=1 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> +; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> +; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> +; PF2-NEXT: <INST_RET op0=1/> ; PF2: </FUNCTION_BLOCK> ; Test how we duplicate bitcasts, even if optimized in the input file. @@ -186,13 +188,13 @@ define i32 @TwoLoadOpt(i32 %i) { ; TD1-NEXT: ret i32 %4 ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=2 op1=1 op2=11/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=2 op1=3 op2=0/> -; PF1-NEXT: <INST_BINOP abbrevid=5 op0=2 op1=1 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF1-NEXT: <INST_CAST op0=2 op1=1 op2=11/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> +; PF1-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> +; PF1-NEXT: <INST_RET op0=1/> ; PF1: </FUNCTION_BLOCK> ; TD2: define i32 @TwoLoadOpt(i32 %i) { @@ -204,12 +206,12 @@ define i32 @TwoLoadOpt(i32 %i) { ; TD2-NEXT: ret i32 %5 ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=2 op1=3 op2=0/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=3 op1=3 op2=0/> -; PF2-NEXT: <INST_BINOP abbrevid=5 op0=2 op1=1 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> +; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> +; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> +; PF2-NEXT: <INST_RET op0=1/> ; PF2: </FUNCTION_BLOCK> ; Test that we elide the simple case of bitcast for a store. @@ -225,11 +227,11 @@ define void @SimpleStore(i32 %i) { ; TD1-NEXT: ret void ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=2 op1=1 op2=11/> -; PF1-NEXT: <INST_STORE abbrevid=12 op0=1 op1=2 op2=3 op3=0/> -; PF1-NEXT: <INST_RET abbrevid=8/> +; PF1-NEXT: <INST_CAST op0=2 op1=1 op2=11/> +; PF1-NEXT: <INST_STORE op0=1 op1=2 op2=3 op3=0/> +; PF1-NEXT: <INST_RET/> ; PF1: </FUNCTION_BLOCK> ; TD2: define void @SimpleStore(i32 %i) { @@ -238,8 +240,8 @@ define void @SimpleStore(i32 %i) { ; TD2-NEXT: ret void ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=5 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_STORE abbrevid=12 op0=2 op1=1 op2=3/> -; PF2-NEXT: <INST_RET abbrevid=8/> +; PF2-NEXT: <INST_STORE op0=2 op1=1 op2=3/> +; PF2-NEXT: <INST_RET/> ; PF2: </FUNCTION_BLOCK> diff --git a/test/NaCl/Bitcode/forward-ref-decl.ll b/test/NaCl/Bitcode/forward-ref-decl.ll index 2aa344d6ac..ac02c850d7 100644 --- a/test/NaCl/Bitcode/forward-ref-decl.ll +++ b/test/NaCl/Bitcode/forward-ref-decl.ll @@ -1,4 +1,5 @@ -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump | FileCheck %s +; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \ +; RUN: | FileCheck %s ; Test that FORWARDTYPEREF declarations are emitted in the correct ; places. These are emitted for forward value references inside @@ -14,18 +15,18 @@ 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= +; CHECK-NEXT: <FORWARDTYPEREF +; CHECK-NEXT: <FORWARDTYPEREF +; CHECK-NEXT: <INST_BINOP ; 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= +; CHECK-NEXT: <INST_BINOP ; Test another case of a forward reference. call void @_start(i32 %forward3) -; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <FORWARDTYPEREF ; CHECK-NEXT: <INST_CALL ; Test that FORWARDTYPEREF is generated for phi nodes (since phi @@ -34,7 +35,7 @@ bb2: bb3: phi i32 [ %forward4, %bb2 ] ; CHECK-NEXT: <INST_BR -; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <FORWARDTYPEREF ; CHECK-NEXT: <INST_PHI ; Test that FORWARDTYPEREF is generated for switch instructions @@ -42,11 +43,11 @@ bb3: ; writer). switch i32 %forward5, label %bb4 [i32 0, label %bb4] bb4: -; CHECK-NEXT: <FORWARDTYPEREF abbrevid= +; CHECK-NEXT: <FORWARDTYPEREF ; CHECK-NEXT: <INST_SWITCH ret void -; CHECK-NEXT: <INST_RET +; CHECK-NEXT: <INST_RET/> bb1: %forward1 = add i32 %arg, 100 diff --git a/test/NaCl/Bitcode/globalvars.ll b/test/NaCl/Bitcode/globalvars.ll index fd1f8eead2..811123dd0e 100644 --- a/test/NaCl/Bitcode/globalvars.ll +++ b/test/NaCl/Bitcode/globalvars.ll @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | pnacl-freeze | pnacl-thaw | llvm-dis - | FileCheck %s -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump \ +; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \ ; RUN: | FileCheck %s -check-prefix=BC ; Test that we generate appropriate bitcode values for global variables. @@ -22,81 +22,81 @@ @bytes = internal global [7 x i8] c"abcdefg" ; CHECK: @bytes = internal global [7 x i8] c"abcdefg" -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <DATA abbrevid=7 op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <DATA op0=97 op1=98 op2=99 op3=100 op4=101 op5=102 op6=103/> @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) ; CHECK: @ptr_to_ptr = internal global i32 ptrtoint (i32* @ptr to i32) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=8 op0=5/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=5/> @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) ; CHECK: @ptr_to_func = internal global i32 ptrtoint (void ()* @func to i32) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=8 op0=0/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=0/> @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> ; CHECK: @compound = internal global <{ [3 x i8], i32 }> <{ [3 x i8] c"foo", i32 ptrtoint (void ()* @func to i32) }> -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <COMPOUND abbrevid=5 op0=2/> -; BC-NEXT: <DATA abbrevid=7 op0=102 op1=111 op2=111/> -; BC-NEXT: <RELOC abbrevid=8 op0=0/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <COMPOUND op0=2/> +; BC-NEXT: <DATA op0=102 op1=111 op2=111/> +; BC-NEXT: <RELOC op0=0/> @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) ; CHECK: @ptr = internal global i32 ptrtoint ([7 x i8]* @bytes to i32) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=8 op0=1/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=1/> @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) ; CHECK: @addend_ptr = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 1) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=5 op1=1/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=5 op1=1/> @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) ; CHECK: @addend_negative = internal global i32 add (i32 ptrtoint (i32* @ptr to i32), i32 -1) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=5 op1=4294967295/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=5 op1=4294967295/> @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) ; CHECK: @addend_array1 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 1) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=1 op1=1/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=1 op1=1/> @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) ; CHECK: @addend_array2 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 7) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=1 op1=7/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=1 op1=7/> @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) ; CHECK: @addend_array3 = internal global i32 add (i32 ptrtoint ([7 x i8]* @bytes to i32), i32 9) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=1 op1=9/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=1 op1=9/> @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) ; CHECK: @addend_struct1 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 1) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=4 op1=1/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=4 op1=1/> @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) ; CHECK: @addend_struct2 = internal global i32 add (i32 ptrtoint (<{ [3 x i8], i32 }>* @compound to i32), i32 4) -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=0/> -; BC-NEXT: <RELOC abbrevid=9 op0=4 op1=4/> +; BC-NEXT: <VAR op0=0 op1=0/> +; BC-NEXT: <RELOC op0=4 op1=4/> @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 ; CHECK: @ptr_to_func_align = internal global i32 ptrtoint (void ()* @func to i32), align 8 -; BC-NEXT: <VAR abbrevid=4 op0=4 op1=0/> -; BC-NEXT: <RELOC abbrevid=8 op0=0/> +; BC-NEXT: <VAR op0=4 op1=0/> +; BC-NEXT: <RELOC op0=0/> @char = internal constant [1 x i8] c"0" ; CHECK: @char = internal constant [1 x i8] c"0" -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=1/> -; BC-NEXT: <DATA abbrevid=7 op0=48/> +; BC-NEXT: <VAR op0=0 op1=1/> +; BC-NEXT: <DATA op0=48/> @short = internal constant [2 x i8] zeroinitializer ; CHECK: @short = internal constant [2 x i8] zeroinitializer -; BC-NEXT: <VAR abbrevid=4 op0=0 op1=1/> -; BC-NEXT: <ZEROFILL abbrevid=6 op0=2/> +; BC-NEXT: <VAR op0=0 op1=1/> +; BC-NEXT: <ZEROFILL op0=2/> ; BC-NEXT: </GLOBALVAR_BLOCK> diff --git a/test/NaCl/Bitcode/inttoptr-elide.ll b/test/NaCl/Bitcode/inttoptr-elide.ll index 8d573c8ca5..029f67adef 100644 --- a/test/NaCl/Bitcode/inttoptr-elide.ll +++ b/test/NaCl/Bitcode/inttoptr-elide.ll @@ -1,13 +1,15 @@ ; Test how we handle eliding inttoptr instructions. ; TODO(kschimpf) Expand these tests as further CL's are added for issue 3544. -; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 | pnacl-bcanalyzer -dump \ +; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 \ +; RUN: | pnacl-bcanalyzer -dump-records \ ; RUN: | FileCheck %s -check-prefix=PF1 ; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 | pnacl-thaw \ ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD1 -; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 | pnacl-bcanalyzer -dump \ +; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 \ +; RUN: | pnacl-bcanalyzer -dump-records \ ; RUN: | FileCheck %s -check-prefix=PF2 ; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 | pnacl-thaw \ @@ -28,11 +30,11 @@ define void @SimpleLoad(i32 %i) { ; TD1-NEXT: ret void ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=10/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=8/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=10/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_RET/> ; PF1: </FUNCTION_BLOCK> ; TD2: define void @SimpleLoad(i32 %i) { @@ -41,10 +43,10 @@ define void @SimpleLoad(i32 %i) { ; TD2-NEXT: ret void ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=5 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=8/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_RET/> ; PF2: </FUNCTION_BLOCK> ; ------------------------------------------------------ @@ -62,11 +64,11 @@ define i32* @NonsimpleLoad(i32 %i) { ; TD1-NEXT: ret i32* %1 ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=10/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=9 op0=2/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=10/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_RET op0=2/> ; PF1: </FUNCTION_BLOCK> ; TD2: define i32* @NonsimpleLoad(i32 %i) { @@ -75,11 +77,11 @@ define i32* @NonsimpleLoad(i32 %i) { ; TD2-NEXT: ret i32* %1 ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=10/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=9 op0=2/> +; PF2-NEXT: <INST_CAST op0=1 op1=1 op2=10/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_RET op0=2/> ; PF2: </FUNCTION_BLOCK> ; ------------------------------------------------------ @@ -103,14 +105,14 @@ define i32 @TwoLoads(i32 %i) { ; TD1-NEXT: ret i32 %5 ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=8 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=10/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=3 op1=1 op2=10/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_BINOP abbrevid=5 op0=3 op1=1 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=10/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_CAST op0=3 op1=1 op2=10/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_BINOP op0=3 op1=1 op2=0/> +; PF1-NEXT: <INST_RET op0=1/> ; PF1: </FUNCTION_BLOCK> ; TD2: define i32 @TwoLoads(i32 %i) { @@ -123,12 +125,12 @@ define i32 @TwoLoads(i32 %i) { ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=2 op1=3 op2=0/> -; PF2-NEXT: <INST_BINOP abbrevid=5 op0=2 op1=1 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> +; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> +; PF2-NEXT: <INST_RET op0=1/> ; PF2: </FUNCTION_BLOCK> ; ------------------------------------------------------ @@ -150,13 +152,13 @@ define i32 @TwoLoadOpt(i32 %i) { ; TD1-NEXT: ret i32 %4 ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=10/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF1-NEXT: <INST_LOAD abbrevid=4 op0=2 op1=3 op2=0/> -; PF1-NEXT: <INST_BINOP abbrevid=5 op0=2 op1=1 op2=0/> -; PF1-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=10/> +; PF1-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF1-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> +; PF1-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> +; PF1-NEXT: <INST_RET op0=1/> ; PF1: </FUNCTION_BLOCK> ; TD2: define i32 @TwoLoadOpt(i32 %i) { @@ -168,12 +170,12 @@ define i32 @TwoLoadOpt(i32 %i) { ; TD2-NEXT: ret i32 %5 ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=7 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=1 op1=3 op2=0/> -; PF2-NEXT: <INST_LOAD abbrevid=4 op0=2 op1=3 op2=0/> -; PF2-NEXT: <INST_BINOP abbrevid=5 op0=2 op1=1 op2=0/> -; PF2-NEXT: <INST_RET abbrevid=9 op0=1/> +; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> +; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> +; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> +; PF2-NEXT: <INST_RET op0=1/> ; PF2: </FUNCTION_BLOCK> ; ------------------------------------------------------ @@ -191,11 +193,11 @@ define void @SimpleStore(i32 %i) { ; TD1-NEXT: ret void ; TD1-NEXT: } -; PF1: <FUNCTION_BLOCK NumWords=6 BlockCodeSize=4> +; PF1: <FUNCTION_BLOCK> ; PF1-NEXT: <DECLAREBLOCKS op0=1/> -; PF1-NEXT: <INST_CAST abbrevid=7 op0=1 op1=1 op2=10/> -; PF1-NEXT: <INST_STORE abbrevid=12 op0=1 op1=2 op2=3 op3=0/> -; PF1-NEXT: <INST_RET abbrevid=8/> +; PF1-NEXT: <INST_CAST op0=1 op1=1 op2=10/> +; PF1-NEXT: <INST_STORE op0=1 op1=2 op2=3 op3=0/> +; PF1-NEXT: <INST_RET/> ; PF1: </FUNCTION_BLOCK> ; TD2: define void @SimpleStore(i32 %i) { @@ -204,8 +206,8 @@ define void @SimpleStore(i32 %i) { ; TD2-NEXT: ret void ; TD2-NEXT: } -; PF2: <FUNCTION_BLOCK NumWords=5 BlockCodeSize=4> +; PF2: <FUNCTION_BLOCK> ; PF2-NEXT: <DECLAREBLOCKS op0=1/> -; PF2-NEXT: <INST_STORE abbrevid=12 op0=1 op1=1 op2=3/> -; PF2-NEXT: <INST_RET abbrevid=8/> +; PF2-NEXT: <INST_STORE op0=1 op1=1 op2=3/> +; PF2-NEXT: <INST_RET/> ; PF2T: </FUNCTION_BLOCK> diff --git a/test/NaCl/Bitcode/struct-types.ll b/test/NaCl/Bitcode/struct-types.ll index a36e6bb0ab..b2f7dc62a8 100644 --- a/test/NaCl/Bitcode/struct-types.ll +++ b/test/NaCl/Bitcode/struct-types.ll @@ -2,7 +2,8 @@ ; even if the struct definintion appears after the pointer type, while ; pnacl bitcode moves the pointer before the struct. ; RUN: llvm-as < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=LLVM -; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump | FileCheck %s -check-prefix=PNACL +; RUN: llvm-as < %s | pnacl-freeze | pnacl-bcanalyzer -dump-records \ +; RUN: | FileCheck %s -check-prefix=PNACL %typeB = type { i8, %typeA, i32, %typeA } %typeA = type { i16 } @@ -50,29 +51,29 @@ define i16 @bam(i16 %a) { ; LLVM: </TYPE_BLOCK_ID> ; Show the ordering pnacl-freeze uses to order types. -; PNACL: <TYPE_BLOCK_ID {{.*}}> +; PNACL: <TYPE_BLOCK_ID> ; %typeB* -; PNACL: <POINTER abbrevid=4 op0=8 op1=0/> +; PNACL: <POINTER op0=8 op1=0/> ; i16 ; PNACL: <INTEGER op0=16/> ; type of instruction "RET" ; PNACL: <VOID/> ; %typeA = type { i16 } -; PNACL: <STRUCT_NAME abbrevid=7 op0=116 op1=121 op2=112 op3=101 op4=65/> -; PNACL: <STRUCT_NAMED abbrevid=8 op0=0 op1=1/> +; PNACL: <STRUCT_NAME op0=116 op1=121 op2=112 op3=101 op4=65/> +; PNACL: <STRUCT_NAMED op0=0 op1=1/> ; %typeB* (%typeB*) -; PNACL: <FUNCTION abbrevid=5 op0=0 op1=0 op2=0/> +; PNACL: <FUNCTION op0=0 op1=0 op2=0/> ; %typeB* (%typeB*)* -; PNACL: <POINTER abbrevid=4 op0=4 op1=0/> +; PNACL: <POINTER op0=4 op1=0/> ; i8 ; PNACL: <INTEGER op0=8/> ; i32 ; PNACL: <INTEGER op0=32/> ; %typeB = type { i8, %typeA, i32, %typeA } -; PNACL: <STRUCT_NAME abbrevid=7 op0=116 op1=121 op2=112 op3=101 op4=66/> -; PNACL: <STRUCT_NAMED abbrevid=8 op0=0 op1=6 op2=3 op3=7 op4=3/> +; PNACL: <STRUCT_NAME op0=116 op1=121 op2=112 op3=101 op4=66/> +; PNACL: <STRUCT_NAMED op0=0 op1=6 op2=3 op3=7 op4=3/> ; i16 (i16) -; PNACL: <FUNCTION abbrevid=5 op0=0 op1=1 op2=1/> +; PNACL: <FUNCTION op0=0 op1=1 op2=1/> ; i16 (i16)* -; PNACL: <POINTER abbrevid=4 op0=9 op1=0/> +; PNACL: <POINTER op0=9 op1=0/> ; PNACL: </TYPE_BLOCK_ID> diff --git a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp index 225827e47b..2e4ff2d162 100644 --- a/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp +++ b/tools/pnacl-bcanalyzer/pnacl-bcanalyzer.cpp @@ -15,6 +15,11 @@ // Options: // --help - Output information about command line switches // --dump - Dump low-level bitcode structure in readable format +// --dump-records - Dump a neutral form of the low-level bitcode structure +// in a readable form. This form doesn't print out summary +// statistics. Also, unlike --dump, no bitstream file +// encoding information is printed. Only the high-level +// record data is dumped. // // This tool provides analytical information about a bitcode file. It is // intended as an aid to developers of bitcode reading and writing software. It @@ -54,6 +59,12 @@ static cl::opt<std::string> static cl::opt<bool> Dump("dump", cl::desc("Dump low level bitcode trace")); +static cl::opt<bool> + Records("dump-records", + cl::desc("Dump contents of records in bitcode, leaving out" + " all bitstreaming information (including abbreviations)"), + cl::init(false)); + static cl::opt<unsigned> OpsPerLine( "operands-per-line", cl::desc("Number of operands to print per dump line. 0 implies " @@ -361,8 +372,11 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID, if (NonSymbolic && BlockName) outs() << " BlockID=" << BlockID; - outs() << " NumWords=" << NumWords - << " BlockCodeSize=" << Stream.getAbbrevIDWidth() << ">\n"; + if (!Records) { + outs() << " NumWords=" << NumWords + << " BlockCodeSize=" << Stream.getAbbrevIDWidth(); + } + outs() << ">\n"; } SmallVector<uint64_t, 64> Record; @@ -444,7 +458,7 @@ static bool ParseBlock(NaClBitstreamCursor &Stream, unsigned BlockID, outs() << "UnknownCode" << Code; if (NonSymbolic && CodeName) outs() << " codeid=" << Code; - if (Entry.ID != naclbitc::UNABBREV_RECORD) + if (!Records && Entry.ID != naclbitc::UNABBREV_RECORD) outs() << " abbrevid=" << Entry.ID; for (unsigned i = 0, e = Record.size(); i != e; ++i) { @@ -544,6 +558,8 @@ static int AnalyzeBitcode() { if (Dump) outs() << "\n\n"; + if (Records) return 0; + uint64_t BufferSizeBits = (EndBufPtr-BufPtr)*CHAR_BIT; // Print a summary of the read file. outs() << "Summary of " << InputFilename << ":\n"; @@ -637,5 +653,7 @@ int main(int argc, char **argv) { llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. cl::ParseCommandLineOptions(argc, argv, "pnacl-bcanalyzer file analyzer\n"); + if (Records) Dump = true; + return AnalyzeBitcode(); } |