[PATCH] D101289: [SimplifyCFG] Use applyUpdatesPermissive in HoistThenElseCodeToIf.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 26 09:21:13 PDT 2021


fhahn updated this revision to Diff 340556.
fhahn added a comment.

Avoid using applyUpdatesPermissive, by directly handling the case with duplicated successors.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101289/new/

https://reviews.llvm.org/D101289

Files:
  llvm/lib/Transforms/Utils/SimplifyCFG.cpp


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1610,16 +1610,22 @@
 
   SmallVector<DominatorTree::UpdateType, 4> Updates;
 
+  SmallSetVector<BasicBlock *, 4> SuccsToUpdate;
   // Update any PHI nodes in our new successors.
   for (BasicBlock *Succ : successors(BB1)) {
     AddPredecessorToBlock(Succ, BIParent, BB1);
     if (DTU)
-      Updates.push_back({DominatorTree::Insert, BIParent, Succ});
+      SuccsToUpdate.insert(Succ);
   }
 
-  if (DTU)
-    for (BasicBlock *Succ : successors(BI))
-      Updates.push_back({DominatorTree::Delete, BIParent, Succ});
+  if (DTU) {
+    for (BasicBlock *Succ : SuccsToUpdate)
+      Updates.push_back({DominatorTree::Insert, BIParent, Succ});
+
+    Updates.push_back({DominatorTree::Delete, BIParent, BB1});
+    if (BB1 != BB2)
+      Updates.push_back({DominatorTree::Delete, BIParent, BB2});
+  }
 
   EraseTerminatorAndDCECond(BI);
   if (DTU)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101289.340556.patch
Type: text/x-patch
Size: 1064 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210426/8ae2d78c/attachment.bin>


More information about the llvm-commits mailing list