1 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
2 ; RUN: llc -mtriple=aarch64 -function-sections %s -o - | FileCheck %s
3 ; RUN: llc -mtriple=aarch64 -function-sections %s -o - | FileCheck %s
4 ; RUN: llc -mtriple=aarch64 -no-integrated-as -binutils-version=2.35 %s -o - | FileCheck --check-prefix=NOLINK %s
5 ; RUN: llc -mtriple=aarch64 -no-integrated-as -binutils-version=2.36 %s -o - | FileCheck %s
7 ;; GNU ld < 2.36 did not support mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections.
10 define i32 @f0() "patchable-function-entry"="0" {
12 ; CHECK-NEXT: .Lfunc_begin0:
15 ; CHECK-NOT: .section __patchable_function_entries
19 define i32 @f1() "patchable-function-entry"="1" {
21 ; CHECK-NEXT: .Lfunc_begin1:
23 ; CHECK-NEXT: mov w0, wzr
24 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f1{{$}}
25 ; CHECK-NEXT: .p2align 3
26 ; CHECK-NEXT: .xword .Lfunc_begin1
30 ;; Without -function-sections, f2 is in the same text section as f1.
31 ;; They share the __patchable_function_entries section.
32 ;; With -function-sections, f1 and f2 are in different text sections.
33 ;; Use separate __patchable_function_entries.
34 define void @f2() "patchable-function-entry"="2" {
36 ; CHECK-NEXT: .Lfunc_begin2:
39 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f2{{$}}
40 ; CHECK-NEXT: .p2align 3
41 ; CHECK-NEXT: .xword .Lfunc_begin2
46 define void @f3() "patchable-function-entry"="3" comdat {
48 ; CHECK-NEXT: .Lfunc_begin3:
51 ; CHECK: .section __patchable_function_entries,"aGwo",@progbits,f3,comdat,f3{{$}}
52 ; CHECK-NEXT: .p2align 3
53 ; CHECK-NEXT: .xword .Lfunc_begin3
58 define void @f5() "patchable-function-entry"="5" comdat {
60 ; CHECK-NEXT: .Lfunc_begin4:
62 ; CHECK-NEXT: sub sp, sp, #16
63 ; CHECK: .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
65 ; CHECK-NEXT: .xword .Lfunc_begin4
66 %frame = alloca i8, i32 16
70 ;; -fpatchable-function-entry=3,2
71 ;; "patchable-function-prefix" emits data before the function entry label.
72 define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
73 ; CHECK-LABEL: .type f3_2,@function
77 ; CHECK-NEXT: f3_2: // @f3_2
81 ;; .size does not include the prefix.
83 ; CHECK-NEXT: .size f3_2, .Lfunc_end5-f3_2
84 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
86 ; CHECK-NEXT: .xword .Ltmp1
90 ;; When prefix data is used, arbitrarily place NOPs after prefix data.
91 define void @prefix() "patchable-function-entry"="0" "patchable-function-prefix"="1" prefix i32 1 {
92 ; CHECK-LABEL: .type prefix,@function
93 ; CHECK-NEXT: .word 1 // 0x1
96 ; CHECK-NEXT: prefix: // @prefix
97 ;; Emit a __patchable_function_entries entry even if "patchable-function-entry" is 0.
98 ; CHECK: .section __patchable_function_entries,"awo",@progbits,prefix{{$}}
100 ; CHECK-NEXT: .xword .Ltmp2