1 ; RUN: llc -mtriple=i386 %s -o - | FileCheck --check-prefixes=CHECK,32 %s
2 ; RUN: llc -mtriple=x86_64 %s -o - | FileCheck --check-prefixes=CHECK,64 %s
3 ; RUN: llc -mtriple=x86_64 -function-sections %s -o - | FileCheck --check-prefixes=CHECK,64 %s
5 define void @f0() "patchable-function-entry"="0" {
7 ; CHECK-NEXT: .Lfunc_begin0:
10 ; CHECK-NOT: .section __patchable_function_entries
14 define void @f1() "patchable-function-entry"="1" {
16 ; CHECK-NEXT: .Lfunc_begin1:
19 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f1{{$}}
21 ; 32-NEXT: .long .Lfunc_begin1
23 ; 64-NEXT: .quad .Lfunc_begin1
27 ;; Without -function-sections, f2 is in the same text section as f1.
28 ;; They share the __patchable_function_entries section.
29 ;; With -function-sections, f1 and f2 are in different text sections.
30 ;; Use separate __patchable_function_entries.
31 define void @f2() "patchable-function-entry"="2" {
33 ; CHECK-NEXT: .Lfunc_begin2:
37 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f2{{$}}
39 ; 32-NEXT: .long .Lfunc_begin2
41 ; 64-NEXT: .quad .Lfunc_begin2
46 define void @f3() "patchable-function-entry"="3" comdat {
48 ; CHECK-NEXT: .Lfunc_begin3:
53 ; CHECK: .section __patchable_function_entries,"awoG",@progbits,f3,f3,comdat{{$}}
55 ; 32-NEXT: .long .Lfunc_begin3
57 ; 64-NEXT: .quad .Lfunc_begin3
62 define void @f5() "patchable-function-entry"="5" comdat {
64 ; CHECK-NEXT: .Lfunc_begin4:
65 ; 32-COUNT-2: xchgw %ax, %ax
67 ; 64: nopl 8(%rax,%rax)
69 ; CHECK: .section __patchable_function_entries,"awoG",@progbits,f5,f5,comdat{{$}}
71 ; 32-NEXT: .long .Lfunc_begin4
73 ; 64-NEXT: .quad .Lfunc_begin4
77 ;; -fpatchable-function-entry=3,2
78 ;; "patchable-function-prefix" emits data before the function entry label.
79 ;; We emit 1-byte NOPs before the function entry, so that with a partial patch,
80 ;; the remaining instructions do not need to be modified.
81 define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
82 ; CHECK-LABEL: .type f3_2,@function
86 ; CHECK-NEXT: f3_2: # @f3_2
90 ;; .size does not include the prefix.
92 ; CHECK-NEXT: .size f3_2, .Lfunc_end5-f3_2
93 ; CHECK: .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
95 ; 32-NEXT: .long .Ltmp0
97 ; 64-NEXT: .quad .Ltmp0
98 %frame = alloca i8, i32 16