mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-27 22:26:31 +00:00
[BranchFolding] Replace MachineBlockFrequencyInfo with MBFIWrapper. NFC.
Differential Revision: http://reviews.llvm.org/D20184 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271923 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
36f2326b3f
commit
f15d24533e
@ -99,8 +99,9 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// HW that requires structurized CFG.
|
// HW that requires structurized CFG.
|
||||||
bool EnableTailMerge = !MF.getTarget().requiresStructuredCFG() &&
|
bool EnableTailMerge = !MF.getTarget().requiresStructuredCFG() &&
|
||||||
PassConfig->getEnableTailMerge();
|
PassConfig->getEnableTailMerge();
|
||||||
BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true,
|
BranchFolder::MBFIWrapper MBBFreqInfo(
|
||||||
getAnalysis<MachineBlockFrequencyInfo>(),
|
getAnalysis<MachineBlockFrequencyInfo>());
|
||||||
|
BranchFolder Folder(EnableTailMerge, /*CommonHoist=*/true, MBBFreqInfo,
|
||||||
getAnalysis<MachineBranchProbabilityInfo>());
|
getAnalysis<MachineBranchProbabilityInfo>());
|
||||||
return Folder.OptimizeFunction(MF, MF.getSubtarget().getInstrInfo(),
|
return Folder.OptimizeFunction(MF, MF.getSubtarget().getInstrInfo(),
|
||||||
MF.getSubtarget().getRegisterInfo(),
|
MF.getSubtarget().getRegisterInfo(),
|
||||||
@ -108,7 +109,7 @@ bool BranchFolderPass::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
|
BranchFolder::BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
|
||||||
const MachineBlockFrequencyInfo &FreqInfo,
|
MBFIWrapper &FreqInfo,
|
||||||
const MachineBranchProbabilityInfo &ProbInfo)
|
const MachineBranchProbabilityInfo &ProbInfo)
|
||||||
: EnableHoistCommonCode(CommonHoist), MBBFreqInfo(FreqInfo),
|
: EnableHoistCommonCode(CommonHoist), MBBFreqInfo(FreqInfo),
|
||||||
MBPI(ProbInfo) {
|
MBPI(ProbInfo) {
|
||||||
@ -540,6 +541,18 @@ void BranchFolder::MBFIWrapper::setBlockFreq(const MachineBasicBlock *MBB,
|
|||||||
MergedBBFreq[MBB] = F;
|
MergedBBFreq[MBB] = F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw_ostream &
|
||||||
|
BranchFolder::MBFIWrapper::printBlockFreq(raw_ostream &OS,
|
||||||
|
const MachineBasicBlock *MBB) const {
|
||||||
|
return MBFI.printBlockFreq(OS, getBlockFreq(MBB));
|
||||||
|
}
|
||||||
|
|
||||||
|
raw_ostream &
|
||||||
|
BranchFolder::MBFIWrapper::printBlockFreq(raw_ostream &OS,
|
||||||
|
const BlockFrequency Freq) const {
|
||||||
|
return MBFI.printBlockFreq(OS, Freq);
|
||||||
|
}
|
||||||
|
|
||||||
/// CountTerminators - Count the number of terminators in the given
|
/// CountTerminators - Count the number of terminators in the given
|
||||||
/// block and set I to the position of the first non-terminator, if there
|
/// block and set I to the position of the first non-terminator, if there
|
||||||
/// is one, or MBB->end() otherwise.
|
/// is one, or MBB->end() otherwise.
|
||||||
|
@ -26,8 +26,10 @@ namespace llvm {
|
|||||||
|
|
||||||
class LLVM_LIBRARY_VISIBILITY BranchFolder {
|
class LLVM_LIBRARY_VISIBILITY BranchFolder {
|
||||||
public:
|
public:
|
||||||
|
class MBFIWrapper;
|
||||||
|
|
||||||
explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
|
explicit BranchFolder(bool defaultEnableTailMerge, bool CommonHoist,
|
||||||
const MachineBlockFrequencyInfo &MBFI,
|
MBFIWrapper &MBFI,
|
||||||
const MachineBranchProbabilityInfo &MBPI);
|
const MachineBranchProbabilityInfo &MBPI);
|
||||||
|
|
||||||
bool OptimizeFunction(MachineFunction &MF,
|
bool OptimizeFunction(MachineFunction &MF,
|
||||||
@ -98,6 +100,7 @@ namespace llvm {
|
|||||||
MachineModuleInfo *MMI;
|
MachineModuleInfo *MMI;
|
||||||
RegScavenger *RS;
|
RegScavenger *RS;
|
||||||
|
|
||||||
|
public:
|
||||||
/// \brief This class keeps track of branch frequencies of newly created
|
/// \brief This class keeps track of branch frequencies of newly created
|
||||||
/// blocks and tail-merged blocks.
|
/// blocks and tail-merged blocks.
|
||||||
class MBFIWrapper {
|
class MBFIWrapper {
|
||||||
@ -105,13 +108,18 @@ namespace llvm {
|
|||||||
MBFIWrapper(const MachineBlockFrequencyInfo &I) : MBFI(I) {}
|
MBFIWrapper(const MachineBlockFrequencyInfo &I) : MBFI(I) {}
|
||||||
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const;
|
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const;
|
||||||
void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F);
|
void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F);
|
||||||
|
raw_ostream &printBlockFreq(raw_ostream &OS,
|
||||||
|
const MachineBasicBlock *MBB) const;
|
||||||
|
raw_ostream &printBlockFreq(raw_ostream &OS,
|
||||||
|
const BlockFrequency Freq) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const MachineBlockFrequencyInfo &MBFI;
|
const MachineBlockFrequencyInfo &MBFI;
|
||||||
DenseMap<const MachineBasicBlock *, BlockFrequency> MergedBBFreq;
|
DenseMap<const MachineBasicBlock *, BlockFrequency> MergedBBFreq;
|
||||||
};
|
};
|
||||||
|
|
||||||
MBFIWrapper MBBFreqInfo;
|
private:
|
||||||
|
MBFIWrapper &MBBFreqInfo;
|
||||||
const MachineBranchProbabilityInfo &MBPI;
|
const MachineBranchProbabilityInfo &MBPI;
|
||||||
|
|
||||||
bool TailMergeBlocks(MachineFunction &MF);
|
bool TailMergeBlocks(MachineFunction &MF);
|
||||||
|
@ -163,7 +163,6 @@ namespace {
|
|||||||
const TargetLoweringBase *TLI;
|
const TargetLoweringBase *TLI;
|
||||||
const TargetInstrInfo *TII;
|
const TargetInstrInfo *TII;
|
||||||
const TargetRegisterInfo *TRI;
|
const TargetRegisterInfo *TRI;
|
||||||
const MachineBlockFrequencyInfo *MBFI;
|
|
||||||
const MachineBranchProbabilityInfo *MBPI;
|
const MachineBranchProbabilityInfo *MBPI;
|
||||||
MachineRegisterInfo *MRI;
|
MachineRegisterInfo *MRI;
|
||||||
|
|
||||||
@ -291,7 +290,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
TLI = ST.getTargetLowering();
|
TLI = ST.getTargetLowering();
|
||||||
TII = ST.getInstrInfo();
|
TII = ST.getInstrInfo();
|
||||||
TRI = ST.getRegisterInfo();
|
TRI = ST.getRegisterInfo();
|
||||||
MBFI = &getAnalysis<MachineBlockFrequencyInfo>();
|
BranchFolder::MBFIWrapper MBFI(getAnalysis<MachineBlockFrequencyInfo>());
|
||||||
MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
|
MBPI = &getAnalysis<MachineBranchProbabilityInfo>();
|
||||||
MRI = &MF.getRegInfo();
|
MRI = &MF.getRegInfo();
|
||||||
SchedModel.init(ST.getSchedModel(), &ST, TII);
|
SchedModel.init(ST.getSchedModel(), &ST, TII);
|
||||||
@ -303,7 +302,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
bool BFChange = false;
|
bool BFChange = false;
|
||||||
if (!PreRegAlloc) {
|
if (!PreRegAlloc) {
|
||||||
// Tail merge tend to expose more if-conversion opportunities.
|
// Tail merge tend to expose more if-conversion opportunities.
|
||||||
BranchFolder BF(true, false, *MBFI, *MBPI);
|
BranchFolder BF(true, false, MBFI, *MBPI);
|
||||||
BFChange = BF.OptimizeFunction(MF, TII, ST.getRegisterInfo(),
|
BFChange = BF.OptimizeFunction(MF, TII, ST.getRegisterInfo(),
|
||||||
getAnalysisIfAvailable<MachineModuleInfo>());
|
getAnalysisIfAvailable<MachineModuleInfo>());
|
||||||
}
|
}
|
||||||
@ -427,7 +426,7 @@ bool IfConverter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
BBAnalysis.clear();
|
BBAnalysis.clear();
|
||||||
|
|
||||||
if (MadeChange && IfCvtBranchFold) {
|
if (MadeChange && IfCvtBranchFold) {
|
||||||
BranchFolder BF(false, false, *MBFI, *MBPI);
|
BranchFolder BF(false, false, MBFI, *MBPI);
|
||||||
BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(),
|
BF.OptimizeFunction(MF, TII, MF.getSubtarget().getRegisterInfo(),
|
||||||
getAnalysisIfAvailable<MachineModuleInfo>());
|
getAnalysisIfAvailable<MachineModuleInfo>());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user