aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-01-04 15:39:19 -0800
committerFangrui Song <maskray@google.com>2020-01-10 09:57:34 -0800
commita44c434b68e515ce9f2627367c83ff6b22328261 (patch)
treed568652ab8ec6c31af18a56b7925f053b0c41ff8 /clang/lib/CodeGen/CodeGenFunction.cpp
parenta8fbdc576990653e92ce1d766659005678fd8514 (diff)
downloadllvm-a44c434b68e515ce9f2627367c83ff6b22328261.zip
llvm-a44c434b68e515ce9f2627367c83ff6b22328261.tar.gz
llvm-a44c434b68e515ce9f2627367c83ff6b22328261.tar.bz2
Support function attribute patchable_function_entry
This feature is generic. Make it applicable for AArch64 and X86 because the backend has only implemented NOP insertion for AArch64 and X86. Reviewed By: nickdesaulniers, aaron.ballman Differential Revision: https://reviews.llvm.org/D72221
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index a717f43e..e59fe06 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -799,8 +799,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
FD->getBody()->getStmtClass() == Stmt::CoroutineBodyStmtClass)
SanOpts.Mask &= ~SanitizerKind::Null;
- // Apply xray attributes to the function (as a string, for now)
if (D) {
+ // Apply xray attributes to the function (as a string, for now)
if (const auto *XRayAttr = D->getAttr<XRayInstrumentAttr>()) {
if (CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
XRayInstrKind::Function)) {
@@ -819,6 +819,12 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
"xray-instruction-threshold",
llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
}
+
+ if (const auto *Attr = D->getAttr<PatchableFunctionEntryAttr>()) {
+ // Attr->getStart is currently ignored.
+ Fn->addFnAttr("patchable-function-entry",
+ std::to_string(Attr->getCount()));
+ }
}
// Add no-jump-tables value.