Move lsan allocator cache from lsan_common_linux to lsan_linux
authorFrancis Ricci <francisjricci@gmail.com>
Mon, 27 Mar 2017 19:42:37 +0000 (19:42 +0000)
committerFrancis Ricci <francisjricci@gmail.com>
Mon, 27 Mar 2017 19:42:37 +0000 (19:42 +0000)
Having this function in common seems to trigger a lot of unrelated
test failures. Given that this isn't really common code anyway,
move this to a new linux-specific lsan file.

llvm-svn: 298878

compiler-rt/lib/lsan/CMakeLists.txt
compiler-rt/lib/lsan/lsan_common_linux.cc
compiler-rt/lib/lsan/lsan_linux.cc [new file with mode: 0644]

index a48b85f..4e66100 100644 (file)
@@ -11,6 +11,7 @@ set(LSAN_COMMON_SOURCES
 set(LSAN_SOURCES
   lsan.cc
   lsan_allocator.cc
+  lsan_linux.cc
   lsan_interceptors.cc
   lsan_preinit.cc
   lsan_thread.cc)
index e73768e..0e10d41 100644 (file)
@@ -22,7 +22,6 @@
 #include "sanitizer_common/sanitizer_flags.h"
 #include "sanitizer_common/sanitizer_linux.h"
 #include "sanitizer_common/sanitizer_stackdepot.h"
-#include "lsan_allocator.h"
 
 namespace __lsan {
 
@@ -39,9 +38,6 @@ static THREADLOCAL u32 current_thread_tid = kInvalidTid;
 u32 GetCurrentThread() { return current_thread_tid; }
 void SetCurrentThread(u32 tid) { current_thread_tid = tid; }
 
-static THREADLOCAL AllocatorCache allocator_cache;
-AllocatorCache *GetAllocatorCache() { return &allocator_cache; }
-
 __attribute__((tls_model("initial-exec")))
 THREADLOCAL int disable_counter;
 bool DisabledInThisThread() { return disable_counter > 0; }
diff --git a/compiler-rt/lib/lsan/lsan_linux.cc b/compiler-rt/lib/lsan/lsan_linux.cc
new file mode 100644 (file)
index 0000000..616c06c
--- /dev/null
@@ -0,0 +1,26 @@
+//=-- lsan_linux.cc -------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of LeakSanitizer. Linux-specific code.
+//
+//===----------------------------------------------------------------------===//
+
+#if SANITIZER_LINUX
+
+#include "lsan_allocator.h"
+
+namespace __lsan {
+
+static THREADLOCAL AllocatorCache allocator_cache;
+AllocatorCache *GetAllocatorCache() { return &allocator_cache; }
+
+} // namespace __lsan
+
+#endif // CAN_SANITIZE_LEAKS && SANITIZER_LINUX
+