mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
blockfreq: Use const in MachineBlockFrequencyInfo
<rdar://problem/14292693> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204740 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
feaa46379a
commit
8451e1baa9
@ -50,7 +50,7 @@ public:
|
||||
///
|
||||
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const;
|
||||
|
||||
MachineFunction *getFunction() const;
|
||||
const MachineFunction *getFunction() const;
|
||||
void view() const;
|
||||
|
||||
// Print the block frequency Freq to OS using the current functions entry
|
||||
|
@ -60,7 +60,8 @@ public:
|
||||
uint32_t getSumForBlock(const MachineBasicBlock *MBB, uint32_t &Scale) const;
|
||||
|
||||
// A 'Hot' edge is an edge which probability is >= 80%.
|
||||
bool isEdgeHot(MachineBasicBlock *Src, MachineBasicBlock *Dst) const;
|
||||
bool isEdgeHot(const MachineBasicBlock *Src,
|
||||
const MachineBasicBlock *Dst) const;
|
||||
|
||||
// Return a hot successor for the block BB or null if there isn't one.
|
||||
// NB: This routine's complexity is linear on the number of successors.
|
||||
@ -72,14 +73,15 @@ public:
|
||||
// NB: This routine's complexity is linear on the number of successors of
|
||||
// Src. Querying sequentially for each successor's probability is a quadratic
|
||||
// query pattern.
|
||||
BranchProbability getEdgeProbability(MachineBasicBlock *Src,
|
||||
MachineBasicBlock *Dst) const;
|
||||
BranchProbability getEdgeProbability(const MachineBasicBlock *Src,
|
||||
const MachineBasicBlock *Dst) const;
|
||||
|
||||
// Print value between 0 (0% probability) and 1 (100% probability),
|
||||
// however the value is never equal to 0, and can be 1 only iff SRC block
|
||||
// has only one successor.
|
||||
raw_ostream &printEdgeProbability(raw_ostream &OS, MachineBasicBlock *Src,
|
||||
MachineBasicBlock *Dst) const;
|
||||
raw_ostream &printEdgeProbability(raw_ostream &OS,
|
||||
const MachineBasicBlock *Src,
|
||||
const MachineBasicBlock *Dst) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ getBlockFreq(const MachineBasicBlock *MBB) const {
|
||||
return MBFI->getBlockFreq(MBB);
|
||||
}
|
||||
|
||||
MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
|
||||
const MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
|
||||
return MBFI->Fn;
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,9 @@ getEdgeWeight(const MachineBasicBlock *Src,
|
||||
return getEdgeWeight(Src, std::find(Src->succ_begin(), Src->succ_end(), Dst));
|
||||
}
|
||||
|
||||
bool MachineBranchProbabilityInfo::isEdgeHot(MachineBasicBlock *Src,
|
||||
MachineBasicBlock *Dst) const {
|
||||
bool
|
||||
MachineBranchProbabilityInfo::isEdgeHot(const MachineBasicBlock *Src,
|
||||
const MachineBasicBlock *Dst) const {
|
||||
// Hot probability is at least 4/5 = 80%
|
||||
// FIXME: Compare against a static "hot" BranchProbability.
|
||||
return getEdgeProbability(Src, Dst) > BranchProbability(4, 5);
|
||||
@ -103,9 +104,8 @@ MachineBranchProbabilityInfo::getHotSucc(MachineBasicBlock *MBB) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BranchProbability
|
||||
MachineBranchProbabilityInfo::getEdgeProbability(MachineBasicBlock *Src,
|
||||
MachineBasicBlock *Dst) const {
|
||||
BranchProbability MachineBranchProbabilityInfo::getEdgeProbability(
|
||||
const MachineBasicBlock *Src, const MachineBasicBlock *Dst) const {
|
||||
uint32_t Scale = 1;
|
||||
uint32_t D = getSumForBlock(Src, Scale);
|
||||
uint32_t N = getEdgeWeight(Src, Dst) / Scale;
|
||||
@ -113,13 +113,13 @@ MachineBranchProbabilityInfo::getEdgeProbability(MachineBasicBlock *Src,
|
||||
return BranchProbability(N, D);
|
||||
}
|
||||
|
||||
raw_ostream &MachineBranchProbabilityInfo::
|
||||
printEdgeProbability(raw_ostream &OS, MachineBasicBlock *Src,
|
||||
MachineBasicBlock *Dst) const {
|
||||
raw_ostream &MachineBranchProbabilityInfo::printEdgeProbability(
|
||||
raw_ostream &OS, const MachineBasicBlock *Src,
|
||||
const MachineBasicBlock *Dst) const {
|
||||
|
||||
const BranchProbability Prob = getEdgeProbability(Src, Dst);
|
||||
OS << "edge MBB#" << Src->getNumber() << " -> MBB#" << Dst->getNumber()
|
||||
<< " probability is " << Prob
|
||||
<< " probability is " << Prob
|
||||
<< (isEdgeHot(Src, Dst) ? " [HOT edge]\n" : "\n");
|
||||
|
||||
return OS;
|
||||
|
Loading…
Reference in New Issue
Block a user