diff --git a/clang/docs/tools/clang-formatted-files.txt b/clang/docs/tools/clang-formatted-files.txt
--- 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_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
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -18,7 +18,6 @@
   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
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.h
@@ -53,7 +53,9 @@
 
     bool eq(hash_type hash, const args_type &args) const;
 
-    static uptr storage_size(const args_type &args);
+    static uptr allocated();
+
+    static ChainedOriginDepotNode *allocate(const args_type &args);
 
     static hash_type hash(const args_type &args);
 
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
--- a/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_chained_origin_depot.cpp
@@ -13,14 +13,21 @@
 
 namespace __sanitizer {
 
+static PersistentAllocator allocator;
+
 bool ChainedOriginDepot::ChainedOriginDepotNode::eq(
     hash_type hash, const args_type &args) const {
   return here_id == args.here_id && prev_id == args.prev_id;
 }
 
-uptr ChainedOriginDepot::ChainedOriginDepotNode::storage_size(
-    const args_type &args) {
-  return sizeof(ChainedOriginDepotNode);
+uptr ChainedOriginDepot::ChainedOriginDepotNode::allocated() {
+  return allocator.total_size();
+}
+
+ChainedOriginDepot::ChainedOriginDepotNode *
+ChainedOriginDepot::ChainedOriginDepotNode::allocate(const args_type &args) {
+  return static_cast<ChainedOriginDepot::ChainedOriginDepotNode *>(
+      allocator.alloc(sizeof(ChainedOriginDepotNode)));
 }
 
 /* This is murmur2 hash for the 64->32 bit case.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
--- a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.h
@@ -23,12 +23,14 @@
 class PersistentAllocator {
  public:
   void *alloc(uptr size);
+  uptr total_size() const { return atomic_load_relaxed(&allocated_size); }
 
  private:
   void *tryAlloc(uptr size);
   StaticSpinMutex mtx;  // Protects alloc of new blocks for region allocator.
   atomic_uintptr_t region_pos;  // Region allocator for Node's.
   atomic_uintptr_t region_end;
+  atomic_uintptr_t allocated_size;
 };
 
 inline void *PersistentAllocator::tryAlloc(uptr size) {
@@ -56,16 +58,13 @@
     uptr allocsz = 64 * 1024;
     if (allocsz < size) allocsz = size;
     uptr mem = (uptr)MmapOrDie(allocsz, "stack depot");
+    atomic_fetch_add(&allocated_size, allocsz, memory_order_relaxed);
     atomic_store(&region_end, mem + allocsz, memory_order_release);
     atomic_store(&region_pos, mem, memory_order_release);
+    atomic_store(&region_pos, mem, memory_order_release);
   }
 }
 
-extern PersistentAllocator thePersistentAllocator;
-inline void *PersistentAlloc(uptr sz) {
-  return thePersistentAllocator.alloc(sz);
-}
-
 } // namespace __sanitizer
 
 #endif // SANITIZER_PERSISTENT_ALLOCATOR_H
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
--- a/compiler-rt/lib/sanitizer_common/sanitizer_persistent_allocator.cpp
+++ /dev/null
@@ -1,18 +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 {
-
-PersistentAllocator thePersistentAllocator;
-
-}  // namespace __sanitizer
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cpp
@@ -14,10 +14,13 @@
 
 #include "sanitizer_common.h"
 #include "sanitizer_hash.h"
+#include "sanitizer_persistent_allocator.h"
 #include "sanitizer_stackdepotbase.h"
 
 namespace __sanitizer {
 
+static PersistentAllocator allocator;
+
 struct StackDepotNode {
   using hash_type = u64;
   hash_type stack_hash;
@@ -36,8 +39,10 @@
   bool eq(hash_type hash, const args_type &args) const {
     return hash == stack_hash;
   }
-  static uptr storage_size(const args_type &args) {
-    return sizeof(StackDepotNode) + (args.size - 1) * sizeof(uptr);
+  static uptr allocated() { return allocator.total_size(); }
+  static StackDepotNode *allocate(const args_type &args) {
+    uptr alloc_size = sizeof(StackDepotNode) + (args.size - 1) * sizeof(uptr);
+    return (StackDepotNode *)allocator.alloc(alloc_size);
   }
   static hash_type hash(const args_type &args) {
     MurMur2Hash64Builder H(args.size * sizeof(uptr));
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepotbase.h
@@ -33,7 +33,7 @@
   // Retrieves a stored stack trace by the id.
   args_type Get(u32 id);
 
-  StackDepotStats GetStats() const { return stats; }
+  StackDepotStats GetStats() const { return {n_uniq_ids, Node::allocated()}; }
 
   void LockAll();
   void UnlockAll();
@@ -55,7 +55,7 @@
   atomic_uintptr_t tab[kTabSize];   // Hash table of Node's.
   atomic_uint32_t seq[kPartCount];  // Unique id generators.
 
-  StackDepotStats stats;
+  uptr n_uniq_ids;
 
   friend class StackDepotReverseMap;
 };
@@ -120,14 +120,12 @@
   }
   uptr part = (h % kTabSize) / kPartSize;
   u32 id = atomic_fetch_add(&seq[part], 1, memory_order_relaxed) + 1;
-  stats.n_uniq_ids++;
+  n_uniq_ids++;
   CHECK_LT(id, kMaxId);
   id |= part << kPartShift;
   CHECK_NE(id, 0);
   CHECK_EQ(id & (((u32)-1) >> kReservedBits), id);
-  uptr memsz = Node::storage_size(args);
-  s = (Node *)PersistentAlloc(memsz);
-  stats.allocated += memsz;
+  s = Node::allocate(args);
   s->id = id;
   s->store(args, h);
   s->link = s2;
diff --git a/compiler-rt/lib/tsan/go/buildgo.sh b/compiler-rt/lib/tsan/go/buildgo.sh
--- a/compiler-rt/lib/tsan/go/buildgo.sh
+++ b/compiler-rt/lib/tsan/go/buildgo.sh
@@ -27,7 +27,6 @@
 	../../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
--- 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 @@
     "sanitizer_mutex.cpp",
     "sanitizer_mutex.h",
     "sanitizer_netbsd.cpp",
-    "sanitizer_persistent_allocator.cpp",
     "sanitizer_persistent_allocator.h",
     "sanitizer_placement_new.h",
     "sanitizer_platform.h",