diff options
author | Ian Levesque <ianlevesque@fb.com> | 2020-01-17 13:24:27 -0800 |
---|---|---|
committer | Shoaib Meenai <smeenai@fb.com> | 2020-01-17 13:32:34 -0800 |
commit | 97ba483026cdcb31bbf6f85ea09d5638a55c651e (patch) | |
tree | b516d253764ec6d323da1282ca6add54a430c6e9 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 1d62be244108547558c6d42ddcf2e4a7f3c6dd03 (diff) | |
download | llvm-97ba483026cdcb31bbf6f85ea09d5638a55c651e.zip llvm-97ba483026cdcb31bbf6f85ea09d5638a55c651e.tar.gz llvm-97ba483026cdcb31bbf6f85ea09d5638a55c651e.tar.bz2 |
[xray] Allow instrumenting only function entry and/or only function exit
Extend -fxray-instrumentation-bundle to split function-entry and
function-exit into two separate options, so that it is possible to
instrument only function entry or only function exit. For use cases
that only care about one or the other this will save significant overhead
and code size.
Differential Revision: https://reviews.llvm.org/D72890
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 75f5c0e..b4a4983 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -803,7 +803,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, // 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)) { + XRayInstrKind::FunctionEntry) || + CGM.getCodeGenOpts().XRayInstrumentationBundle.has( + XRayInstrKind::FunctionExit)) { if (XRayAttr->alwaysXRayInstrument() && ShouldXRayInstrumentFunction()) Fn->addFnAttr("function-instrument", "xray-always"); if (XRayAttr->neverXRayInstrument()) @@ -812,6 +814,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (ShouldXRayInstrumentFunction()) Fn->addFnAttr("xray-log-args", llvm::utostr(LogArgs->getArgumentCount())); + if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has( + XRayInstrKind::FunctionExit)) { + Fn->addFnAttr("xray-skip-exit"); + } + if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has( + XRayInstrKind::FunctionEntry)) { + Fn->addFnAttr("xray-skip-entry"); + } } } else { if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc)) |