[compiler-rt] r306502 - [XRay][compiler-rt][NFC] Add example always/never instrument files.

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 21:44:37 PDT 2017


Author: dberris
Date: Tue Jun 27 21:44:36 2017
New Revision: 306502

URL: http://llvm.org/viewvc/llvm-project?rev=306502&view=rev
Log:
[XRay][compiler-rt][NFC] Add example always/never instrument files.

Summary:
This change introduces two files that show exaples of the
always/never instrument files that can be provided to clang. We don't
add these as defaults yet in clang, which we can do later on (in a
separate change).

We also add a test that makes sure that these apply in the compiler-rt
project tests, and that changes in clang don't break the expectations in
compiler-rt.

Reviewers: pelikan, kpw

Subscribers: llvm-commits

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

Added:
    compiler-rt/trunk/lib/xray/xray_always_instrument.txt
    compiler-rt/trunk/lib/xray/xray_never_instrument.txt
    compiler-rt/trunk/test/xray/TestCases/always-never-instrument.cc

Added: compiler-rt/trunk/lib/xray/xray_always_instrument.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_always_instrument.txt?rev=306502&view=auto
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_always_instrument.txt (added)
+++ compiler-rt/trunk/lib/xray/xray_always_instrument.txt Tue Jun 27 21:44:36 2017
@@ -0,0 +1,6 @@
+# List of function matchers common to C/C++ applications that make sense to
+# always instrument. You can use this as an argument to
+# -fxray-always-instrument=<path> along with your project-specific lists.
+
+# Always instrument the main function.
+fun:main

Added: compiler-rt/trunk/lib/xray/xray_never_instrument.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_never_instrument.txt?rev=306502&view=auto
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_never_instrument.txt (added)
+++ compiler-rt/trunk/lib/xray/xray_never_instrument.txt Tue Jun 27 21:44:36 2017
@@ -0,0 +1,6 @@
+# List of function matchers common to C/C++ applications that make sense to
+# never instrument. You can use this as an argument to
+# -fxray-never-instrument=<path> along with your project-specific lists.
+
+# Never instrument any function whose symbol starts with __xray.
+fun:__xray*

Added: compiler-rt/trunk/test/xray/TestCases/always-never-instrument.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/always-never-instrument.cc?rev=306502&view=auto
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/always-never-instrument.cc (added)
+++ compiler-rt/trunk/test/xray/TestCases/always-never-instrument.cc Tue Jun 27 21:44:36 2017
@@ -0,0 +1,21 @@
+// Test that the always/never instrument lists apply.
+// RUN: echo "fun:main" > %tmp-always.txt
+// RUN: echo "fun:__xray*" > %tmp-never.txt
+// RUN: %clangxx_xray \
+// RUN:     -fxray-never-instrument=%tmp-never.txt \
+// RUN:     -fxray-always-instrument=%tmp-always.txt \
+// RUN:     %s -o %t
+// RUN: %llvm_xray extract -symbolize %t | \
+// RUN:    FileCheck %s --check-prefix NOINSTR
+// RUN: %llvm_xray extract -symbolize %t | \
+// RUN:    FileCheck %s --check-prefix ALWAYSINSTR
+
+// NOINSTR-NOT: {{.*__xray_NeverInstrumented.*}}
+int __xray_NeverInstrumented() {
+  return 0;
+}
+
+// ALWAYSINSTR: {{.*function-name:.*main.*}}
+int main(int argc, char *argv[]) {
+  return __xray_NeverInstrumented();
+}




More information about the llvm-commits mailing list