Remove redundant code in MachineBasicBlock.cpp. NFC.
authorCong Hou <congh@google.com>
Wed, 18 Nov 2015 01:45:10 +0000 (01:45 +0000)
committerCong Hou <congh@google.com>
Wed, 18 Nov 2015 01:45:10 +0000 (01:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253425 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/MachineBasicBlock.cpp

index 44dbf9f..354bd3e 100644 (file)
@@ -544,24 +544,9 @@ void MachineBasicBlock::addSuccessorWithoutProb(MachineBasicBlock *Succ) {
 }
 
 void MachineBasicBlock::removeSuccessor(MachineBasicBlock *Succ) {
 }
 
 void MachineBasicBlock::removeSuccessor(MachineBasicBlock *Succ) {
-  Succ->removePredecessor(this);
   succ_iterator I = std::find(Successors.begin(), Successors.end(), Succ);
   assert(I != Successors.end() && "Not a current successor!");
   succ_iterator I = std::find(Successors.begin(), Successors.end(), Succ);
   assert(I != Successors.end() && "Not a current successor!");
-
-  // If Weight list is empty it means we don't use it (disabled optimization).
-  if (!Weights.empty()) {
-    weight_iterator WI = getWeightIterator(I);
-    Weights.erase(WI);
-  }
-
-  // If probability list is empty it means we don't use it (disabled
-  // optimization).
-  if (!Probs.empty()) {
-    probability_iterator WI = getProbabilityIterator(I);
-    Probs.erase(WI);
-  }
-
-  Successors.erase(I);
+  removeSuccessor(I);
 }
 
 MachineBasicBlock::succ_iterator
 }
 
 MachineBasicBlock::succ_iterator
@@ -606,10 +591,10 @@ void MachineBasicBlock::replaceSuccessor(MachineBasicBlock *Old,
     }
   }
   assert(OldI != E && "Old is not a successor of this block");
     }
   }
   assert(OldI != E && "Old is not a successor of this block");
-  Old->removePredecessor(this);
 
   // If New isn't already a successor, let it take Old's place.
   if (NewI == E) {
 
   // If New isn't already a successor, let it take Old's place.
   if (NewI == E) {
+    Old->removePredecessor(this);
     New->addPredecessor(this);
     *OldI = New;
     return;
     New->addPredecessor(this);
     *OldI = New;
     return;
@@ -617,18 +602,13 @@ void MachineBasicBlock::replaceSuccessor(MachineBasicBlock *Old,
 
   // New is already a successor.
   // Update its weight instead of adding a duplicate edge.
 
   // New is already a successor.
   // Update its weight instead of adding a duplicate edge.
-  if (!Weights.empty()) {
-    weight_iterator OldWI = getWeightIterator(OldI);
-    *getWeightIterator(NewI) += *OldWI;
-    Weights.erase(OldWI);
-  }
+  if (!Weights.empty())
+    *getWeightIterator(NewI) += *getWeightIterator(OldI);
   // Update its probability instead of adding a duplicate edge.
   // Update its probability instead of adding a duplicate edge.
-  if (!Probs.empty()) {
-    probability_iterator OldPI = getProbabilityIterator(OldI);
-    *getProbabilityIterator(NewI) += *OldPI;
-    Probs.erase(OldPI);
-  }
-  Successors.erase(OldI);
+  if (!Probs.empty())
+    *getProbabilityIterator(NewI) += *getProbabilityIterator(OldI);
+
+  removeSuccessor(OldI);
 }
 
 void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) {
 }
 
 void MachineBasicBlock::addPredecessor(MachineBasicBlock *Pred) {