Index: clang/include/clang/Basic/XRayInstr.h =================================================================== --- clang/include/clang/Basic/XRayInstr.h +++ clang/include/clang/Basic/XRayInstr.h @@ -60,6 +60,8 @@ bool empty() const { return Mask == 0; } + bool full() const { return Mask == XRayInstrKind::All; } + XRayInstrMask Mask = 0; }; Index: clang/lib/Driver/XRayArgs.cpp =================================================================== --- clang/lib/Driver/XRayArgs.cpp +++ clang/lib/Driver/XRayArgs.cpp @@ -215,4 +215,19 @@ 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)); } Index: clang/test/CodeGen/xray-instrumentation-bundles-flags.cpp =================================================================== --- /dev/null +++ clang/test/CodeGen/xray-instrumentation-bundles-flags.cpp @@ -0,0 +1,8 @@ +// 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