|
| 1 | +# Checking that after reordering BasicBlocks, the generated OpNegateRAState instructions |
| 2 | +# are placed where the RA state is different between two consecutive instructions. |
| 3 | +# This case demonstrates, that the input might have a different amount than the output: |
| 4 | +# input has 4, but output only has 3. |
| 5 | + |
| 6 | +# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o |
| 7 | +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q |
| 8 | +# RUN: llvm-bolt %t.exe -o %t.exe.bolt --no-threads --reorder-blocks=reverse \ |
| 9 | +# RUN: --print-cfg --print-after-lowering --print-only foo | FileCheck %s |
| 10 | + |
| 11 | +# Check that the reordering succeeded. |
| 12 | +# CHECK: Binary Function "foo" after building cfg { |
| 13 | +# CHECK: BB Layout : .LBB00, .Ltmp2, .Ltmp0, .Ltmp1 |
| 14 | +# CHECK: Binary Function "foo" after inst-lowering { |
| 15 | +# CHECK: BB Layout : .LBB00, .Ltmp1, .Ltmp0, .Ltmp2 |
| 16 | + |
| 17 | + |
| 18 | +# Check the generated CFIs. |
| 19 | +# CHECK: OpNegateRAState |
| 20 | +# CHECK-NEXT: mov x2, #0x6 |
| 21 | + |
| 22 | +# CHECK: autiasp |
| 23 | +# CHECK-NEXT: OpNegateRAState |
| 24 | +# CHECK-NEXT: ret |
| 25 | + |
| 26 | +# CHECK: paciasp |
| 27 | +# CHECK-NEXT: OpNegateRAState |
| 28 | + |
| 29 | +# CHECK: DWARF CFI Instructions: |
| 30 | +# CHECK-NEXT: 0: OpNegateRAState |
| 31 | +# CHECK-NEXT: 1: OpNegateRAState |
| 32 | +# CHECK-NEXT: 2: OpNegateRAState |
| 33 | +# CHECK-NEXT: End of Function "foo" |
| 34 | + |
| 35 | + .text |
| 36 | + .globl foo |
| 37 | + .p2align 2 |
| 38 | + .type foo,@function |
| 39 | +foo: |
| 40 | + .cfi_startproc |
| 41 | + // RA is unsigned |
| 42 | + mov x1, #0 |
| 43 | + mov x1, #1 |
| 44 | + mov x1, #2 |
| 45 | + // jump into the signed "range" |
| 46 | + b .Lmiddle |
| 47 | +.Lback: |
| 48 | +// sign RA |
| 49 | + paciasp |
| 50 | + .cfi_negate_ra_state |
| 51 | + mov x2, #3 |
| 52 | + mov x2, #4 |
| 53 | + // skip unsigned instructions |
| 54 | + b .Lcont |
| 55 | + .cfi_negate_ra_state |
| 56 | +.Lmiddle: |
| 57 | +// RA is unsigned |
| 58 | + mov x4, #5 |
| 59 | + b .Lback |
| 60 | + .cfi_negate_ra_state |
| 61 | +.Lcont: |
| 62 | +// continue in signed state |
| 63 | + mov x2, #6 |
| 64 | + autiasp |
| 65 | + .cfi_negate_ra_state |
| 66 | + ret |
| 67 | + .cfi_endproc |
| 68 | + .size foo, .-foo |
| 69 | + |
| 70 | + .global _start |
| 71 | + .type _start, %function |
| 72 | +_start: |
| 73 | + b foo |
0 commit comments