|
| 1 | +# Checking that .cfi-negate_ra_state directives are emitted in the same location as in the input in the case of no optimizations. |
| 2 | + |
1 | 3 | # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o |
2 | 4 | # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q |
| 5 | +# RUN: llvm-bolt %t.exe -o %t.exe.bolt --no-threads --print-all | FileCheck %s --check-prefix=CHECK-BOLT |
| 6 | + |
| 7 | +# Check that the negate-ra-state at the start of bar is not discarded. |
| 8 | +# If it was discarded, MarkRAState would report bar as having inconsistent RAStates. |
| 9 | +# CHECK-BOLT-NOT: BOLT-INFO: inconsistent RAStates in function foo |
| 10 | +# CHECK-BOLT-NOT: BOLT-INFO: inconsistent RAStates in function bar |
| 11 | + |
| 12 | +# Check that OpNegateRAState CFIs are generated correctly. |
| 13 | +# CHECK-BOLT: Binary Function "foo" after insert-negate-ra-state-pass { |
| 14 | +# CHECK-BOLT: paciasp |
| 15 | +# CHECK-BOLT-NEXT: OpNegateRAState |
| 16 | + |
| 17 | +# CHECK-BOLT: DWARF CFI Instructions: |
| 18 | +# CHECK-BOLT-NEXT: 0: OpNegateRAState |
| 19 | +# CHECK-BOLT-NEXT: End of Function "foo" |
| 20 | + |
| 21 | +# CHECK-BOLT: Binary Function "bar" after insert-negate-ra-state-pass { |
| 22 | +# CHECK-BOLT: OpNegateRAState |
| 23 | +# CHECK-BOLT-NEXT: mov x1, #0x0 |
| 24 | +# CHECK-BOLT-NEXT: mov x1, #0x1 |
| 25 | +# CHECK-BOLT-NEXT: autiasp |
| 26 | +# CHECK-BOLT-NEXT: OpNegateRAState |
| 27 | +# CHECK-BOLT-NEXT: ret |
3 | 28 |
|
4 | | -# RUN: llvm-objdump %t.exe -d > %t.exe.dump |
5 | | -# RUN: llvm-objdump --dwarf=frames %t.exe > %t.exe.dump-dwarf |
6 | | -# RUN: match-dwarf %t.exe.dump %t.exe.dump-dwarf foo > %t.match-dwarf.txt |
| 29 | +# CHECK-BOLT: DWARF CFI Instructions: |
| 30 | +# CHECK-BOLT-NEXT: 0: OpNegateRAState |
| 31 | +# CHECK-BOLT-NEXT: 1: OpNegateRAState |
| 32 | +# CHECK-BOLT-NEXT: End of Function "bar" |
7 | 33 |
|
8 | | -# RUN: llvm-bolt %t.exe -o %t.exe.bolt |
| 34 | +# End of negate-ra-state insertion logs for foo and bar. |
| 35 | +# CHECK: Binary Function "_start" after insert-negate-ra-state-pass { |
9 | 36 |
|
10 | | -# RUN: llvm-objdump %t.exe.bolt -d > %t.exe.bolt.dump |
11 | | -# RUN: llvm-objdump --dwarf=frames %t.exe.bolt > %t.exe.bolt.dump-dwarf |
12 | | -# RUN: match-dwarf %t.exe.bolt.dump %t.exe.bolt.dump-dwarf foo > %t.bolt.match-dwarf.txt |
| 37 | +# Check that the functions are in the new .text section |
| 38 | +# RUN: llvm-objdump %t.exe.bolt -d -j .text | FileCheck %s --check-prefix=CHECK-OBJDUMP |
| 39 | +# CHECK-OBJDUMP: <foo>: |
| 40 | +# CHECK-OBJDUMP: <bar>: |
13 | 41 |
|
14 | | -# RUN: diff %t.match-dwarf.txt %t.bolt.match-dwarf.txt |
15 | 42 |
|
16 | | - .text |
17 | | - .globl foo |
18 | | - .p2align 2 |
19 | | - .type foo,@function |
| 43 | + .text |
| 44 | + .globl foo |
| 45 | + .p2align 2 |
| 46 | + .type foo,@function |
20 | 47 | foo: |
21 | | - .cfi_startproc |
22 | | - hint #25 |
23 | | - .cfi_negate_ra_state |
24 | | - sub sp, sp, #16 |
25 | | - stp x29, x30, [sp, #16] // 16-byte Folded Spill |
26 | | - .cfi_def_cfa_offset 16 |
27 | | - str w0, [sp, #12] |
28 | | - ldr w8, [sp, #12] |
29 | | - add w0, w8, #1 |
30 | | - ldp x29, x30, [sp, #16] // 16-byte Folded Reload |
31 | | - add sp, sp, #16 |
32 | | - hint #29 |
33 | | - .cfi_negate_ra_state |
34 | | - ret |
35 | | -.Lfunc_end1: |
36 | | - .size foo, .Lfunc_end1-foo |
37 | | - .cfi_endproc |
38 | | - |
39 | | - .global _start |
40 | | - .type _start, %function |
| 48 | + .cfi_startproc |
| 49 | + paciasp |
| 50 | + .cfi_negate_ra_state |
| 51 | + mov x1, #0 |
| 52 | + b bar |
| 53 | + .cfi_endproc |
| 54 | + .size foo, .-foo |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + .text |
| 59 | + .globl bar |
| 60 | + .p2align 2 |
| 61 | + .type bar,@function |
| 62 | +bar: |
| 63 | + .cfi_startproc |
| 64 | + .cfi_negate_ra_state // Indicating that RA is signed from the start of bar. |
| 65 | + mov x1, #0 |
| 66 | + mov x1, #1 |
| 67 | + autiasp |
| 68 | + .cfi_negate_ra_state |
| 69 | + ret |
| 70 | + .cfi_endproc |
| 71 | + .size bar, .-bar |
| 72 | + |
| 73 | + .global _start |
| 74 | + .type _start, %function |
41 | 75 | _start: |
42 | | - b foo |
| 76 | + b foo |
0 commit comments