[llvm] [VPlan] Use RPOT in CSE, fixing potential crash (PR #187548)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 02:23:19 PDT 2026


================
@@ -2630,8 +2630,9 @@ void VPlanTransforms::cse(VPlan &Plan) {
   VPDominatorTree VPDT(Plan);
   DenseMap<VPSingleDefRecipe *, VPSingleDefRecipe *, VPCSEDenseMapInfo> CSEMap;
 
-  for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(
-           vp_depth_first_deep(Plan.getEntry()))) {
+  ReversePostOrderTraversal<VPBlockDeepTraversalWrapper<VPBlockBase *>> RPOT(
+      Plan.getEntry());
----------------
artagnon wrote:

Unfortunately, our RPOT is quite expensive, and my understanding from the comment in PostOrderIterator.h is that we should avoid creating quick shortening-helpers, and construct and use it explicitly, as it comes with quite a few caveats.

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


More information about the llvm-commits mailing list