aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Dominators.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-18 22:11:16 +0000
committerChris Lattner <sabre@nondot.org>2003-08-18 22:11:16 +0000
commit24f83a15dd50b923fe674a55c5f11d91f383bb01 (patch)
tree15d0ff93b370985e2395d8af5c8cee870a714321 /lib/VMCore/Dominators.cpp
parentfd4d8975cf0e7c288b4985b1751113154c7defcc (diff)
downloadexternal_llvm-24f83a15dd50b923fe674a55c5f11d91f383bb01.zip
external_llvm-24f83a15dd50b923fe674a55c5f11d91f383bb01.tar.gz
external_llvm-24f83a15dd50b923fe674a55c5f11d91f383bb01.tar.bz2
Do not even attempt to compute dominator information for unreachable blocks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7963 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Dominators.cpp')
-rw-r--r--lib/VMCore/Dominators.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index abd875e..c55f0e4 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -48,7 +48,7 @@ void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) {
BasicBlock *BB = *It;
pred_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
if (PI != PEnd) { // Is there SOME predecessor?
- // Loop until we get to a predecessor that has had it's dom set filled
+ // Loop until we get to a predecessor that has had its dom set filled
// in at least once. We are guaranteed to have this because we are
// traversing the graph in DFO and have handled start nodes specially,
// except when there are unreachable blocks.
@@ -63,29 +63,15 @@ void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) {
if (PredSet.size())
set_intersect(WorkingSet, PredSet);
}
- } else {
- // Otherwise this block is unreachable. it doesn't really matter what
- // we use for the dominator set for the node...
- //
- WorkingSet = Doms[Root];
}
- } else if (BB != Root) {
- // If this isn't the root basic block and it has no predecessors, it
- // must be an unreachable block. Fib a bit by saying that the root node
- // dominates this unreachable node. This isn't exactly true, because
- // there is no path from the entry node to this node, but it is sorta
- // true because any paths to this node would have to go through the
- // entry node.
- //
- // This allows for dominator properties to be built for unreachable code
- // in a reasonable manner.
- //
- WorkingSet = Doms[Root];
+ } else {
+ assert(BB == Root && "We got into unreachable code somehow!");
}
WorkingSet.insert(BB); // A block always dominates itself
DomSetType &BBSet = Doms[BB];
if (BBSet != WorkingSet) {
+ //assert(WorkingSet.size() > BBSet.size() && "Must only grow sets!");
BBSet.swap(WorkingSet); // Constant time operation!
Changed = true; // The sets changed.
}
@@ -113,16 +99,12 @@ void DominatorSet::recalculate() {
// Calculate dominator sets for the reachable basic blocks...
calculateDominatorsFromBlock(Root);
- // Every basic block in the function should at least dominate themselves, and
- // thus every basic block should have an entry in Doms. The one case where we
- // miss this is when a basic block is unreachable. To get these we now do an
- // extra pass over the function, calculating dominator information for
+
+ // Loop through the function, ensuring that every basic block has at least an
+ // empty set of nodes. This is important for the case when there is
// unreachable blocks.
- //
Function *F = Root->getParent();
- for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
- if (Doms[I].count(I) == 0)
- calculateDominatorsFromBlock(I);
+ for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I) Doms[I];
}