Avoid unnecessary string construction during asm printing.
[oota-llvm.git] / lib / CodeGen / BranchFolding.cpp
index e67339ab3860066f1d86587615c327b36a7cb7ac..f6b3d9cada5066d602eb1ffcb4ae93055ef09d6b 100644 (file)
@@ -114,12 +114,12 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) {
   while (!MBB->succ_empty())
     MBB->removeSuccessor(MBB->succ_end()-1);
   
-  // If there is DWARF info to active, check to see if there are any LABEL
+  // If there is DWARF info to active, check to see if there are any DBG_LABEL
   // records in the basic block.  If so, unregister them from MachineModuleInfo.
   if (MMI && !MBB->empty()) {
     for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
          I != E; ++I) {
-      if ((unsigned)I->getOpcode() == TargetInstrInfo::LABEL) {
+      if ((unsigned)I->getOpcode() == TargetInstrInfo::DBG_LABEL) {
         // The label ID # is always operand #0, an immediate.
         MMI->InvalidateLabel(I->getOperand(0).getImm());
       }
@@ -127,7 +127,7 @@ void BranchFolder::RemoveDeadBlock(MachineBasicBlock *MBB) {
   }
   
   // Remove the block.
-  MF->getBasicBlockList().erase(MBB);
+  MF->erase(MBB);
 }
 
 /// OptimizeImpDefsBlock - If a basic block is just a bunch of implicit_def
@@ -375,17 +375,15 @@ void BranchFolder::ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst,
 /// iterator.  This returns the new MBB.
 MachineBasicBlock *BranchFolder::SplitMBBAt(MachineBasicBlock &CurMBB,
                                             MachineBasicBlock::iterator BBI1) {
+  MachineFunction &MF = *CurMBB.getParent();
+
   // Create the fall-through block.
   MachineFunction::iterator MBBI = &CurMBB;
-  MachineBasicBlock *NewMBB = new MachineBasicBlock(CurMBB.getBasicBlock());
-  CurMBB.getParent()->getBasicBlockList().insert(++MBBI, NewMBB);
+  MachineBasicBlock *NewMBB =MF.CreateMachineBasicBlock(CurMBB.getBasicBlock());
+  CurMBB.getParent()->insert(++MBBI, NewMBB);
 
   // Move all the successors of this block to the specified block.
-  while (!CurMBB.succ_empty()) {
-    MachineBasicBlock *S = *(CurMBB.succ_end()-1);
-    NewMBB->addSuccessor(S);
-    CurMBB.removeSuccessor(S);
-  }
+  NewMBB->transferSuccessors(&CurMBB);
  
   // Add an edge from CurMBB to NewMBB for the fall-through.
   CurMBB.addSuccessor(NewMBB);
@@ -701,8 +699,7 @@ bool BranchFolder::TailMergeBlocks(MachineFunction &MF) {
   // transformations.)
 
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
-    if (!I->succ_empty() && I->pred_size() >= 2 && 
-         I->pred_size() < TailMergeThreshold) {
+    if (I->pred_size() >= 2 && I->pred_size() < TailMergeThreshold) {
       MachineBasicBlock *IBB = I;
       MachineBasicBlock *PredBB = prior(I);
       MergePotentials.clear();