[llvm] [VPlan] Fix VPTypeAnalysis cache clobbering in EVL transform (PR #120252)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 09:20:04 PST 2024


================
@@ -1565,10 +1567,17 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
         VPValue *CurVPV = CurRecipe->getVPSingleValue();
         CurVPV->replaceAllUsesWith(NewRecipe->getVPSingleValue());
       }
-      CurRecipe->eraseFromParent();
+      // Defer erasing recipes till the end so that we don't invalidate the
+      // VPTypeAnalysis cache
+      ToErase.push_back(CurRecipe);
     }
-    recursivelyDeleteDeadRecipes(HeaderMask);
----------------
fhahn wrote:

In that case, maybe just recursively delete the recipes to erase, which then will automatically clean up the header mask if it becomes dead?

All recipes you are queuing should be `VPSingelDefRecipe*`

```
 for (VPRecipeBase *R : ToErase)
     recursivelyDeleteDeadRecipes(R);
```

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


More information about the llvm-commits mailing list