summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/XRayArgs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Driver/XRayArgs.cpp')
-rw-r--r--clang/lib/Driver/XRayArgs.cpp35
1 files changed, 32 insertions, 3 deletions
diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index bfc5053dcdc..e25259ca6d6 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -58,8 +58,7 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
}
} else {
D.Diag(diag::err_drv_clang_unsupported)
- << (std::string(XRayInstrumentOption) +
- " on non-supported target OS");
+ << (std::string(XRayInstrumentOption) + " on " + Triple.str());
}
XRayInstrument = true;
if (const Arg *A =
@@ -82,6 +81,36 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
options::OPT_fnoxray_link_deps, true))
XRayRT = false;
+ auto Bundles =
+ Args.getAllArgValues(options::OPT_fxray_instrumentation_bundle);
+ if (Bundles.empty())
+ InstrumentationBundle.Mask = XRayInstrKind::All;
+ else
+ for (const auto &B : Bundles) {
+ llvm::SmallVector<StringRef, 2> BundleParts;
+ llvm::SplitString(B, BundleParts, ",");
+ for (const auto &P : BundleParts) {
+ // TODO: Automate the generation of the string case table.
+ auto Valid = llvm::StringSwitch<bool>(P)
+ .Cases("none", "all", "function", "custom", true)
+ .Default(false);
+
+ if (!Valid) {
+ D.Diag(clang::diag::err_drv_invalid_value)
+ << "-fxray-instrumentation-bundle=" << P;
+ continue;
+ }
+
+ auto Mask = parseXRayInstrValue(P);
+ if (Mask == XRayInstrKind::None) {
+ InstrumentationBundle.clear();
+ break;
+ }
+
+ InstrumentationBundle.Mask |= Mask;
+ }
+ }
+
// Validate the always/never attribute files. We also make sure that they
// are treated as actual dependencies.
for (const auto &Filename :
@@ -165,7 +194,7 @@ void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args,
CmdArgs.push_back(Args.MakeArgString(NeverInstrumentOpt));
}
- for (const auto& AttrFile : AttrListFiles) {
+ for (const auto &AttrFile : AttrListFiles) {
SmallString<64> AttrListFileOpt("-fxray-attr-list=");
AttrListFileOpt += AttrFile;
CmdArgs.push_back(Args.MakeArgString(AttrListFileOpt));
OpenPOWER on IntegriCloud