[PATCH] D73842: [xray][clang] Always add xray-skip-entry/exit and xray-ignore-loops attrs
Ian Levesque via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 1 14:59:05 PST 2020
ianlevesque created this revision.
ianlevesque added reviewers: hiraditya, smeenai, dberris.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
The function attributes xray-skip-entry, xray-skip-exit, and
xray-ignore-loops were only being applied if a function had an
xray-instrument attribute, but they should apply if xray is enabled
globally too.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73842
Files:
clang/include/clang/Driver/XRayArgs.h
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Driver/XRayArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
Index: clang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1100,7 +1100,7 @@
Opts.XRayInstructionThreshold =
getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
Opts.XRayIgnoreLoops =
- Args.hasArg(OPT_fxray_ignore_loops, OPT_fno_xray_ignore_loops, false);
+ Args.hasFlag(OPT_fxray_ignore_loops, OPT_fno_xray_ignore_loops, false);
auto XRayInstrBundles =
Args.getAllArgValues(OPT_fxray_instrumentation_bundle);
Index: clang/lib/Driver/XRayArgs.cpp
===================================================================
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -101,6 +101,10 @@
options::OPT_fnoxray_link_deps, true))
XRayRT = false;
+ if (Args.hasFlag(options::OPT_fxray_ignore_loops,
+ options::OPT_fno_xray_ignore_loops, false))
+ XRayIgnoreLoops = true;
+
auto Bundles =
Args.getAllArgValues(options::OPT_fxray_instrumentation_bundle);
if (Bundles.empty())
@@ -197,6 +201,9 @@
if (XRayAlwaysEmitTypedEvents)
CmdArgs.push_back("-fxray-always-emit-typedevents");
+ if (XRayIgnoreLoops)
+ CmdArgs.push_back("-fxray-ignore-loops");
+
CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
Twine(InstructionThreshold)));
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -814,23 +814,26 @@
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))
Fn->addFnAttr(
"xray-instruction-threshold",
llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+ }
+
+ if (ShouldXRayInstrumentFunction()) {
if (CGM.getCodeGenOpts().XRayIgnoreLoops) {
Fn->addFnAttr("xray-ignore-loops");
}
+ if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+ XRayInstrKind::FunctionExit)) {
+ Fn->addFnAttr("xray-skip-exit");
+ }
+ if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+ XRayInstrKind::FunctionEntry)) {
+ Fn->addFnAttr("xray-skip-entry");
+ }
}
unsigned Count, Offset;
Index: clang/include/clang/Driver/XRayArgs.h
===================================================================
--- clang/include/clang/Driver/XRayArgs.h
+++ clang/include/clang/Driver/XRayArgs.h
@@ -30,6 +30,7 @@
bool XRayAlwaysEmitCustomEvents = false;
bool XRayAlwaysEmitTypedEvents = false;
bool XRayRT = true;
+ bool XRayIgnoreLoops = false;
public:
/// Parses the XRay arguments from an argument list.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73842.241907.patch
Type: text/x-patch
Size: 3410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200201/5a065268/attachment-0001.bin>
More information about the cfe-commits
mailing list