Skip to content

Commit f469cb9

Browse files
committedOct 27, 2016
[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 llvm-svn: 285266
1 parent f852055 commit f469cb9

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed
 

‎clang/lib/Driver/Tools.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -4810,7 +4810,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
48104810

48114811
if (Args.hasFlag(options::OPT_fxray_instrument,
48124812
options::OPT_fnoxray_instrument, false)) {
4813-
CmdArgs.push_back("-fxray-instrument");
4813+
const char *const XRayInstrumentOption = "-fxray-instrument";
4814+
if (Triple.getOS() == llvm::Triple::Linux &&
4815+
(Triple.getArch() == llvm::Triple::arm ||
4816+
Triple.getArch() == llvm::Triple::x86_64)) {
4817+
// Supported.
4818+
} else {
4819+
D.Diag(diag::err_drv_clang_unsupported)
4820+
<< (std::string(XRayInstrumentOption) + " on " + Triple.str());
4821+
}
4822+
CmdArgs.push_back(XRayInstrumentOption);
48144823
if (const Arg *A =
48154824
Args.getLastArg(options::OPT_fxray_instruction_threshold_,
48164825
options::OPT_fxray_instruction_threshold_EQ)) {

‎clang/test/Driver/XRay/lit.local.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
target_triple_components = config.target_triple.split('-')
2+
config.available_features.update(target_triple_components)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not %clang -v -fxray-instrument -c %s
2+
// XFAIL: amd64-, x86_64-, x86_64h-, arm
3+
// REQUIRES: linux
4+
typedef int a;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: not %clang -v -fxray-instrument -c %s
2+
// XFAIL: -linux-
3+
// REQUIRES-ANY: amd64, x86_64, x86_64h, arm
4+
typedef int a;

0 commit comments

Comments
 (0)
Please sign in to comment.