]> granicus.if.org Git - llvm/commitdiff
[Dominators] Don't compute DFS InOut numbers eagerly.
authorJakub Kuderski <kubakuderski@gmail.com>
Fri, 30 Jun 2017 01:28:21 +0000 (01:28 +0000)
committerJakub Kuderski <kubakuderski@gmail.com>
Fri, 30 Jun 2017 01:28:21 +0000 (01:28 +0000)
Summary:
DFS InOut numbers currently get eagerly computer upon DomTree construction. They are only needed to answer dome dominance queries and they get invalidated by updates and recalculations. Because of that, it is faster in practice to compute them lazily when they are actually needed.

Clang built without this patch takes 6m 45s to boostrap on my machine, and with the patch applied 6m 38s.

Reviewers: sanjoy, dberlin, chandlerc

Reviewed By: dberlin

Subscribers: davide, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306778 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/GenericDomTreeConstruction.h
test/Analysis/Dominators/2006-10-02-BreakCritEdges.ll
unittests/IR/DominatorTreeTest.cpp

index 7899a81751a692ad3feb269c8c5dc2ced7239707..038d34fd5c6fb67fe42efa4e6fd96a995bc39460 100644 (file)
@@ -277,8 +277,6 @@ struct SemiNCAInfo {
       DT.DomTreeNodes[W] = IDomNode->addChild(
           llvm::make_unique<DomTreeNodeBase<NodeT>>(W, IDomNode));
     }
-
-    DT.updateDFSNumbers();
   }
 
   void doFullDFSWalk(const DomTreeT &DT) {
index a8013176977da7d0089edf2f9adf6c0585613ec8..c036fe22ab87e681abee48eae5940aaaaaa643c2 100644 (file)
@@ -2,7 +2,7 @@
 ; RUN: opt < %s -passes='require<domtree>,break-crit-edges,print<domtree>' -disable-output 2>&1| FileCheck %s
 ; PR932
 
-; CHECK: [3] %brtrue {1,2}
+; CHECK: [3] %brtrue {{{[0-9]+}},{{[0-9]+}}}
 
 declare void @use1(i32)
 
index 232f0cbd4ed9f53d2aec21cb33d46a7c12bebeff..5d3ef30177aeadec21eb7f29bfe80d78900b044b 100644 (file)
@@ -220,6 +220,7 @@ TEST(DominatorTree, Unreachable) {
         EXPECT_EQ(PostDominatedBBs.size(), 0UL);
 
         // Check DFS Numbers before
+        DT->updateDFSNumbers();
         EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL);
         EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 7UL);
         EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL);
@@ -235,6 +236,7 @@ TEST(DominatorTree, Unreachable) {
         DT->recalculate(F);
 
         // Check DFS Numbers after
+        DT->updateDFSNumbers();
         EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL);
         EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 9UL);
         EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL);