[clang] 05d46f6 - [NFC][sanitizer] Remove sanitizer_persistent_allocator.cpp

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 8 13:43:43 PDT 2021


Author: Vitaly Buka
Date: 2021-10-08T13:43:28-07:00
New Revision: 05d46f627c49ca9a576150be910a869034ced764

URL: https://github.com/llvm/llvm-project/commit/05d46f627c49ca9a576150be910a869034ced764
DIFF: https://github.com/llvm/llvm-project/commit/05d46f627c49ca9a576150be910a869034ced764.diff

LOG: [NFC][sanitizer] Remove sanitizer_persistent_allocator.cpp

We need to make it a template

Added: 
    

Modified: 
    clang/docs/tools/clang-formatted-files.txt
    compiler-rt/lib/sanitizer_common/CMakeLists.txt
    compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
    compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
    compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
    compiler-rt/lib/tsan/go/build.bat
    compiler-rt/lib/tsan/go/buildgo.sh
    llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn

Removed: 
    compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp


################################################################################
diff  --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt
index 9dd2329f35e8f..79a61042e7214 100644
--- a/clang/docs/tools/clang-formatted-files.txt
+++ b/clang/docs/tools/clang-formatted-files.txt
@@ -1591,7 +1591,6 @@ compiler-rt/lib/sanitizer_common/sanitizer_errno.h
 compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
 compiler-rt/lib/sanitizer_common/sanitizer_local_address_space_view.h
 compiler-rt/lib/sanitizer_common/sanitizer_openbsd.cpp
-compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp
 compiler-rt/lib/sanitizer_common/sanitizer_placement_new.h
 compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h
 compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_openbsd.cpp

diff  --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index 9cfe6d43e1ff6..5630543e7566b 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -18,7 +18,6 @@ set(SANITIZER_SOURCES_NOTERMINATION
   sanitizer_mac.cpp
   sanitizer_mutex.cpp
   sanitizer_netbsd.cpp
-  sanitizer_persistent_allocator.cpp
   sanitizer_platform_limits_freebsd.cpp
   sanitizer_platform_limits_linux.cpp
   sanitizer_platform_limits_netbsd.cpp

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
index 1d40812aeca01..be4190dc735d8 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
@@ -13,6 +13,7 @@
 #define SANITIZER_CHAINED_ORIGIN_DEPOT_H
 
 #include "sanitizer_common.h"
+#include "sanitizer_persistent_allocator.h"
 #include "sanitizer_stackdepotbase.h"
 
 namespace __sanitizer {

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp
deleted file mode 100644
index 3377fcb07939d..0000000000000
--- a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===-- sanitizer_persistent_allocator.cpp ----------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is shared between AddressSanitizer and ThreadSanitizer
-// run-time libraries.
-//===----------------------------------------------------------------------===//
-#include "sanitizer_persistent_allocator.h"
-
-namespace __sanitizer {
-
-void *PersistentAllocator::refillAndAlloc(uptr size) {
-  // If failed, lock, retry and alloc new superblock.
-  SpinMutexLock l(&mtx);
-  for (;;) {
-    void *s = tryAlloc(size);
-    if (s)
-      return s;
-    atomic_store(&region_pos, 0, memory_order_relaxed);
-    uptr allocsz = 64 * 1024;
-    if (allocsz < size)
-      allocsz = size;
-    uptr mem = (uptr)MmapOrDie(allocsz, "stack depot");
-    atomic_fetch_add(&mapped_size, allocsz, memory_order_relaxed);
-    atomic_store(&region_end, mem + allocsz, memory_order_release);
-    atomic_store(&region_pos, mem, memory_order_release);
-  }
-}
-
-}  // namespace __sanitizer

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
index 7d06dbb124163..e943fa5da07f1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
@@ -58,6 +58,24 @@ inline void *PersistentAllocator::alloc(uptr size) {
   return refillAndAlloc(size);
 }
 
+inline void *PersistentAllocator::refillAndAlloc(uptr size) {
+  // If failed, lock, retry and alloc new superblock.
+  SpinMutexLock l(&mtx);
+  for (;;) {
+    void *s = tryAlloc(size);
+    if (s)
+      return s;
+    atomic_store(&region_pos, 0, memory_order_relaxed);
+    uptr allocsz = 64 * 1024;
+    if (allocsz < size)
+      allocsz = size;
+    uptr mem = (uptr)MmapOrDie(allocsz, "stack depot");
+    atomic_fetch_add(&mapped_size, allocsz, memory_order_relaxed);
+    atomic_store(&region_end, mem + allocsz, memory_order_release);
+    atomic_store(&region_pos, mem, memory_order_release);
+  }
+}
+
 } // namespace __sanitizer
 
 #endif // SANITIZER_PERSISTENT_ALLOCATOR_H

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
index 9f38a29f99129..b7f47b4566abc 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
@@ -18,7 +18,6 @@
 #include "sanitizer_atomic.h"
 #include "sanitizer_internal_defs.h"
 #include "sanitizer_mutex.h"
-#include "sanitizer_persistent_allocator.h"
 
 namespace __sanitizer {
 

diff  --git a/compiler-rt/lib/tsan/go/build.bat b/compiler-rt/lib/tsan/go/build.bat
index 4d05480263da9..ba246a4648803 100644
--- a/compiler-rt/lib/tsan/go/build.bat
+++ b/compiler-rt/lib/tsan/go/build.bat
@@ -25,7 +25,6 @@ type ^
   ..\..\sanitizer_common\sanitizer_win.cpp ^
   ..\..\sanitizer_common\sanitizer_deadlock_detector1.cpp ^
   ..\..\sanitizer_common\sanitizer_stackdepot.cpp ^
-  ..\..\sanitizer_common\sanitizer_persistent_allocator.cpp ^
   ..\..\sanitizer_common\sanitizer_flag_parser.cpp ^
   ..\..\sanitizer_common\sanitizer_symbolizer.cpp ^
   ..\..\sanitizer_common\sanitizer_termination.cpp ^

diff  --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
index 489da16066dd4..35456725fb43a 100755
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -27,7 +27,6 @@ SRCS="
 	../../sanitizer_common/sanitizer_flags.cpp
 	../../sanitizer_common/sanitizer_libc.cpp
 	../../sanitizer_common/sanitizer_mutex.cpp
-	../../sanitizer_common/sanitizer_persistent_allocator.cpp
 	../../sanitizer_common/sanitizer_printf.cpp
 	../../sanitizer_common/sanitizer_suppressions.cpp
 	../../sanitizer_common/sanitizer_thread_registry.cpp

diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
index 2cafcba3f95c6..00eaa1b63cdc0 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
@@ -84,7 +84,6 @@ source_set("sources") {
     "sanitizer_mutex.cpp",
     "sanitizer_mutex.h",
     "sanitizer_netbsd.cpp",
-    "sanitizer_persistent_allocator.cpp",
     "sanitizer_persistent_allocator.h",
     "sanitizer_placement_new.h",
     "sanitizer_platform.h",


        


More information about the cfe-commits mailing list