Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / bolt / test / RISCV / call-annotations.s
blob477c4693cd6dd72f970d9b175df02dfb0610b80b
1 /// Test that annotations are properly carried over to fixed calls.
2 /// Note that --enable-bat is used to force offsets to be kept.
4 // RUN: llvm-mc -triple riscv64 -mattr=+c -filetype obj -o %t.o %s
5 // RUN: ld.lld --emit-relocs -o %t %t.o
6 // RUN: llvm-bolt --enable-bat --print-cfg --print-fix-riscv-calls \
7 // RUN: -o /dev/null %t | FileCheck %s
9 .text
10 .option norvc
11 .global f
12 .p2align 1
14 ret
15 .size f, .-f
17 // CHECK-LABEL: Binary Function "_start" after building cfg {
18 // CHECK: auipc ra, f
19 // CHECK-NEXT: jalr ra, -4(ra) # Offset: 4
20 // CHECK-NEXT: jal ra, f # Offset: 8
21 // CHECK-NEXT: jal zero, f # TAILCALL # Offset: 12
23 // CHECK-LABEL: Binary Function "long_tail" after building cfg {
24 // CHECK: auipc t1, f
25 // CHECK-NEXT: jalr zero, -24(t1) # TAILCALL # Offset: 8
27 // CHECK-LABEL: Binary Function "compressed_tail" after building cfg {
28 // CHECK: jr a0 # TAILCALL # Offset: 0
30 // CHECK-LABEL: Binary Function "_start" after fix-riscv-calls {
31 // CHECK: call f # Offset: 0
32 // CHECK-NEXT: call f # Offset: 8
33 // CHECK-NEXT: tail f # TAILCALL # Offset: 12
35 // CHECK-LABEL: Binary Function "long_tail" after fix-riscv-calls {
36 // CHECK: tail f # TAILCALL # Offset: 4
38 // CHECK-LABEL: Binary Function "compressed_tail" after fix-riscv-calls {
39 // CHECK: jr a0 # TAILCALL # Offset: 0
41 .globl _start
42 .p2align 1
43 _start:
44 call f
45 jal f
46 jal zero, f
47 .size _start, .-_start
49 .globl long_tail
50 .p2align 1
51 long_tail:
52 // NOTE: BOLT assumes indirect calls in single-BB functions are tail calls
53 // so artificially introduce a second BB to force RISC-V-specific analysis
54 // to get triggered.
55 beq a0, a1, 1f
57 tail f
58 .size long_tail, .-long_tail
60 .globl compressed_tail
61 .p2align 1
62 .option rvc
63 compressed_tail:
64 c.jr a0
65 .size compressed_tail, .-compressed_tail