Skip to content

Commit

Permalink
[XRay][compiler-rt] Do not print the warning when the binary is not X…
Browse files Browse the repository at this point in the history
…Ray instrumented.

Summary:
Currently when the XRay runtime is linked into a binary that doesn't
have the instrumentation map, we print a warning unconditionally. This
change attempts to make this behaviour more quiet.

Reviewers: kpw, pelikan

Subscribers: llvm-commits

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

llvm-svn: 309534
  • Loading branch information
deanberris committed Jul 31, 2017
1 parent 7639db8 commit 5ca1955
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler-rt/lib/xray/xray_init.cc
Expand Up @@ -49,7 +49,8 @@ XRaySledMap XRayInstrMap;
void __xray_init() XRAY_NEVER_INSTRUMENT {
initializeFlags();
if (__start_xray_instr_map == nullptr) {
Report("XRay instrumentation map missing. Not initializing XRay.\n");
if (Verbosity())
Report("XRay instrumentation map missing. Not initializing XRay.\n");
return;
}

Expand Down
22 changes: 22 additions & 0 deletions compiler-rt/test/xray/TestCases/Linux/quiet-start.cc
@@ -0,0 +1,22 @@
// Ensure that we have a quiet startup when we don't have the XRay
// instrumentation sleds.
//
// RUN: %clangxx -std=c++11 %s -o %t %xraylib
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=1" %run %t 2>&1 | \
// RUN: FileCheck %s --check-prefix NOISY
// RUN: XRAY_OPTIONS="patch_premain=true verbosity=0" %run %t 2>&1 | \
// RUN: FileCheck %s --check-prefix QUIET
// RUN: XRAY_OPTIONS="" %run %t 2>&1 | FileCheck %s --check-prefix DEFAULT
#include <iostream>

using namespace std;

int main(int, char**) {
// NOISY: {{.*}}XRay instrumentation map missing. Not initializing XRay.
// QUIET-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay.
// DEFAULT-NOT: {{.*}}XRay instrumentation map missing. Not initializing XRay.
cout << "Hello, XRay!" << endl;
// NOISY-NEXT: Hello, XRay!
// QUIET: Hello, XRay!
// DEFAULT: Hello, XRay!
}
5 changes: 5 additions & 0 deletions compiler-rt/test/xray/lit.cfg
Expand Up @@ -31,6 +31,11 @@ config.substitutions.append(
('%clangxx_xray', build_invocation(clang_xray_cxxflags)))
config.substitutions.append(
('%llvm_xray', llvm_xray))
config.substitutions.append(
('%xraylib',
('-lm -lpthread -ldl -lrt -L%s '
'-Wl,-whole-archive -lclang_rt.xray-%s -Wl,-no-whole-archive')
% (config.compiler_rt_libdir, config.host_arch)))

# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
Expand Down

0 comments on commit 5ca1955

Please sign in to comment.