// We print the probabilities from the last function the analysis ran over,
// or the function it is currently running over.
assert(LastF && "Cannot print prior to running over a function");
- for (Function::const_iterator BI = LastF->begin(), BE = LastF->end();
- BI != BE; ++BI) {
- for (succ_const_iterator SI = succ_begin(BI), SE = succ_end(BI);
- SI != SE; ++SI) {
- printEdgeProbability(OS << " ", BI, *SI);
+ for (const auto &BI : *LastF) {
+ for (succ_const_iterator SI = succ_begin(&BI), SE = succ_end(&BI); SI != SE;
+ ++SI) {
+ printEdgeProbability(OS << " ", &BI, *SI);
}
}
}
uint32_t N = getEdgeWeight(Src, IndexInSuccessors);
uint32_t D = getSumForBlock(Src);
+ // It is possible that the edge weight on the only successor edge of Src is
+ // zero, in which case we return 100%.
+ if (N == 0 && D == 0)
+ return BranchProbability::getOne();
+
return BranchProbability(N, D);
}
uint32_t N = getEdgeWeight(Src, Dst);
uint32_t D = getSumForBlock(Src);
+ // It is possible that the edge weight on the only successor edge of Src is
+ // zero, in which case we return 100%.
+ if (N == 0 && D == 0)
+ return BranchProbability::getOne();
+
return BranchProbability(N, D);
}