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

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 14:54:38 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;
----------------
felipepiovezan wrote:

The rationale for this code is because I removed the code [in line 3596](https://github.com/llvm/llvm-project/pull/74203/files#diff-c952216f21020db4d436ad0aa579a75aee29aab3ac1fe07a6541246e2bb38395R3596) of the "green" side of the diff.

I.e., before:
```
 for (auto *MBB : ArtificialBlocks)
     if (MOutLocs[MBB->getNumber()])
       EjectBlock(*MBB);
```

After:
```
  for (auto *MBB : ArtificialBlocks)
     EjectBlock(*MBB);
```

Prior to this change, we were testing whether something had been ejected by querying whether we had called "reset" on the unique pointer. There are no unique pointers anymore, and checking for whether the length of the vector is 0 not the equivalent, so the only solution was to add this check.

So, with this mind, the patch is 100% intended to be NFC. Do you agree with that?

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


More information about the llvm-commits mailing list