diff --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt index 9dd2329f35e8..79a61042e721 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 9cfe6d43e1ff..5630543e7566 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 1d40812aeca0..be4190dc735d 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 3377fcb07939..000000000000 --- 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(®ion_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(®ion_end, mem + allocsz, memory_order_release); - atomic_store(®ion_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 7d06dbb12416..e943fa5da07f 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(®ion_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(®ion_end, mem + allocsz, memory_order_release); + atomic_store(®ion_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 9f38a29f9912..b7f47b4566ab 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 4d05480263da..ba246a464880 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 489da16066dd..35456725fb43 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 2cafcba3f95c..00eaa1b63cdc 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",