[llvm] r253425 - Remove redundant code in MachineBasicBlock.cpp. NFC.
Cong Hou via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 17 17:45:10 PST 2015
Author: conghou
Date: Tue Nov 17 19:45:10 2015
New Revision: 253425
URL: http://llvm.org/viewvc/llvm-project?rev=253425&view=rev
Log:
Remove redundant code in MachineBasicBlock.cpp. NFC.
Modified:
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=253425&r1=253424&r2=253425&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Tue Nov 17 19:45:10 2015
@@ -544,24 +544,9 @@ void MachineBasicBlock::addSuccessorWith
}
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!");
-
- // 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
@@ -606,10 +591,10 @@ void MachineBasicBlock::replaceSuccessor
}
}
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) {
+ Old->removePredecessor(this);
New->addPredecessor(this);
*OldI = New;
return;
@@ -617,18 +602,13 @@ void MachineBasicBlock::replaceSuccessor
// 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.
- 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) {
More information about the llvm-commits
mailing list