Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
[oota-llvm.git] / lib / Transforms / Scalar / LoopUnswitch.cpp
index 8d39a4dece31e4374d8727bb897376e6ca3a0441..47751235304a25f2ac93f7e1cd229f6ccc9b399a 100644 (file)
@@ -115,12 +115,12 @@ namespace {
         LoopProcessWorklist.erase(I);
     }
 
-    /// Split all of the edges from inside the loop to their exit blocks.  Update
-    /// the appropriate Phi nodes as we do so.
+    /// Split all of the edges from inside the loop to their exit blocks.
+    /// Update the appropriate Phi nodes as we do so.
     void SplitExitEdges(Loop *L, const SmallVector<BasicBlock *, 8> &ExitBlocks,
                         SmallVector<BasicBlock *, 8> &MiddleBlocks);
 
-    /// If BB's dominance frontier  has a member that is not part of loop L then 
+    /// If BB's dominance frontier  has a member that is not part of loop L then
     /// remove it. Add NewDFMember in BB's dominance frontier.
     void ReplaceLoopExternalDFMember(Loop *L, BasicBlock *BB,
                                      BasicBlock *NewDFMember);
@@ -568,7 +568,7 @@ void LoopUnswitch::EmitPreheaderBranchOnCondition(Value *LIC, Constant *Val,
     std::swap(TrueDest, FalseDest);
 
   // Insert the new branch.
-  new BranchInst(TrueDest, FalseDest, BranchVal, InsertPt);
+  BranchInst::Create(TrueDest, FalseDest, BranchVal, InsertPt);
 
 }
 
@@ -644,10 +644,10 @@ void LoopUnswitch::ReplaceLoopExternalDFMember(Loop *L, BasicBlock *BB,
   DF->addToFrontier(DFI, NewDFMember);
 }
 
-/// SplitExitEdges -
-/// Split all of the edges from inside the loop to their exit blocks.  Update
-/// the appropriate Phi nodes as we do so.
-void LoopUnswitch::SplitExitEdges(Loop *L, const SmallVector<BasicBlock *, 8> &ExitBlocks,
+/// SplitExitEdges - Split all of the edges from inside the loop to their exit
+/// blocks.  Update the appropriate Phi nodes as we do so.
+void LoopUnswitch::SplitExitEdges(Loop *L, 
+                                 const SmallVector<BasicBlock *, 8> &ExitBlocks,
                                   SmallVector<BasicBlock *, 8> &MiddleBlocks) {
 
   for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
@@ -673,9 +673,9 @@ void LoopUnswitch::SplitExitEdges(Loop *L, const SmallVector<BasicBlock *, 8> &E
       for (BasicBlock::iterator I = EndBlock->begin();
            (OldLCSSA = dyn_cast<PHINode>(I)); ++I) {
         Value* OldValue = OldLCSSA->getIncomingValueForBlock(MiddleBlock);
-        PHINode* NewLCSSA = new PHINode(OldLCSSA->getType(),
-                                        OldLCSSA->getName() + ".us-lcssa",
-                                        MiddleBlock->getTerminator());
+        PHINode* NewLCSSA = PHINode::Create(OldLCSSA->getType(),
+                                            OldLCSSA->getName() + ".us-lcssa",
+                                            MiddleBlock->getTerminator());
         NewLCSSA->addIncoming(OldValue, StartBlock);
         OldLCSSA->setIncomingValue(OldLCSSA->getBasicBlockIndex(MiddleBlock),
                                    NewLCSSA);
@@ -687,9 +687,9 @@ void LoopUnswitch::SplitExitEdges(Loop *L, const SmallVector<BasicBlock *, 8> &E
       for (BasicBlock::iterator I = MiddleBlock->begin();
          (OldLCSSA = dyn_cast<PHINode>(I)) && InsertedPHIs.count(OldLCSSA) == 0;
          ++I) {
-        PHINode *NewLCSSA = new PHINode(OldLCSSA->getType(),
-                                        OldLCSSA->getName() + ".us-lcssa",
-                                        InsertPt);
+        PHINode *NewLCSSA = PHINode::Create(OldLCSSA->getType(),
+                                            OldLCSSA->getName() + ".us-lcssa",
+                                            InsertPt);
         OldLCSSA->replaceAllUsesWith(NewLCSSA);
         NewLCSSA->addIncoming(OldLCSSA, MiddleBlock);
       }
@@ -850,8 +850,8 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
       //   If LBB's dominance frontier includes DFMember 
       //      such that DFMember is also a member of LoopDF then
       //         - Remove DFMember from LBB's dominance frontier
-      //         - Copy loop exiting blocks', that are dominated by BB, dominance frontier
-      //           member in BB's dominance frontier
+      //         - Copy loop exiting blocks', that are dominated by BB,
+      //           dominance frontier member in BB's dominance frontier
 
       DominanceFrontier::iterator LBBI = DF->find(LBB);
       DominanceFrontier::iterator NBBI = DF->find(NBB);
@@ -870,7 +870,8 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
         
         // If LBB dominates loop exits then insert loop exit block's DF
         // into B's DF.
-        for(SmallVector<BasicBlock *, 4>::iterator LExitI = ExitingBlocks.begin(),
+        for(SmallVector<BasicBlock *, 4>::iterator 
+              LExitI = ExitingBlocks.begin(),
               LExitE = ExitingBlocks.end(); LExitI != LExitE; ++LExitI) {
           BasicBlock *E = *LExitI;
           
@@ -888,7 +889,8 @@ void LoopUnswitch::UnswitchNontrivialCondition(Value *LIC, Constant *Val,
           removeB = true;
         }
         
-        // If B's replacement is inserted in DF then now is the time to remove B.
+        // If B's replacement is inserted in DF then now is the time to remove
+        // B.
         if (removeB) {
           DF->removeFromFrontier(LBBI, B);
           if (L->contains(B))
@@ -1151,10 +1153,10 @@ void LoopUnswitch::RewriteLoopBodyWithConditionConstant(Loop *L, Value *LIC,
               BasicBlock* Split = SplitBlock(Old, SI, this);
               
               Instruction* OldTerm = Old->getTerminator();
-              new BranchInst(Split, SI->getSuccessor(i),
-                             ConstantInt::getTrue(), OldTerm);
+              BranchInst::Create(Split, SI->getSuccessor(i),
+                                 ConstantInt::getTrue(), OldTerm);
 
-              LPM->deleteSimpleAnalysisValue(Old->getTerminator(), L);                
+              LPM->deleteSimpleAnalysisValue(Old->getTerminator(), L);
               Old->getTerminator()->eraseFromParent();
               
               PHINode *PN;
@@ -1291,7 +1293,7 @@ void LoopUnswitch::SimplifyCode(std::vector<Instruction*> &Worklist, Loop *L) {
         BasicBlock *DeadSucc = BI->getSuccessor(CB->getZExtValue());
         BasicBlock *LiveSucc = BI->getSuccessor(!CB->getZExtValue());
         DeadSucc->removePredecessor(BI->getParent(), true);
-        Worklist.push_back(new BranchInst(LiveSucc, BI));
+        Worklist.push_back(BranchInst::Create(LiveSucc, BI));
         LPM->deleteSimpleAnalysisValue(BI, L);
         BI->eraseFromParent();
         RemoveFromWorklist(BI, Worklist);