]> granicus.if.org Git - clang/commitdiff
[XRay][clang] Propagate -fxray-instrumentation-bundle to -cc1
authorDean Michael Berris <dberris@google.com>
Fri, 21 Sep 2018 08:32:49 +0000 (08:32 +0000)
committerDean Michael Berris <dberris@google.com>
Fri, 21 Sep 2018 08:32:49 +0000 (08:32 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342715 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/XRayInstr.h
lib/Driver/XRayArgs.cpp
test/Driver/XRay/xray-instrumentation-bundles-flags.cpp [new file with mode: 0644]

index 13c3032a5ccabd28babd5c51a4e89b7ced14f7cb..6efefcb33ac877f0cb7e4ac4e66daa5e673e83bc 100644 (file)
@@ -60,6 +60,8 @@ struct XRayInstrSet {
 
   bool empty() const { return Mask == 0; }
 
+  bool full() const { return Mask == XRayInstrKind::All; }
+
   XRayInstrMask Mask = 0;
 };
 
index 527fc3c95584adc9dc57b0ecd0c38518bbcf3c8e..a20232897539680807088240e7d4825b46c0f495 100644 (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));
 }
diff --git a/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp b/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp
new file mode 100644 (file)
index 0000000..da25355
--- /dev/null
@@ -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