return BlockFrequencyInfoImplBase::getFloatingBlockFreq(getNode(BB));
}
+ const BranchProbabilityInfoT &getBPI() const { return *BPI; }
+
/// \brief Print the frequencies for the current function.
///
/// Prints the frequencies for the blocks in the current function.
Optional<uint64_t> getBlockProfileCount(const MachineBasicBlock *MBB) const;
const MachineFunction *getFunction() const;
+ const MachineBranchProbabilityInfo *getMBPI() const;
void view() const;
// Print the block frequency Freq to OS using the current functions entry
static std::string getEdgeAttributes(const MachineBasicBlock *Node,
EdgeIter EI,
const MachineBlockFrequencyInfo *MBFI) {
- MachineBranchProbabilityInfo &MBPI =
- MBFI->getAnalysis<MachineBranchProbabilityInfo>();
- BranchProbability BP = MBPI.getEdgeProbability(Node, EI);
+ std::string Str;
+ const MachineBranchProbabilityInfo *MBPI = MBFI->getMBPI();
+ if (!MBPI)
+ return Str;
+ BranchProbability BP = MBPI->getEdgeProbability(Node, EI);
uint32_t N = BP.getNumerator();
uint32_t D = BP.getDenominator();
double Percent = 100.0 * N / D;
- std::string Str;
raw_string_ostream OS(Str);
OS << format("label=\"%.1f%%\"", Percent);
OS.flush();
return MBFI ? MBFI->getFunction() : nullptr;
}
+const MachineBranchProbabilityInfo *MachineBlockFrequencyInfo::getMBPI() const {
+ return MBFI ? &MBFI->getBPI() : nullptr;
+}
+
raw_ostream &
MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS,
const BlockFrequency Freq) const {