Only recalculate DFS Numbers if invalid. Invalidate DFS numbers on reset. Add unit test to verify recalculation

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234933 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Berlin
2015-04-14 19:49:26 +00:00
parent 5d6f997e0a
commit 2e6716eb55
2 changed files with 36 additions and 0 deletions

View File

@ -243,6 +243,8 @@ protected:
this->Roots.clear();
Vertex.clear();
RootNode = nullptr;
DFSInfoValid = false;
SlowQueries = 0;
}
// NewBB is split and now it has one successor. Update dominator tree to
@ -663,6 +665,12 @@ public:
/// updateDFSNumbers - Assign In and Out numbers to the nodes while walking
/// dominator tree in dfs order.
void updateDFSNumbers() const {
if (DFSInfoValid) {
SlowQueries = 0;
return;
}
unsigned DFSNum = 0;
SmallVector<std::pair<const DomTreeNodeBase<NodeT> *,