r299126 - [XRay][clang] Fix the -fxray-instruction-threshold flag processing

Dean Michael Berris via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 30 15:46:45 PDT 2017


Author: dberris
Date: Thu Mar 30 17:46:45 2017
New Revision: 299126

URL: http://llvm.org/viewvc/llvm-project?rev=299126&view=rev
Log:
[XRay][clang] Fix the -fxray-instruction-threshold flag processing

Summary:
The refactoring introduced a regression in the flag processing for
-fxray-instruction-threshold which causes it to not get passed properly.
This change should restore the previous behaviour.

Reviewers: rnk, pelikan

Subscribers: cfe-commits

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

Added:
    cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
Modified:
    cfe/trunk/lib/Driver/XRayArgs.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Driver/XRayArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/XRayArgs.cpp?rev=299126&r1=299125&r2=299126&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/XRayArgs.cpp (original)
+++ cfe/trunk/lib/Driver/XRayArgs.cpp Thu Mar 30 17:46:45 2017
@@ -16,8 +16,8 @@
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
-#include "llvm/Support/SpecialCaseList.h"
 #include "llvm/Support/ScopedPrinter.h"
+#include "llvm/Support/SpecialCaseList.h"
 
 using namespace clang;
 using namespace clang::driver;
@@ -91,8 +91,8 @@ void XRayArgs::addArgs(const ToolChain &
     return;
 
   CmdArgs.push_back(XRayInstrumentOption);
-  CmdArgs.push_back(Args.MakeArgString(XRayInstructionThresholdOption +
-                                       llvm::to_string(InstructionThreshold)));
+  CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
+                                       Twine(InstructionThreshold)));
 
   for (const auto &Always : AlwaysInstrumentFiles) {
     SmallString<64> AlwaysInstrumentOpt(XRayAlwaysInstrumentOption);

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=299126&r1=299125&r2=299126&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Mar 30 17:46:45 2017
@@ -721,7 +721,7 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
-      getLastArgIntValue(Args, OPT_fxray_instruction_threshold_, 200, Diags);
+      getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
   Opts.InstrumentForProfiling = Args.hasArg(OPT_pg);
   Opts.CallFEntry = Args.hasArg(OPT_mfentry);
   Opts.EmitOpenCLArgMetadata = Args.hasArg(OPT_cl_kernel_arg_info);
@@ -2308,9 +2308,11 @@ static void ParseLangArgs(LangOptions &O
       getLastArgIntValue(Args, OPT_fsanitize_address_field_padding, 0, Diags);
   Opts.SanitizerBlacklistFiles = Args.getAllArgValues(OPT_fsanitize_blacklist);
 
-  // -fxray-{always,never}-instrument= filenames.
+  // -fxray-instrument
   Opts.XRayInstrument =
       Args.hasFlag(OPT_fxray_instrument, OPT_fnoxray_instrument, false);
+
+  // -fxray-{always,never}-instrument= filenames.
   Opts.XRayAlwaysInstrumentFiles =
       Args.getAllArgValues(OPT_fxray_always_instrument);
   Opts.XRayNeverInstrumentFiles =

Added: cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp?rev=299126&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp (added)
+++ cfe/trunk/test/CodeGen/xray-instruction-threshold.cpp Thu Mar 30 17:46:45 2017
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-instruction-threshold=1 -x c++ -std=c++11 -emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+[[clang::xray_never_instrument]] int bar() {
+  return 2;
+}
+
+// CHECK-DAG: define i32 @_Z3foov() #[[THRESHOLD:[0-9]+]] {
+// CHECK-DAG: define i32 @_Z3barv() #[[NEVERATTR:[0-9]+]] {
+// CHECK-DAG: attributes #[[THRESHOLD]] = {{.*}} "xray-instruction-threshold"="1" {{.*}}
+// CHECK-DAG: attributes #[[NEVERATTR]] = {{.*}} "function-instrument"="xray-never" {{.*}}




More information about the cfe-commits mailing list