forked from OSchip/llvm-project
[BFI]: code cleanup
Expose getBPI interface from BFI impl and use it in graph viewer. This eliminates the dependency on old PM interface. llvm-svn: 273967
This commit is contained in:
parent
0f684b0d04
commit
3264fdd3ca
|
@ -927,6 +927,8 @@ public:
|
|||
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.
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
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
|
||||
|
|
|
@ -120,13 +120,14 @@ struct DOTGraphTraits<MachineBlockFrequencyInfo *>
|
|||
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();
|
||||
|
@ -207,6 +208,10 @@ const MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
|
|||
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 {
|
||||
|
|
Loading…
Reference in New Issue