diff options
author | Yonghong Song <yhs@fb.com> | 2017-11-16 19:15:36 +0000 |
---|---|---|
committer | Yonghong Song <yhs@fb.com> | 2017-11-16 19:15:36 +0000 |
commit | 7a07b064e95d464a7192a4ea78ad902e232b9604 (patch) | |
tree | bb07f3249798cfc99a32250bc67aafeb2ae4b700 /test/CodeGen/BPF | |
parent | 4c98672343e4338ea7fc5f3a325f5fdc175314e5 (diff) |
bpf: print backward branch target properly
Currently, it prints the backward branch offset as unsigned value
like below:
7: 7d 34 0b 00 00 00 00 00 if r4 s>= r3 goto 11 <LBB0_3>
8: b7 00 00 00 00 00 00 00 r0 = 0
LBB0_2:
9: 07 00 00 00 01 00 00 00 r0 += 1
......
17: bf 31 00 00 00 00 00 00 r1 = r3
18: 6d 32 f6 ff 00 00 00 00 if r2 s> r3 goto 65526 <LBB0_3+0x7FFB0>
The correct print insn 18 should be:
18: 6d 32 f6 ff 00 00 00 00 if r2 s> r3 goto -10 <LBB0_2>
To provide better clarity and be consistent with kernel verifier output,
the insn 7 output is changed to the following with "+" added to
non-negative branch offset:
7: 7d 34 0b 00 00 00 00 00 if r4 s>= r3 goto +11 <LBB0_3>
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/BPF')
-rw-r--r-- | test/CodeGen/BPF/objdump_cond_op.ll | 6 | ||||
-rw-r--r-- | test/CodeGen/BPF/objdump_cond_op_2.ll | 39 |
2 files changed, 42 insertions, 3 deletions
diff --git a/test/CodeGen/BPF/objdump_cond_op.ll b/test/CodeGen/BPF/objdump_cond_op.ll index 3abbb76ccc9..b9dc122fe20 100644 --- a/test/CodeGen/BPF/objdump_cond_op.ll +++ b/test/CodeGen/BPF/objdump_cond_op.ll @@ -27,7 +27,7 @@ define i32 @test(i32, i32) local_unnamed_addr #0 { br label %13 ; CHECK: r1 <<= 32 ; CHECK: r1 >>= 32 -; CHECK: if r1 != 2 goto 6 <LBB0_2> +; CHECK: if r1 != 2 goto +6 <LBB0_2> ; <label>:8: ; preds = %2 %9 = icmp eq i32 %0, %1 @@ -38,7 +38,7 @@ define i32 @test(i32, i32) local_unnamed_addr #0 { ; CHECK: r0 = *(u32 *)(r1 + 0) ; CHECK: r0 *= r0 ; CHECK: r0 <<= 1 -; CHECK: goto 7 <LBB0_4> +; CHECK: goto +7 <LBB0_4> ; <label>:11: ; preds = %8 %12 = shl nsw i32 %10, 2 @@ -49,7 +49,7 @@ define i32 @test(i32, i32) local_unnamed_addr #0 { ; CHECK: r0 = *(u32 *)(r3 + 0) ; CHECK: r2 <<= 32 ; CHECK: r2 >>= 32 -; CHECK: if r1 == r2 goto 4 <LBB0_5> +; CHECK: if r1 == r2 goto +4 <LBB0_5> ; CHECK: r0 <<= 2 ; <label>:13: ; preds = %4, %11 diff --git a/test/CodeGen/BPF/objdump_cond_op_2.ll b/test/CodeGen/BPF/objdump_cond_op_2.ll new file mode 100644 index 00000000000..618fb6ce187 --- /dev/null +++ b/test/CodeGen/BPF/objdump_cond_op_2.ll @@ -0,0 +1,39 @@ +; RUN: llc -march=bpfel -filetype=obj -o - %s | llvm-objdump -d - | FileCheck %s + +; Source Code: +; int test(int a, int b) { +; int s = 0; +; while (a < b) { s++; a += s; b -= s; } +; return s; +; } + +define i32 @test(i32, i32) local_unnamed_addr #0 { +; CHECK-LABEL: test: + %3 = icmp slt i32 %0, %1 + br i1 %3, label %4, label %13 + +; <label>:4: ; preds = %2 + br label %5 +; CHECK: if r4 s>= r3 goto +11 <LBB0_3> +; CHECK: r0 = 0 +; CHECK-LABEL: LBB0_2: + +; <label>:5: ; preds = %4, %5 + %6 = phi i32 [ %9, %5 ], [ 0, %4 ] + %7 = phi i32 [ %11, %5 ], [ %1, %4 ] + %8 = phi i32 [ %10, %5 ], [ %0, %4 ] + %9 = add nuw nsw i32 %6, 1 + %10 = add nsw i32 %9, %8 + %11 = sub nsw i32 %7, %9 + %12 = icmp slt i32 %10, %11 + br i1 %12, label %5, label %13 +; CHECK: r1 = r3 +; CHECK: if r2 s> r3 goto -10 <LBB0_2> + +; <label>:13: ; preds = %5, %2 + %14 = phi i32 [ 0, %2 ], [ %9, %5 ] + ret i32 %14 +; CHECK-LABEL: LBB0_3: +; CHECK: exit +} +attributes #0 = { norecurse nounwind readnone } |