From: Dean Michael Berris Date: Thu, 27 Oct 2016 04:56:14 +0000 (+0000) Subject: [XRay] Check in Clang whether XRay supports the target when -fxray-instrument is... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=424463b984d5023c55377af7d5a350e66f7a88cf;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285266 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 74e3681425..36b4c950ae 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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 index 0000000000..34040d2261 --- /dev/null +++ b/test/Driver/XRay/lit.local.cfg @@ -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 index 0000000000..377459aab9 --- /dev/null +++ b/test/Driver/XRay/xray-instrument-cpu.c @@ -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 index 0000000000..0802d28d30 --- /dev/null +++ b/test/Driver/XRay/xray-instrument-os.c @@ -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;