[llvm] r324686 - [CodeGen] Only print successors when the list is not empty
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 16:12:53 PST 2018
Author: thegameg
Date: Thu Feb 8 16:12:53 2018
New Revision: 324686
URL: http://llvm.org/viewvc/llvm-project?rev=324686&view=rev
Log:
[CodeGen] Only print successors when the list is not empty
Follow-up of r324685.
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=324686&r1=324685&r2=324686&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Thu Feb 8 16:12:53 2018
@@ -334,27 +334,30 @@ void MachineBasicBlock::print(raw_ostrea
OS << '\n';
}
- // Print the successors
- OS.indent(2) << "successors: ";
- for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
- if (I != succ_begin())
- OS << ", ";
- OS << printMBBReference(**I);
- OS << '(' << format("0x%08" PRIx32, getSuccProbability(I).getNumerator())
- << ')';
- }
- // Print human readable probabilities as comments.
- OS << "; ";
- for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
- const BranchProbability &BP = *getProbabilityIterator(I);
- if (I != succ_begin())
- OS << ", ";
- OS << printMBBReference(**I) << '('
- << format("%.2f%%",
- rint(((double)BP.getNumerator() / BP.getDenominator()) *
- 100.0 * 100.0) /
- 100.0)
- << ')';
+ if (!succ_empty()) {
+ // Print the successors
+ OS.indent(2) << "successors: ";
+ for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
+ if (I != succ_begin())
+ OS << ", ";
+ OS << printMBBReference(**I);
+ OS << '(' << format("0x%08" PRIx32, getSuccProbability(I).getNumerator())
+ << ')';
+ }
+ // Print human readable probabilities as comments.
+ OS << "; ";
+ for (auto I = succ_begin(), E = succ_end(); I != E; ++I) {
+ const BranchProbability &BP = *getProbabilityIterator(I);
+ if (I != succ_begin())
+ OS << ", ";
+ OS << printMBBReference(**I) << '('
+ << format("%.2f%%",
+ rint(((double)BP.getNumerator() / BP.getDenominator()) *
+ 100.0 * 100.0) /
+ 100.0)
+ << ')';
+ }
+ OS << '\n';
}
// Print the preds of this block according to the CFG.
More information about the llvm-commits
mailing list