]> granicus.if.org Git - clang/commitdiff
[XRay] Check in Clang whether XRay supports the target when -fxray-instrument is...
authorDean Michael Berris <dberris@google.com>
Thu, 27 Oct 2016 04:56:14 +0000 (04:56 +0000)
committerDean Michael Berris <dberris@google.com>
Thu, 27 Oct 2016 04:56:14 +0000 (04:56 +0000)
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

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

lib/Driver/Tools.cpp
test/Driver/XRay/lit.local.cfg [new file with mode: 0644]
test/Driver/XRay/xray-instrument-cpu.c [new file with mode: 0644]
test/Driver/XRay/xray-instrument-os.c [new file with mode: 0644]

index 74e3681425c72e0b8d0a61706ff7a20c7e54d120..36b4c950ae4e6bdf1f049a5c4258a7d9581d6c46 100644 (file)
@@ -4810,7 +4810,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   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)) {
diff --git a/test/Driver/XRay/lit.local.cfg b/test/Driver/XRay/lit.local.cfg
new file mode 100644 (file)
index 0000000..34040d2
--- /dev/null
@@ -0,0 +1,2 @@
+target_triple_components = config.target_triple.split('-')
+config.available_features.update(target_triple_components)
diff --git a/test/Driver/XRay/xray-instrument-cpu.c b/test/Driver/XRay/xray-instrument-cpu.c
new file mode 100644 (file)
index 0000000..377459a
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: not %clang -v -fxray-instrument -c %s
+// XFAIL: amd64-, x86_64-, x86_64h-, arm
+// REQUIRES: linux
+typedef int a;
diff --git a/test/Driver/XRay/xray-instrument-os.c b/test/Driver/XRay/xray-instrument-os.c
new file mode 100644 (file)
index 0000000..0802d28
--- /dev/null
@@ -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;