From a915ef0fc085d914df69d531c0438d2c330df5de Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 2 Aug 2002 16:51:27 +0000 Subject: Fix bug: test/Regression/Other/2002-08-02-DomSetProblem.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3213 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Dominators.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index eb57587..a388402 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -60,7 +60,7 @@ bool DominatorSet::runOnFunction(Function &F) { // in at least once. We are guaranteed to have this because we are // traversing the graph in DFO and have handled start nodes specially. // - while (Doms[*PI].size() == 0) ++PI; + while (Doms[*PI].empty()) ++PI; WorkingSet = Doms[*PI]; for (++PI; PI != PEnd; ++PI) { // Intersect all of the predecessor sets @@ -79,6 +79,17 @@ bool DominatorSet::runOnFunction(Function &F) { WorkingSet.clear(); // Clear out the set for next iteration } } while (Changed); + + // 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 adding self dominance info to the DomSet if the block doesn't + // already have an entry. + // + for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) + if (!Doms.count(I)) + Doms[I].insert(I); + return false; } -- cgit v1.1