summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-01-20 14:57:11 -0800
committerFangrui Song <maskray@google.com>2020-01-24 10:38:40 -0800
commitbf04730dee1b74c8e7661c671484eff93c1f5a77 (patch)
tree2a780731504023d8075ca85e50e5f582ffd930c6 /llvm/include
parent0e2eea29cc4f360fc95638fbfc8aca24cec3fc5f (diff)
downloadbcm5719-llvm-bf04730dee1b74c8e7661c671484eff93c1f5a77.tar.gz
bcm5719-llvm-bf04730dee1b74c8e7661c671484eff93c1f5a77.zip
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 (cherry picked from commit 22467e259507f5ead2a87d989251b4c951a587e4)
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/CodeGen/AsmPrinter.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/AsmPrinter.h b/llvm/include/llvm/CodeGen/AsmPrinter.h
index b374fd3d80a..a860ce2773e 100644
--- a/llvm/include/llvm/CodeGen/AsmPrinter.h
+++ b/llvm/include/llvm/CodeGen/AsmPrinter.h
@@ -113,6 +113,9 @@ public:
ProfileSummaryInfo *PSI;
+ /// The symbol for the entry in __patchable_function_entires.
+ MCSymbol *CurrentPatchableFunctionEntrySym = nullptr;
+
/// The symbol for the current function. This is recalculated at the beginning
/// of each call to runOnMachineFunction().
MCSymbol *CurrentFnSym = nullptr;
@@ -449,6 +452,9 @@ public:
/// instructions in verbose mode.
virtual void emitImplicitDef(const MachineInstr *MI) const;
+ /// Emit N NOP instructions.
+ void emitNops(unsigned N);
+
//===------------------------------------------------------------------===//
// Symbol Lowering Routines.
//===------------------------------------------------------------------===//
OpenPOWER on IntegriCloud