[XRay][clang] Propagate -fxray-instrumentation-bundle to -cc1

Summary:
Add a test and ensure that we propagate the
-fxray-instrumentation-bundle flag from the driver invocation to the
-cc1 options.

Reviewers: mboerger, tejohnson

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D52342

llvm-svn: 342715
This commit is contained in:
Dean Michael Berris 2018-09-21 08:32:49 +00:00
parent b32274242d
commit 5082e25196
3 changed files with 28 additions and 0 deletions

View File

@ -60,6 +60,8 @@ struct XRayInstrSet {
bool empty() const { return Mask == 0; }
bool full() const { return Mask == XRayInstrKind::All; }
XRayInstrMask Mask = 0;
};

View File

@ -215,4 +215,19 @@ void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args,
ModeOpt += Mode;
CmdArgs.push_back(Args.MakeArgString(ModeOpt));
}
SmallString<64> Bundle("-fxray-instrumentation-bundle=");
if (InstrumentationBundle.full()) {
Bundle += "all";
} else if (InstrumentationBundle.empty()) {
Bundle += "none";
} else {
if (InstrumentationBundle.has(XRayInstrKind::Function))
Bundle += "function";
if (InstrumentationBundle.has(XRayInstrKind::Custom))
Bundle += "custom";
if (InstrumentationBundle.has(XRayInstrKind::Typed))
Bundle += "typed";
}
CmdArgs.push_back(Args.MakeArgString(Bundle));
}

View File

@ -0,0 +1,11 @@
// This test ensures that when we invoke the clang compiler, that the -cc1
// options include the -fxray-instrumentation-bundle= flag we provide in the
// invocation.
//
// RUN: %clang -fxray-instrument -fxray-instrumentation-bundle=function -### \
// RUN: -x c++ -std=c++11 -emit-llvm -c -o - %s 2>&1 \
// RUN: | FileCheck %s
// CHECK: -fxray-instrumentation-bundle=function
//
// REQUIRES-ANY: linux, freebsd
// REQUIRES-ANY: amd64, x86_64, x86_64h, arm, aarch64, arm64