[compiler-rt] r312824 - Prevent DCE on __lsan_is_turned_off and re-enable test case

Francis Ricci via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 12:43:53 PDT 2017


Author: fjricci
Date: Fri Sep  8 12:43:53 2017
New Revision: 312824

URL: http://llvm.org/viewvc/llvm-project?rev=312824&view=rev
Log:
Prevent DCE on __lsan_is_turned_off and re-enable test case

Summary:
-dead_strip in ld64 strips weak interface symbols, which I believe
is most likely the cause of this test failure. Re-enable after marking the interface
function as used.

Reviewers: alekseyshl, kubamracek, kcc

Subscribers: llvm-commits

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

Modified:
    compiler-rt/trunk/include/sanitizer/lsan_interface.h
    compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc

Modified: compiler-rt/trunk/include/sanitizer/lsan_interface.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/include/sanitizer/lsan_interface.h?rev=312824&r1=312823&r2=312824&view=diff
==============================================================================
--- compiler-rt/trunk/include/sanitizer/lsan_interface.h (original)
+++ compiler-rt/trunk/include/sanitizer/lsan_interface.h Fri Sep  8 12:43:53 2017
@@ -64,6 +64,8 @@ extern "C" {
   // for the program it is linked into (if the return value is non-zero). This
   // function must be defined as returning a constant value; any behavior beyond
   // that is unsupported.
+  // To avoid dead stripping, you may need to define this function with
+  // __attribute__((used))
   int __lsan_is_turned_off();
 
   // This function may be optionally provided by the user and should return

Modified: compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc?rev=312824&r1=312823&r2=312824&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc (original)
+++ compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc Fri Sep  8 12:43:53 2017
@@ -3,15 +3,13 @@
 // RUN: %clangxx_lsan %s -o %t
 // RUN: %env_lsan_opts=$LSAN_BASE %run %t
 // RUN: %env_lsan_opts=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s
-//
-// UNSUPPORTED: darwin
 
 #include <sanitizer/lsan_interface.h>
 
 int argc_copy;
 
 extern "C" {
-int __lsan_is_turned_off() {
+int __attribute__((used)) __lsan_is_turned_off() {
   return (argc_copy == 1);
 }
 }




More information about the llvm-commits mailing list