[PATCH] D37635: Prevent DCE on __lsan_is_turned_off and re-enable test case

Francis Ricci via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 8 12:47:05 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL312824: Prevent DCE on __lsan_is_turned_off and re-enable test case (authored by fjricci).

Repository:
  rL LLVM

https://reviews.llvm.org/D37635

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


Index: compiler-rt/trunk/include/sanitizer/lsan_interface.h
===================================================================
--- compiler-rt/trunk/include/sanitizer/lsan_interface.h
+++ compiler-rt/trunk/include/sanitizer/lsan_interface.h
@@ -64,6 +64,8 @@
   // 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
Index: compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc
===================================================================
--- compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc
+++ compiler-rt/trunk/test/lsan/TestCases/link_turned_off.cc
@@ -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);
 }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37635.114419.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170908/e1bc3c15/attachment.bin>


More information about the llvm-commits mailing list