1 ;; Test the function attribute "patchable-function-entry".
2 ; RUN: llc -mtriple=riscv32 --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV32,NORVC
3 ; RUN: llc -mtriple=riscv64 --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV64,NORVC
4 ; RUN: llc -mtriple=riscv32 -mattr=+c --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV32,RVC
5 ; RUN: llc -mtriple=riscv64 -mattr=+c --riscv-no-aliases < %s | FileCheck %s --check-prefixes=CHECK,RV64,RVC
7 define void @f0() "patchable-function-entry"="0" {
9 ; CHECK-NEXT: .Lfunc_begin0:
10 ; CHECK-NOT: {{addi|c.nop}}
11 ; NORVC: jalr zero, 0(ra)
13 ; CHECK-NOT: .section __patchable_function_entries
17 define void @f1() "patchable-function-entry"="1" {
19 ; CHECK-NEXT: .Lfunc_begin1:
20 ; NORVC: addi zero, zero, 0
21 ; NORVC-NEXT: jalr zero, 0(ra)
24 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f1{{$}}
26 ; 32-NEXT: .word .Lfunc_begin1
28 ; 64-NEXT: .quad .Lfunc_begin1
33 define void @f5() "patchable-function-entry"="5" comdat {
35 ; CHECK-NEXT: .Lfunc_begin2:
36 ; NORVC-COUNT-5: addi zero, zero, 0
37 ; NORVC-NEXT: jalr zero, 0(ra)
40 ; CHECK: .section __patchable_function_entries,"awoG",@progbits,f5,f5,comdat{{$}}
42 ; RV32-NEXT: .word .Lfunc_begin2
44 ; RV64-NEXT: .quad .Lfunc_begin2
48 ;; -fpatchable-function-entry=3,2
49 ;; "patchable-function-prefix" emits data before the function entry label.
50 define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
51 ; CHECK-LABEL: .type f3_2,@function
53 ; NORVC-COUNT-2: addi zero, zero, 0
55 ; CHECK-NEXT: f3_2: # @f3_2
57 ; NORVC-NEXT: addi zero, zero, 0
58 ; NORVC-NEXT: addi sp, sp, -16
60 ; RVC-NEXT: c.addi sp, -16
61 ;; .size does not include the prefix.
63 ; CHECK-NEXT: .size f3_2, .Lfunc_end3-f3_2
64 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
66 ; RV32-NEXT: .word .Ltmp0
68 ; RV64-NEXT: .quad .Ltmp0
69 %frame = alloca i8, i32 16