[compiler-rt] [NFC] Make RingBuffer an atomic pointer (PR #82547)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 21 16:59:41 PST 2024
================
@@ -1061,16 +1064,29 @@ class Allocator {
atomic_u32 DeallocationTrace;
atomic_u32 DeallocationTid;
};
-
+ StackDepot *Depot = nullptr;
+ uptr StackDepotSize = 0;
+ MemMapT RawRingBufferMap;
+ MemMapT RawStackDepotMap;
+ u32 RingBufferElements;
atomic_uptr Pos;
// An array of Size (at least one) elements of type Entry is immediately
// following to this struct.
};
// Pointer to memory mapped area starting with AllocationRingBuffer struct,
// and immediately followed by Size elements of type Entry.
- char *RawRingBuffer = {};
- u32 RingBufferElements = 0;
- MemMapT RawRingBufferMap;
+ atomic_voidptr RingBuffer = {};
+
+ AllocationRingBuffer *getRingBuffer() {
+ return reinterpret_cast<AllocationRingBuffer *>(
+ atomic_load(&RingBuffer, memory_order_acquire));
+ }
+
+ AllocationRingBuffer *getRingBufferIfEnabled(const Options &Options) {
+ if (!UNLIKELY(Options.get(OptionBit::TrackAllocationStacks)))
+ return nullptr;
+ return getRingBuffer();
+ }
----------------
ChiaHungDuan wrote:
The difference between this two functions is unclear to me because both call sites need to check the nullity. I think the better to do this is to inline this function. I.e., check the `TrackAllocationStacks` in the caller
https://github.com/llvm/llvm-project/pull/82547
More information about the llvm-commits
mailing list