[llvm] r324690 - [CodeGen] Don't compute BranchProbability for MBB::print
Francis Visoiu Mistrih via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 16:40:57 PST 2018
Author: thegameg
Date: Thu Feb 8 16:40:57 2018
New Revision: 324690
URL: http://llvm.org/viewvc/llvm-project?rev=324690&view=rev
Log:
[CodeGen] Don't compute BranchProbability for MBB::print
Avoid re-computing BP only to print successor probabilities in -debug
printing.
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=324690&r1=324689&r2=324690&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Thu Feb 8 16:40:57 2018
@@ -341,23 +341,27 @@ void MachineBasicBlock::print(raw_ostrea
if (I != succ_begin())
OS << ", ";
OS << printMBBReference(**I);
- OS << '(' << format("0x%08" PRIx32, getSuccProbability(I).getNumerator())
- << ')';
+ if (!Probs.empty())
+ 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 (!Probs.empty()) {
+ // 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';
}
- OS << '\n';
}
// Print the preds of this block according to the CFG.
More information about the llvm-commits
mailing list