aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-01-20 14:30:06 -0800
committerFangrui Song <maskray@google.com>2020-01-23 17:02:54 -0800
commit69bf40c45fd7f6dfe11b47de42571d8bff5ef94f (patch)
treea3ffc30b1b9e1dd0c234eebbe055451d0eb9f7f8 /clang/lib/CodeGen/CodeGenFunction.cpp
parent01da05b71aa72c15a518d3407682a3775db63808 (diff)
downloadllvm-69bf40c45fd7f6dfe11b47de42571d8bff5ef94f.zip
llvm-69bf40c45fd7f6dfe11b47de42571d8bff5ef94f.tar.gz
llvm-69bf40c45fd7f6dfe11b47de42571d8bff5ef94f.tar.bz2
[Driver][CodeGen] Support -fpatchable-function-entry=N,M and __attribute__((patchable_function_entry(N,M))) where M>0
Reviewed By: nickdesaulniers Differential Revision: https://reviews.llvm.org/D73072
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index b4a4983..af0adc2 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -833,13 +833,18 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
}
}
+ unsigned Count, Offset;
if (const auto *Attr = D->getAttr<PatchableFunctionEntryAttr>()) {
- // Attr->getStart is currently ignored.
- Fn->addFnAttr("patchable-function-entry",
- std::to_string(Attr->getCount()));
- } else if (unsigned Count = CGM.getCodeGenOpts().PatchableFunctionEntryCount) {
- Fn->addFnAttr("patchable-function-entry",
- std::to_string(Count));
+ Count = Attr->getCount();
+ Offset = Attr->getOffset();
+ } else {
+ Count = CGM.getCodeGenOpts().PatchableFunctionEntryCount;
+ Offset = CGM.getCodeGenOpts().PatchableFunctionEntryOffset;
+ }
+ if (Count && Offset <= Count) {
+ Fn->addFnAttr("patchable-function-entry", std::to_string(Count - Offset));
+ if (Offset)
+ Fn->addFnAttr("patchable-function-prefix", std::to_string(Offset));
}
}