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