getSuccWeight returns now default 0 if Weights vector is empty.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133271 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakub Staszak 2011-06-17 18:00:21 +00:00
parent 799a58a55e
commit 981d82674c

View File

@ -768,6 +768,9 @@ MachineBasicBlock::findDebugLoc(MachineBasicBlock::iterator &MBBI) {
/// getSuccWeight - Return weight of the edge from this block to MBB.
///
uint32_t MachineBasicBlock::getSuccWeight(MachineBasicBlock *succ) {
if (Weights.empty())
return 0;
succ_iterator I = std::find(Successors.begin(), Successors.end(), succ);
return *getWeightIterator(I);
}
@ -776,8 +779,7 @@ uint32_t MachineBasicBlock::getSuccWeight(MachineBasicBlock *succ) {
/// iterator
MachineBasicBlock::weight_iterator MachineBasicBlock::
getWeightIterator(MachineBasicBlock::succ_iterator I) {
assert((Weights.size() == Successors.size() || Weights.empty()) &&
"Async weight list!");
assert(Weights.size() == Successors.size() && "Async weight list!");
size_t index = std::distance(Successors.begin(), I);
assert(index < Weights.size() && "Not a current successor!");
return Weights.begin() + index;