2020-02-15 12:35:04 +08:00
|
|
|
; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
|
|
|
|
; RUN: llc -mtriple=aarch64 -function-sections %s -o - | FileCheck %s
|
2021-02-06 11:53:06 +08:00
|
|
|
; RUN: llc -mtriple=aarch64 -function-sections %s -o - | FileCheck %s
|
|
|
|
; RUN: llc -mtriple=aarch64 -no-integrated-as -binutils-version=2.35 %s -o - | FileCheck --check-prefix=NOLINK %s
|
|
|
|
; RUN: llc -mtriple=aarch64 -no-integrated-as -binutils-version=2.36 %s -o - | FileCheck %s
|
2020-01-03 16:35:47 +08:00
|
|
|
|
2021-02-06 11:53:06 +08:00
|
|
|
;; GNU ld < 2.36 did not support mixed SHF_LINK_ORDER and non-SHF_LINK_ORDER sections.
|
2020-01-03 16:35:47 +08:00
|
|
|
; NOLINK-NOT: "awo"
|
|
|
|
|
|
|
|
define i32 @f0() "patchable-function-entry"="0" {
|
|
|
|
; CHECK-LABEL: f0:
|
|
|
|
; CHECK-NEXT: .Lfunc_begin0:
|
|
|
|
; CHECK-NOT: nop
|
|
|
|
; CHECK: mov w0, wzr
|
2020-01-21 07:52:38 +08:00
|
|
|
; CHECK-NOT: .section __patchable_function_entries
|
2020-01-03 16:35:47 +08:00
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @f1() "patchable-function-entry"="1" {
|
|
|
|
; CHECK-LABEL: f1:
|
|
|
|
; CHECK-NEXT: .Lfunc_begin1:
|
|
|
|
; CHECK: nop
|
|
|
|
; CHECK-NEXT: mov w0, wzr
|
2020-02-15 12:35:04 +08:00
|
|
|
; CHECK: .section __patchable_function_entries,"awo",@progbits,f1{{$}}
|
2020-01-03 16:35:47 +08:00
|
|
|
; CHECK-NEXT: .p2align 3
|
|
|
|
; CHECK-NEXT: .xword .Lfunc_begin1
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
Add function attribute "patchable-function-prefix" to support -fpatchable-function-entry=N,M where M>0
Similar to the function attribute `prefix` (prefix data),
"patchable-function-prefix" inserts data (M NOPs) before the function
entry label.
-fpatchable-function-entry=2,1 (1 NOP before entry, 1 NOP after entry)
will look like:
```
.type foo,@function
.Ltmp0: # @foo
nop
foo:
.Lfunc_begin0:
# optional `bti c` (AArch64 Branch Target Identification) or
# `endbr64` (Intel Indirect Branch Tracking)
nop
.section __patchable_function_entries,"awo",@progbits,get,unique,0
.p2align 3
.quad .Ltmp0
```
-fpatchable-function-entry=N,0 + -mbranch-protection=bti/-fcf-protection=branch has two reasonable
placements (https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01185.html):
```
(a) (b)
func: func:
.Ltmp0: bti c
bti c .Ltmp0:
nop nop
```
(a) needs no additional code. If the consensus is to go for (b), we will
need more code in AArch64BranchTargets.cpp / X86IndirectBranchTracking.cpp .
Differential Revision: https://reviews.llvm.org/D73070
2020-01-21 06:57:11 +08:00
|
|
|
;; Without -function-sections, f2 is in the same text section as f1.
|
|
|
|
;; They share the __patchable_function_entries section.
|
|
|
|
;; With -function-sections, f1 and f2 are in different text sections.
|
|
|
|
;; Use separate __patchable_function_entries.
|
2020-01-21 07:52:38 +08:00
|
|
|
define void @f2() "patchable-function-entry"="2" {
|
|
|
|
; CHECK-LABEL: f2:
|
|
|
|
; CHECK-NEXT: .Lfunc_begin2:
|
|
|
|
; CHECK-COUNT-2: nop
|
|
|
|
; CHECK-NEXT: ret
|
2020-02-15 12:35:04 +08:00
|
|
|
; CHECK: .section __patchable_function_entries,"awo",@progbits,f2{{$}}
|
2020-01-21 07:52:38 +08:00
|
|
|
; CHECK-NEXT: .p2align 3
|
|
|
|
; CHECK-NEXT: .xword .Lfunc_begin2
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:35:47 +08:00
|
|
|
$f3 = comdat any
|
|
|
|
define void @f3() "patchable-function-entry"="3" comdat {
|
|
|
|
; CHECK-LABEL: f3:
|
2020-01-21 07:52:38 +08:00
|
|
|
; CHECK-NEXT: .Lfunc_begin3:
|
2020-01-03 16:35:47 +08:00
|
|
|
; CHECK-COUNT-3: nop
|
|
|
|
; CHECK-NEXT: ret
|
2020-02-15 12:35:04 +08:00
|
|
|
; CHECK: .section __patchable_function_entries,"aGwo",@progbits,f3,comdat,f3{{$}}
|
2020-01-03 16:35:47 +08:00
|
|
|
; CHECK-NEXT: .p2align 3
|
2020-01-21 07:52:38 +08:00
|
|
|
; CHECK-NEXT: .xword .Lfunc_begin3
|
2020-01-03 16:35:47 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
$f5 = comdat any
|
|
|
|
define void @f5() "patchable-function-entry"="5" comdat {
|
|
|
|
; CHECK-LABEL: f5:
|
2020-01-21 07:52:38 +08:00
|
|
|
; CHECK-NEXT: .Lfunc_begin4:
|
2020-01-03 16:35:47 +08:00
|
|
|
; CHECK-COUNT-5: nop
|
|
|
|
; CHECK-NEXT: sub sp, sp, #16
|
2020-02-15 12:35:04 +08:00
|
|
|
; CHECK: .section __patchable_function_entries,"aGwo",@progbits,f5,comdat,f5{{$}}
|
2020-01-03 16:35:47 +08:00
|
|
|
; CHECK: .p2align 3
|
2020-01-21 07:52:38 +08:00
|
|
|
; CHECK-NEXT: .xword .Lfunc_begin4
|
2020-01-03 16:35:47 +08:00
|
|
|
%frame = alloca i8, i32 16
|
|
|
|
ret void
|
|
|
|
}
|
Add function attribute "patchable-function-prefix" to support -fpatchable-function-entry=N,M where M>0
Similar to the function attribute `prefix` (prefix data),
"patchable-function-prefix" inserts data (M NOPs) before the function
entry label.
-fpatchable-function-entry=2,1 (1 NOP before entry, 1 NOP after entry)
will look like:
```
.type foo,@function
.Ltmp0: # @foo
nop
foo:
.Lfunc_begin0:
# optional `bti c` (AArch64 Branch Target Identification) or
# `endbr64` (Intel Indirect Branch Tracking)
nop
.section __patchable_function_entries,"awo",@progbits,get,unique,0
.p2align 3
.quad .Ltmp0
```
-fpatchable-function-entry=N,0 + -mbranch-protection=bti/-fcf-protection=branch has two reasonable
placements (https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01185.html):
```
(a) (b)
func: func:
.Ltmp0: bti c
bti c .Ltmp0:
nop nop
```
(a) needs no additional code. If the consensus is to go for (b), we will
need more code in AArch64BranchTargets.cpp / X86IndirectBranchTracking.cpp .
Differential Revision: https://reviews.llvm.org/D73070
2020-01-21 06:57:11 +08:00
|
|
|
|
|
|
|
;; -fpatchable-function-entry=3,2
|
|
|
|
;; "patchable-function-prefix" emits data before the function entry label.
|
|
|
|
define void @f3_2() "patchable-function-entry"="1" "patchable-function-prefix"="2" {
|
|
|
|
; CHECK-LABEL: .type f3_2,@function
|
|
|
|
; CHECK-NEXT: .Ltmp1: // @f3_2
|
|
|
|
; CHECK-NEXT: nop
|
|
|
|
; CHECK-NEXT: nop
|
|
|
|
; CHECK-NEXT: f3_2:
|
|
|
|
; CHECK: // %bb.0:
|
|
|
|
; CHECK-NEXT: nop
|
|
|
|
; CHECK-NEXT: ret
|
|
|
|
;; .size does not include the prefix.
|
|
|
|
; CHECK: .Lfunc_end5:
|
|
|
|
; CHECK-NEXT: .size f3_2, .Lfunc_end5-f3_2
|
2020-02-15 12:35:04 +08:00
|
|
|
; CHECK: .section __patchable_function_entries,"awo",@progbits,f3_2{{$}}
|
Add function attribute "patchable-function-prefix" to support -fpatchable-function-entry=N,M where M>0
Similar to the function attribute `prefix` (prefix data),
"patchable-function-prefix" inserts data (M NOPs) before the function
entry label.
-fpatchable-function-entry=2,1 (1 NOP before entry, 1 NOP after entry)
will look like:
```
.type foo,@function
.Ltmp0: # @foo
nop
foo:
.Lfunc_begin0:
# optional `bti c` (AArch64 Branch Target Identification) or
# `endbr64` (Intel Indirect Branch Tracking)
nop
.section __patchable_function_entries,"awo",@progbits,get,unique,0
.p2align 3
.quad .Ltmp0
```
-fpatchable-function-entry=N,0 + -mbranch-protection=bti/-fcf-protection=branch has two reasonable
placements (https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01185.html):
```
(a) (b)
func: func:
.Ltmp0: bti c
bti c .Ltmp0:
nop nop
```
(a) needs no additional code. If the consensus is to go for (b), we will
need more code in AArch64BranchTargets.cpp / X86IndirectBranchTracking.cpp .
Differential Revision: https://reviews.llvm.org/D73070
2020-01-21 06:57:11 +08:00
|
|
|
; CHECK: .p2align 3
|
|
|
|
; CHECK-NEXT: .xword .Ltmp1
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
;; When prefix data is used, arbitrarily place NOPs after prefix data.
|
|
|
|
define void @prefix() "patchable-function-entry"="0" "patchable-function-prefix"="1" prefix i32 1 {
|
|
|
|
; CHECK-LABEL: .type prefix,@function
|
|
|
|
; CHECK-NEXT: .word 1 // @prefix
|
|
|
|
; CHECK: .Ltmp2:
|
|
|
|
; CHECK: nop
|
|
|
|
; CHECK-NEXT: prefix:
|
|
|
|
;; Emit a __patchable_function_entries entry even if "patchable-function-entry" is 0.
|
2020-02-15 12:35:04 +08:00
|
|
|
; CHECK: .section __patchable_function_entries,"awo",@progbits,prefix{{$}}
|
Add function attribute "patchable-function-prefix" to support -fpatchable-function-entry=N,M where M>0
Similar to the function attribute `prefix` (prefix data),
"patchable-function-prefix" inserts data (M NOPs) before the function
entry label.
-fpatchable-function-entry=2,1 (1 NOP before entry, 1 NOP after entry)
will look like:
```
.type foo,@function
.Ltmp0: # @foo
nop
foo:
.Lfunc_begin0:
# optional `bti c` (AArch64 Branch Target Identification) or
# `endbr64` (Intel Indirect Branch Tracking)
nop
.section __patchable_function_entries,"awo",@progbits,get,unique,0
.p2align 3
.quad .Ltmp0
```
-fpatchable-function-entry=N,0 + -mbranch-protection=bti/-fcf-protection=branch has two reasonable
placements (https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01185.html):
```
(a) (b)
func: func:
.Ltmp0: bti c
bti c .Ltmp0:
nop nop
```
(a) needs no additional code. If the consensus is to go for (b), we will
need more code in AArch64BranchTargets.cpp / X86IndirectBranchTracking.cpp .
Differential Revision: https://reviews.llvm.org/D73070
2020-01-21 06:57:11 +08:00
|
|
|
; CHECK: .p2align 3
|
|
|
|
; CHECK-NEXT: .xword .Ltmp2
|
|
|
|
ret void
|
|
|
|
}
|