[CodeGen] Unify the syntax of MBB successors in MIR and -debug output
Instead of:
Successors according to CFG: %bb.6(0x12492492 / 0x80000000 = 14.29%)
print:
successors: %bb.6(0x12492492); %bb.6(14.29%)
llvm-svn: 324685
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 1076c19..f2f84cf 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -333,6 +333,30 @@
}
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)
+ << ')';
+ }
+
// Print the preds of this block according to the CFG.
if (!pred_empty()) {
if (Indexes) OS << '\t';
@@ -355,17 +379,6 @@
OS << '\n';
}
- // Print the successors of this block according to the CFG.
- if (!succ_empty()) {
- if (Indexes) OS << '\t';
- OS << " Successors according to CFG:";
- for (const_succ_iterator SI = succ_begin(), E = succ_end(); SI != E; ++SI) {
- OS << " " << printMBBReference(*(*SI));
- if (!Probs.empty())
- OS << '(' << *getProbabilityIterator(SI) << ')';
- }
- OS << '\n';
- }
if (IrrLoopHeaderWeight) {
if (Indexes) OS << '\t';
OS << " Irreducible loop header weight: "