1/// Test that annotations are properly carried over to fixed calls. 2/// Note that --enable-bat is used to force offsets to be kept. 3 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 %t.null %t | FileCheck %s 8 9 .text 10 .option norvc 11 .global f 12 .p2align 1 13f: 14 ret 15 .size f, .-f 16 17// CHECK-LABEL: Binary Function "_start" after building cfg { 18// CHECK: auipc ra, f 19// CHECK-NEXT: jalr -0x4(ra) # Offset: 4 20// CHECK-NEXT: jal f # Offset: 8 21// CHECK-NEXT: j f # TAILCALL # Offset: 12 22 23// CHECK-LABEL: Binary Function "long_tail" after building cfg { 24// CHECK: auipc t1, f 25// CHECK-NEXT: jr -0x18(t1) # TAILCALL # Offset: 8 26 27// CHECK-LABEL: Binary Function "compressed_tail" after building cfg { 28// CHECK: jr a0 # TAILCALL # Offset: 0 29 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 34 35// CHECK-LABEL: Binary Function "long_tail" after fix-riscv-calls { 36// CHECK: tail f # TAILCALL # Offset: 4 37 38// CHECK-LABEL: Binary Function "compressed_tail" after fix-riscv-calls { 39// CHECK: jr a0 # TAILCALL # Offset: 0 40 41 .globl _start 42 .p2align 1 43_start: 44 call f 45 jal f 46 jal zero, f 47 .size _start, .-_start 48 49 .globl long_tail 50 .p2align 1 51long_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 561: 57 tail f 58 .size long_tail, .-long_tail 59 60 .globl compressed_tail 61 .p2align 1 62 .option rvc 63compressed_tail: 64 c.jr a0 65 .size compressed_tail, .-compressed_tail 66