[llvm] [InstrRef][nfc] Remove usage of unique_ptrs of arrays (PR #74203)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 5 03:06:41 PST 2023


================
@@ -3503,7 +3504,10 @@ bool InstrRefBasedLDV::depthFirstVLocAndEmit(
   // Helper lambda for ejecting a block -- if nothing is going to use the block,
   // we can translate the variable location information into DBG_VALUEs and then
   // free all of InstrRefBasedLDV's data structures.
+  SmallPtrSet<const MachineBasicBlock *, 8> EjectedBBs;
   auto EjectBlock = [&](MachineBasicBlock &MBB) -> void {
+    if (EjectedBBs.insert(&MBB).second == false)
+      return;
----------------
jmorse wrote:

Ahhh, I see the rationale. I'm struggling to remember where that came from -- I thought it should be the case that the set of ArtificialBlocks and the set of blocks produced by `makeDepthFirstEjectionMap` shouldn't overlap anyway because the artificial blocks shouldn't be in any lexical scopes? But maybe they can, as LexicalScopes only stores a start/end block-number pair.

Either way, I'm not confident enough to say the is-null test isn't double-ejection prevention so it should be kept. For performance, could you use a `SmallDenseMap` instead of SmallPtrSet with a call to `reserve` as we'll know the maximum number of blocks that might get inserted. That limits the worst-case map-growth to a single allocation while providing a local scratchpad for small functions.

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


More information about the llvm-commits mailing list