[llvm] [RegisterCoalescer] Fix reuse of instruction pointers (PR #73519)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 27 19:17:10 PST 2023


================
@@ -1190,7 +1203,15 @@ bool RegisterCoalescer::removePartialRedundancy(const CoalescerPair &CP,
     // If the newly created Instruction has an address of an instruction that was
     // deleted before (object recycled by the allocator) it needs to be removed from
     // the deleted list.
-    ErasedInstrs.erase(NewCopyMI);
+    bool WasErased = ErasedInstrs.erase(NewCopyMI);
+    // Also remove the deleted instruction from work lists. There shouldn't be
+    // duplicate instructions there.
+    if (WasErased) {
+      // Attempt to remove from WorkList. If not found, it could be in
+      // LocalWorkList.
----------------
arsenm wrote:

For the partial redundancy case, can't it only be in the global worklist?

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


More information about the llvm-commits mailing list