r285266 - [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

Dean Michael Berris via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 26 21:56:15 PDT 2016


Author: dberris
Date: Wed Oct 26 23:56:14 2016
New Revision: 285266

URL: http://llvm.org/viewvc/llvm-project?rev=285266&view=rev
Log:
[XRay] Check in Clang whether XRay supports the target when -fxray-instrument is passed

Summary:
Added the code which explicitly emits an error in Clang in case
`-fxray-instrument` is passed, but XRay is not supported for the
selected target.

Reviewers: rsmith, aaron.ballman, rnk, dberris

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

Added:
    cfe/trunk/test/Driver/XRay/
    cfe/trunk/test/Driver/XRay/lit.local.cfg
    cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
    cfe/trunk/test/Driver/XRay/xray-instrument-os.c
Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=285266&r1=285265&r2=285266&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Oct 26 23:56:14 2016
@@ -4810,7 +4810,16 @@ void Clang::ConstructJob(Compilation &C,
 
   if (Args.hasFlag(options::OPT_fxray_instrument,
                    options::OPT_fnoxray_instrument, false)) {
-    CmdArgs.push_back("-fxray-instrument");
+    const char *const XRayInstrumentOption = "-fxray-instrument";
+    if (Triple.getOS() == llvm::Triple::Linux &&
+        (Triple.getArch() == llvm::Triple::arm ||
+         Triple.getArch() == llvm::Triple::x86_64)) {
+      // Supported.
+    } else {
+      D.Diag(diag::err_drv_clang_unsupported)
+          << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+    }
+    CmdArgs.push_back(XRayInstrumentOption);
     if (const Arg *A =
             Args.getLastArg(options::OPT_fxray_instruction_threshold_,
                             options::OPT_fxray_instruction_threshold_EQ)) {

Added: cfe/trunk/test/Driver/XRay/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/lit.local.cfg?rev=285266&view=auto
==============================================================================
--- cfe/trunk/test/Driver/XRay/lit.local.cfg (added)
+++ cfe/trunk/test/Driver/XRay/lit.local.cfg Wed Oct 26 23:56:14 2016
@@ -0,0 +1,2 @@
+target_triple_components = config.target_triple.split('-')
+config.available_features.update(target_triple_components)

Added: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c?rev=285266&view=auto
==============================================================================
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c (added)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c Wed Oct 26 23:56:14 2016
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// REQUIRES: linux
+typedef int a;

Added: cfe/trunk/test/Driver/XRay/xray-instrument-os.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-os.c?rev=285266&view=auto
==============================================================================
--- cfe/trunk/test/Driver/XRay/xray-instrument-os.c (added)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-os.c Wed Oct 26 23:56:14 2016
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: -linux-
+// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
+typedef int a;




More information about the cfe-commits mailing list