[PATCH] D54730: [DomTree] Fix order of domtree updates in MergeBlockIntoPredecessor.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 19 15:00:25 PST 2018


efriedma created this revision.
efriedma added reviewers: kuhar, brzycki, dmgreen, davide.

If the "delete" update is ordered before the "insert" update, DeleteUnreachable will delete all the descendants of the basic block, so the update isn't really incremental. Changing the order makes the update incremental and fast.  This makes an extreme C++ testcase compile three times faster.

I don't currently have a testcase I can upload, but I can try to construct one if it would be helpful.

I'm not sure this is the right fix; I'm not deeply familiar with how domtree updating works.  Should the batch updating code handle this itself, somehow?


Repository:
  rL LLVM

https://reviews.llvm.org/D54730

Files:
  lib/Transforms/Utils/BasicBlockUtils.cpp


Index: lib/Transforms/Utils/BasicBlockUtils.cpp
===================================================================
--- lib/Transforms/Utils/BasicBlockUtils.cpp
+++ lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -164,11 +164,11 @@
   std::vector<DominatorTree::UpdateType> Updates;
   if (DTU) {
     Updates.reserve(1 + (2 * succ_size(BB)));
+    for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
+      Updates.push_back({DominatorTree::Insert, PredBB, *I});
     Updates.push_back({DominatorTree::Delete, PredBB, BB});
-    for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I) {
+    for (auto I = succ_begin(BB), E = succ_end(BB); I != E; ++I)
       Updates.push_back({DominatorTree::Delete, BB, *I});
-      Updates.push_back({DominatorTree::Insert, PredBB, *I});
-    }
   }
 
   if (MSSAU)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54730.174688.patch
Type: text/x-patch
Size: 814 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181119/b3555371/attachment.bin>


More information about the llvm-commits mailing list