1 // A contrived example to test the double jump removal peephole.
3 // RUN: %clang %cflags -O0 %s -o %t.exe
4 // RUN: llvm-bolt %t.exe -o %t.bolt --peepholes=double-jumps | \
5 // RUN: FileCheck %s -check-prefix=CHECKBOLT
6 // RUN: llvm-objdump --no-print-imm-hex -d %t.bolt | FileCheck %s
8 // CHECKBOLT: BOLT-INFO: Peephole: 1 double jumps patched.
11 // CHECK-NEXT: sub sp, sp, #16
12 // CHECK-NEXT: str x0, [sp, #8]
13 // CHECK-NEXT: ldr [[REG:x[0-28]+]], [sp, #8]
14 // CHECK-NEXT: cmp [[REG]], #0
15 // CHECK-NEXT: b.eq {{.*}} <_Z3foom+0x34>
16 // CHECK-NEXT: add [[REG]], [[REG]], #1
17 // CHECK-NEXT: add [[REG]], [[REG]], #1
18 // CHECK-NEXT: cmp [[REG]], #2
19 // CHECK-NEXT: b.eq {{.*}} <_Z3foom+0x28>
20 // CHECK-NEXT: add [[REG]], [[REG]], #1
21 // CHECK-NEXT: mov [[REG]], x1
22 // CHECK-NEXT: ldr x1, [sp]
23 // CHECK-NEXT: b {{.*}} <bar>
24 // CHECK-NEXT: ldr x1, [sp]
25 // CHECK-NEXT: add [[REG]], [[REG]], #1
26 // CHECK-NEXT: b {{.*}} <bar>
28 extern "C" unsigned long bar(unsigned long count
) { return count
+ 1; }
30 unsigned long foo(unsigned long count
) {
31 asm volatile(" cmp %0,#0\n"
36 ".L2: add %0, %0, #1\n"
41 ".L5: add %0, %0, #1\n"
55 extern "C" int _start() { return foo(38); }