[llvm-commits] [llvm] r79132 - in /llvm/trunk: lib/Transforms/Utils/SSI.cpp test/Transforms/SSI/2009-08-15-UnreachableBB.ll

Nick Lewycky nicholas at mxc.ca
Sat Aug 15 13:12:18 PDT 2009


Author: nicholas
Date: Sat Aug 15 15:12:18 2009
New Revision: 79132

URL: http://llvm.org/viewvc/llvm-project?rev=79132&view=rev
Log:
SSI construction should just go ahead and ignore instructions in unreachable
blocks.

Added:
    llvm/trunk/test/Transforms/SSI/2009-08-15-UnreachableBB.ll
Modified:
    llvm/trunk/lib/Transforms/Utils/SSI.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SSI.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSI.cpp?rev=79132&r1=79131&r2=79132&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SSI.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SSI.cpp Sat Aug 15 15:12:18 2009
@@ -39,7 +39,7 @@
 void SSI::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<DominanceFrontier>();
   AU.addRequired<DominatorTree>();
-  AU.setPreservesAll();
+  AU.setPreservesCFG();
 }
 
 bool SSI::runOnFunction(Function &F) {
@@ -121,7 +121,7 @@
     // Test if there were any sigmas for this variable
     if (needConstruction[i]) {
 
-      SmallPtrSet<BasicBlock *, 1> BB_visited;
+      SmallPtrSet<BasicBlock *, 16> BB_visited;
 
       // Insert phi functions if there is any sigma function
       while (!defsites[i].empty()) {
@@ -131,6 +131,10 @@
         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<BasicBlock *>::iterator DF_BB_begin =
              DF_BB->second.begin(), DF_BB_end = DF_BB->second.end();

Added: llvm/trunk/test/Transforms/SSI/2009-08-15-UnreachableBB.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SSI/2009-08-15-UnreachableBB.ll?rev=79132&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/SSI/2009-08-15-UnreachableBB.ll (added)
+++ llvm/trunk/test/Transforms/SSI/2009-08-15-UnreachableBB.ll Sat Aug 15 15:12:18 2009
@@ -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		; <i32> [#uses=1]
+	%1 = icmp eq i32 %0, 0		; <i1> [#uses=1]
+	br i1 %1, label %bb2, label %bb6
+
+bb2:		; preds = %cc_InitData.exit
+	unreachable
+
+bb6:		; preds = %cc_InitData.exit
+	ret i32 undef
+}





More information about the llvm-commits mailing list