[llvm] [GVN] Improve processBlock for instruction erasure (PR #131753)

Antonio Frighetto via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 11:35:57 PDT 2025


================
@@ -2820,41 +2817,12 @@ bool GVNPass::processBlock(BasicBlock *BB) {
     VN.erase(PN);
     removeInstruction(PN);
   }
-
-  for (BasicBlock::iterator BI = BB->begin(), BE = BB->end();
-       BI != BE;) {
+  for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) {
+    Instruction *Inst = &*BI++;
----------------
antoniofrighetto wrote:

```suggestion
  for (Instruction &Inst : make_early_inc_range(*BB)) {
```

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


More information about the llvm-commits mailing list