[llvm] r373430 - [GlobalOpt] Pass DTU to removeUnreachableBlocks instead of recomputing.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 01:15:31 PDT 2019


Author: fhahn
Date: Wed Oct  2 01:15:31 2019
New Revision: 373430

URL: http://llvm.org/viewvc/llvm-project?rev=373430&view=rev
Log:
[GlobalOpt] Pass DTU to removeUnreachableBlocks instead of recomputing.

removeUnreachableBlocks knows how to preserve the DomTree, so make use
of it instead of re-computing the DT.

Reviewers: davide, kuhar, brzycki

Reviewed By: davide, kuhar

Differential Revision: https://reviews.llvm.org/D68298

Modified:
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=373430&r1=373429&r2=373430&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Oct  2 01:15:31 2019
@@ -2285,14 +2285,10 @@ OptimizeFunctions(Module &M,
     // So, remove unreachable blocks from the function, because a) there's
     // no point in analyzing them and b) GlobalOpt should otherwise grow
     // some more complicated logic to break these cycles.
-    // Removing unreachable blocks might invalidate the dominator so we
-    // recalculate it.
     if (!F->isDeclaration()) {
-      if (removeUnreachableBlocks(*F)) {
-        auto &DT = LookupDomTree(*F);
-        DT.recalculate(*F);
-        Changed = true;
-      }
+      auto &DT = LookupDomTree(*F);
+      DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
+      Changed |= removeUnreachableBlocks(*F, nullptr, &DTU);
     }
 
     Changed |= processGlobal(*F, GetTLI, LookupDomTree);




More information about the llvm-commits mailing list