[compiler-rt] r342200 - [XRay][clang] Emit "never-instrument" attribute

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 13 18:59:12 PDT 2018


Author: dberris
Date: Thu Sep 13 18:59:12 2018
New Revision: 342200

URL: http://llvm.org/viewvc/llvm-project?rev=342200&view=rev
Log:
[XRay][clang] Emit "never-instrument" attribute

Summary:
Before this change, we only emit the XRay attributes in LLVM IR when the
-fxray-instrument flag is provided. This may cause issues with thinlto
when the final binary is being built/linked with -fxray-instrument, and
the constitutent LLVM IR gets re-lowered with xray instrumentation.

With this change, we can honour the "never-instrument "attributes
provided in the source code and preserve those in the IR. This way, even
in thinlto builds, we retain the attributes which say whether functions
should never be XRay instrumented.

This change addresses llvm.org/PR38922.

Reviewers: mboerger, eizan

Subscribers: mehdi_amini, dexonsmith, cfe-commits, llvm-commits

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

Added:
    compiler-rt/trunk/test/xray/TestCases/Posix/clang-no-xray-instrument.cc

Added: compiler-rt/trunk/test/xray/TestCases/Posix/clang-no-xray-instrument.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Posix/clang-no-xray-instrument.cc?rev=342200&view=auto
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Posix/clang-no-xray-instrument.cc (added)
+++ compiler-rt/trunk/test/xray/TestCases/Posix/clang-no-xray-instrument.cc Thu Sep 13 18:59:12 2018
@@ -0,0 +1,11 @@
+// Test that we cannot actually find XRay instrumentation when we build with
+// -fno-xray-instrument but have code that's marked as 'xray_always_instrument'.
+//
+// RUN: %clangxx -fno-xray-instrument -c %s -o %t.o
+// RUN: not %llvm_xray extract -symbolize %t.o 2>&1 | FileCheck %s
+// REQUIRES: x86_64-target-arch
+// REQUIRES: built-in-llvm-tree
+
+// CHECK: llvm-xray: Cannot extract instrumentation map
+// CHECK-NOT: {{.*always_instrumented.*}}
+[[clang::xray_always_instrument]] int always_instrumented() { return 42; }




More information about the llvm-commits mailing list