@@ -24,8 +24,13 @@ define void @f1() "patchable-function-entry"="1" {
24
24
ret void
25
25
}
26
26
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.
27
31
define void @f2 () "patchable-function-entry" ="2" {
28
32
; CHECK-LABEL: f2:
33
+ ; CHECK-NEXT: .Lfunc_begin2:
29
34
; 32-COUNT-2: nop
30
35
; 64: xchgw %ax, %ax
31
36
; CHECK-NEXT: ret
@@ -41,6 +46,7 @@ define void @f2() "patchable-function-entry"="2" {
41
46
$f3 = comdat any
42
47
define void @f3 () "patchable-function-entry" ="3" comdat {
43
48
; CHECK-LABEL: f3:
49
+ ; CHECK-NEXT: .Lfunc_begin3:
44
50
; 32-COUNT-3: nop
45
51
; 64: nopl (%rax)
46
52
; CHECK: ret
@@ -56,6 +62,7 @@ define void @f3() "patchable-function-entry"="3" comdat {
56
62
$f5 = comdat any
57
63
define void @f5 () "patchable-function-entry" ="5" comdat {
58
64
; CHECK-LABEL: f5:
65
+ ; CHECK-NEXT: .Lfunc_begin4:
59
66
; 32-COUNT-5: nop
60
67
; 64: nopl 8(%rax,%rax)
61
68
; CHECK-NEXT: ret
@@ -67,3 +74,29 @@ define void @f5() "patchable-function-entry"="5" comdat {
67
74
; 64-NEXT: .quad .Lfunc_begin4
68
75
ret void
69
76
}
77
+
78
+ ;; -fpatchable-function-entry=3,2
79
+ ;; "patchable-function-prefix" emits data before the function entry label.
80
+ ;; We emit 1-byte NOPs before the function entry, so that with a partial patch,
81
+ ;; the remaining instructions do not need to be modified.
82
+ define void @f3_2 () "patchable-function-entry" ="1" "patchable-function-prefix" ="2" {
83
+ ; CHECK-LABEL: .type f3_2,@function
84
+ ; CHECK-NEXT: .Ltmp0: # @f3_2
85
+ ; CHECK-NEXT: nop
86
+ ; CHECK-NEXT: nop
87
+ ; CHECK-NEXT: f3_2:
88
+ ; CHECK: # %bb.0:
89
+ ; CHECK-NEXT: nop
90
+ ; CHECK-NEXT: ret
91
+ ;; .size does not include the prefix.
92
+ ; CHECK: .Lfunc_end5:
93
+ ; CHECK-NEXT: .size f3_2, .Lfunc_end5-f3_2
94
+ ; NOFSECT .section __patchable_function_entries,"awo",@progbits,f0,unique,0
95
+ ; FSECT: .section __patchable_function_entries,"awo",@progbits,f3_2,unique,4
96
+ ; 32: .p2align 2
97
+ ; 32-NEXT: .long .Ltmp0
98
+ ; 64: .p2align 3
99
+ ; 64-NEXT: .quad .Ltmp0
100
+ %frame = alloca i8 , i32 16
101
+ ret void
102
+ }
0 commit comments