Reworked branch adding in prologue. Added check for infinite loops which are not modulo scheduled.

llvm-svn: 18419
diff --git a/llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp b/llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
index 29aba15..beab69c 100644
--- a/llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
+++ b/llvm/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp
@@ -164,9 +164,7 @@
 }
 
 bool MSSchedule::constructKernel(int II) {
-  MSchedGraphNode *branchNode = 0;
-  MSchedGraphNode *branchANode = 0;
-
+ 
   int stageNum = (schedule.rbegin()->first)/ II;
   DEBUG(std::cerr << "Number of Stages: " << stageNum << "\n");
   
@@ -178,11 +176,8 @@
 	      E = schedule[i].end(); I != E; ++I) {
 	  //Check if its a branch
 	  if((*I)->isBranch()) {
-	    if((*I)->getInst()->getOpcode() == V9::BA)
-	      branchANode = *I;
-	    else
-	      branchNode = *I;
 	    assert(count == 0 && "Branch can not be from a previous iteration");
+	    kernel.push_back(std::make_pair(*I, count));
 	  }
 	  else
 	  //FIXME: Check if the instructions in the earlier stage conflict
@@ -193,13 +188,6 @@
     }
   }
   
-  //Add Branch to the end
-  kernel.push_back(std::make_pair(branchNode, 0));
-
-  //Add Branch Always to the end
-  kernel.push_back(std::make_pair(branchANode, 0));
-
-
   if(stageNum > 0)
     maxStage = stageNum;
   else