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 @@ -32,7 +32,12 @@ // Retrieves a stored stack trace by the id. args_type Get(u32 id); - StackDepotStats GetStats() const { return stats; } + StackDepotStats GetStats() const { + return { + atomic_load_relaxed(&n_uniq_ids), + atomic_load_relaxed(&allocated), + }; + } void LockAll(); void UnlockAll(); @@ -54,7 +59,8 @@ atomic_uintptr_t tab[kTabSize]; // Hash table of Node's. atomic_uint32_t seq[kPartCount]; // Unique id generators. - StackDepotStats stats; + atomic_uintptr_t n_uniq_ids; + atomic_uintptr_t allocated; friend class StackDepotReverseMap; }; @@ -119,14 +125,14 @@ } uptr part = (h % kTabSize) / kPartSize; u32 id = atomic_fetch_add(&seq[part], 1, memory_order_relaxed) + 1; - stats.n_uniq_ids++; + atomic_fetch_add(&n_uniq_ids, 1, memory_order_relaxed); 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; + atomic_fetch_add(&allocated, memsz, memory_order_relaxed); s->id = id; s->store(args, h); s->link = s2;