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

Dean Michael Berris via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 21 01:32:49 PDT 2018


Author: dberris
Date: Fri Sep 21 01:32:49 2018
New Revision: 342715

URL: http://llvm.org/viewvc/llvm-project?rev=342715&view=rev
Log:
[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

Added:
    cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp
Modified:
    cfe/trunk/include/clang/Basic/XRayInstr.h
    cfe/trunk/lib/Driver/XRayArgs.cpp

Modified: cfe/trunk/include/clang/Basic/XRayInstr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/XRayInstr.h?rev=342715&r1=342714&r2=342715&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/XRayInstr.h (original)
+++ cfe/trunk/include/clang/Basic/XRayInstr.h Fri Sep 21 01:32:49 2018
@@ -60,6 +60,8 @@ struct XRayInstrSet {
 
   bool empty() const { return Mask == 0; }
 
+  bool full() const { return Mask == XRayInstrKind::All; }
+
   XRayInstrMask Mask = 0;
 };
 

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=342715&r1=342714&r2=342715&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Fri Sep 21 01:32:49 2018
@@ -215,4 +215,19 @@ void XRayArgs::addArgs(const ToolChain &
     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));
 }

Added: cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp?rev=342715&view=auto
==============================================================================
--- cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp (added)
+++ cfe/trunk/test/Driver/XRay/xray-instrumentation-bundles-flags.cpp Fri Sep 21 01:32:49 2018
@@ -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




More information about the cfe-commits mailing list