From 39ec2e95ae6bb24940a1aecdf51d4a096cc0c9de Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Fri, 9 Feb 2018 00:10:31 +0000 Subject: [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 --- llvm/lib/CodeGen/MachineBasicBlock.cpp | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp') diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 1076c198531..f2f84cf8889 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -333,6 +333,30 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, } 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 @@ void MachineBasicBlock::print(raw_ostream &OS, ModuleSlotTracker &MST, 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: " -- cgit v1.2.3