[compiler-rt] r309534 - [XRay][compiler-rt] Do not print the warning when the binary is not XRay instrumented.

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 30 22:16:20 PDT 2017


Author: dberris
Date: Sun Jul 30 22:16:20 2017
New Revision: 309534

URL: http://llvm.org/viewvc/llvm-project?rev=309534&view=rev
Log:
[XRay][compiler-rt] Do not print the warning when the binary is not XRay 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

Added:
    compiler-rt/trunk/test/xray/TestCases/Linux/quiet-start.cc
Modified:
    compiler-rt/trunk/lib/xray/xray_init.cc
    compiler-rt/trunk/test/xray/lit.cfg

Modified: compiler-rt/trunk/lib/xray/xray_init.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_init.cc?rev=309534&r1=309533&r2=309534&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_init.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_init.cc Sun Jul 30 22:16:20 2017
@@ -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;
   }
 

Added: compiler-rt/trunk/test/xray/TestCases/Linux/quiet-start.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/quiet-start.cc?rev=309534&view=auto
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Linux/quiet-start.cc (added)
+++ compiler-rt/trunk/test/xray/TestCases/Linux/quiet-start.cc Sun Jul 30 22:16:20 2017
@@ -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!
+}

Modified: compiler-rt/trunk/test/xray/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/lit.cfg?rev=309534&r1=309533&r2=309534&view=diff
==============================================================================
--- compiler-rt/trunk/test/xray/lit.cfg (original)
+++ compiler-rt/trunk/test/xray/lit.cfg Sun Jul 30 22:16:20 2017
@@ -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']




More information about the llvm-commits mailing list