[compiler-rt] [NFC] Make RingBuffer an atomic pointer (PR #82547)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 16:59:39 PST 2024


================
@@ -1259,27 +1275,22 @@ class Allocator {
     storeEndMarker(RoundNewPtr, NewSize, BlockEnd);
   }
 
-  StackDepot *getDepotIfEnabled(const Options &Options) {
-    if (!UNLIKELY(Options.get(OptionBit::TrackAllocationStacks)))
-      return nullptr;
-    return Depot;
-  }
-
   void storePrimaryAllocationStackMaybe(const Options &Options, void *Ptr) {
-    auto *Depot = getDepotIfEnabled(Options);
-    if (!Depot)
+    auto *RingBuffer = getRingBufferIfEnabled(Options);
+    if (!RingBuffer)
       return;
     auto *Ptr32 = reinterpret_cast<u32 *>(Ptr);
-    Ptr32[MemTagAllocationTraceIndex] = collectStackTrace(Depot);
+    Ptr32[MemTagAllocationTraceIndex] = collectStackTrace(RingBuffer->Depot);
     Ptr32[MemTagAllocationTidIndex] = getThreadID();
   }
 
-  void storeRingBufferEntry(void *Ptr, u32 AllocationTrace, u32 AllocationTid,
+  void storeRingBufferEntry(AllocationRingBuffer *RB, void *Ptr,
----------------
ChiaHungDuan wrote:

We have the var names `RB` and `RingBuffer` in different places for `AllocationRingBuffer`, besides, we still have `RawRingBuffer` when access the entry. Can we rename this to make it less confusing? For example, we could name 

```
RingBuffer => RawRingBuffer
Var of AllocationRingBuffer => RingBuffer
RawRingBuffer => RingBufferEntryAddress (or EntryAddress)
```

https://github.com/llvm/llvm-project/pull/82547


More information about the llvm-commits mailing list