[llvm] [InterleavedAccessPass]: Ensure that dead nodes get erased only once (PR #122643)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 13 03:14:04 PST 2025


================
@@ -545,7 +545,8 @@ bool InterleavedAccessImpl::runOnFunction(Function &F) {
   }
 
   for (auto *I : DeadInsts)
-    I->eraseFromParent();
+    if (I->getParent())
----------------
david-arm wrote:

It looks like you're trying to fix a scenario where the same Instruction is included twice in `DeadInsts`, right? I think the problem here is that `I` may have been deleted and so you're dereferencing unreliable contents in memory or we could seg fault. I think you probably need to fix this a different way either by:

1. Keeping track of which instructions you've deleted, i.e. by maintaining a map of visited instructions. Or,
2. Removing duplicate dead instructions from the list before iterating over them.

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


More information about the llvm-commits mailing list