2020-01-03 16:35:47 +08:00
|
|
|
; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
|
|
|
|
|
|
|
|
; CHECK: "patchable-function-entry" takes an unsigned integer:
|
|
|
|
; CHECK: "patchable-function-entry" takes an unsigned integer: a
|
|
|
|
; CHECK: "patchable-function-entry" takes an unsigned integer: -1
|
|
|
|
; CHECK: "patchable-function-entry" takes an unsigned integer: 3,
|
|
|
|
|
|
|
|
define void @f() "patchable-function-entry" { ret void }
|
|
|
|
define void @fa() "patchable-function-entry"="a" { ret void }
|
|
|
|
define void @f_1() "patchable-function-entry"="-1" { ret void }
|
|
|
|
define void @f3comma() "patchable-function-entry"="3," { 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
|
|
|
|
|
|
|
; CHECK: "patchable-function-prefix" takes an unsigned integer:
|
|
|
|
; CHECK: "patchable-function-prefix" takes an unsigned integer: a
|
|
|
|
; CHECK: "patchable-function-prefix" takes an unsigned integer: -1
|
|
|
|
; CHECK: "patchable-function-prefix" takes an unsigned integer: 3,
|
|
|
|
|
|
|
|
define void @g() "patchable-function-prefix" { ret void }
|
|
|
|
define void @ga() "patchable-function-prefix"="a" { ret void }
|
|
|
|
define void @g_1() "patchable-function-prefix"="-1" { ret void }
|
|
|
|
define void @g3comma() "patchable-function-prefix"="3," { ret void }
|