From: Nick Lewycky Date: Sat, 15 Aug 2009 20:12:18 +0000 (+0000) Subject: SSI construction should just go ahead and ignore instructions in unreachable X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=071d84e1094e532ea7313c7e7a2c1f106f1d424c;p=oota-llvm.git SSI construction should just go ahead and ignore instructions in unreachable blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79132 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/SSI.cpp b/lib/Transforms/Utils/SSI.cpp index 63ca3547935..7736f087684 100644 --- a/lib/Transforms/Utils/SSI.cpp +++ b/lib/Transforms/Utils/SSI.cpp @@ -39,7 +39,7 @@ STATISTIC(NumPhiInserted, "Number of phi functions inserted"); void SSI::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); - AU.setPreservesAll(); + AU.setPreservesCFG(); } bool SSI::runOnFunction(Function &F) { @@ -121,7 +121,7 @@ void SSI::insertPhiFunctions(SmallVectorImpl &value) { // Test if there were any sigmas for this variable if (needConstruction[i]) { - SmallPtrSet BB_visited; + SmallPtrSet BB_visited; // Insert phi functions if there is any sigma function while (!defsites[i].empty()) { @@ -131,6 +131,10 @@ void SSI::insertPhiFunctions(SmallVectorImpl &value) { defsites[i].pop_back(); DominanceFrontier::iterator DF_BB = DF->find(BB); + // The BB is unreachable. Skip it. + if (DF_BB == DF->end()) + continue; + // Iterates through all the dominance frontier of BB for (std::set::iterator DF_BB_begin = DF_BB->second.begin(), DF_BB_end = DF_BB->second.end(); diff --git a/test/Transforms/SSI/2009-08-15-UnreachableBB.ll b/test/Transforms/SSI/2009-08-15-UnreachableBB.ll new file mode 100644 index 00000000000..11a4f60b154 --- /dev/null +++ b/test/Transforms/SSI/2009-08-15-UnreachableBB.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | opt -ssi-everything -disable-output + +declare fastcc i32 @ras_Empty(i8** nocapture) nounwind readonly + +define i32 @cc_Tautology() nounwind { +entry: + unreachable + +cc_InitData.exit: ; No predecessors! + %0 = call fastcc i32 @ras_Empty(i8** undef) nounwind ; [#uses=1] + %1 = icmp eq i32 %0, 0 ; [#uses=1] + br i1 %1, label %bb2, label %bb6 + +bb2: ; preds = %cc_InitData.exit + unreachable + +bb6: ; preds = %cc_InitData.exit + ret i32 undef +}