mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-25 21:18:19 +00:00
blockfreq: Implement Pass::releaseMemory()
Implement Pass::releaseMemory() in BlockFrequencyInfo and MachineBlockFrequencyInfo. Just delete the private implementation when not in use. Switch to a std::unique_ptr to make the logic more clear. <rdar://problem/14292693> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204741 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -121,13 +121,9 @@ char MachineBlockFrequencyInfo::ID = 0;
|
||||
MachineBlockFrequencyInfo::
|
||||
MachineBlockFrequencyInfo() :MachineFunctionPass(ID) {
|
||||
initializeMachineBlockFrequencyInfoPass(*PassRegistry::getPassRegistry());
|
||||
MBFI = new BlockFrequencyImpl<MachineBasicBlock, MachineFunction,
|
||||
MachineBranchProbabilityInfo>();
|
||||
}
|
||||
|
||||
MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() {
|
||||
delete MBFI;
|
||||
}
|
||||
MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() {}
|
||||
|
||||
void MachineBlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<MachineBranchProbabilityInfo>();
|
||||
@@ -138,6 +134,8 @@ void MachineBlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) {
|
||||
MachineBranchProbabilityInfo &MBPI =
|
||||
getAnalysis<MachineBranchProbabilityInfo>();
|
||||
if (!MBFI)
|
||||
MBFI.reset(new ImplType);
|
||||
MBFI->doFunction(&F, &MBPI);
|
||||
#ifndef NDEBUG
|
||||
if (ViewMachineBlockFreqPropagationDAG != GVDT_None) {
|
||||
@@ -147,6 +145,8 @@ bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void MachineBlockFrequencyInfo::releaseMemory() { MBFI.reset(); }
|
||||
|
||||
/// Pop up a ghostview window with the current block frequency propagation
|
||||
/// rendered using dot.
|
||||
void MachineBlockFrequencyInfo::view() const {
|
||||
@@ -162,25 +162,25 @@ void MachineBlockFrequencyInfo::view() const {
|
||||
|
||||
BlockFrequency MachineBlockFrequencyInfo::
|
||||
getBlockFreq(const MachineBasicBlock *MBB) const {
|
||||
return MBFI->getBlockFreq(MBB);
|
||||
return MBFI ? MBFI->getBlockFreq(MBB) : 0;
|
||||
}
|
||||
|
||||
const MachineFunction *MachineBlockFrequencyInfo::getFunction() const {
|
||||
return MBFI->Fn;
|
||||
return MBFI ? MBFI->Fn : nullptr;
|
||||
}
|
||||
|
||||
raw_ostream &
|
||||
MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS,
|
||||
const BlockFrequency Freq) const {
|
||||
return MBFI->printBlockFreq(OS, Freq);
|
||||
return MBFI ? MBFI->printBlockFreq(OS, Freq) : OS;
|
||||
}
|
||||
|
||||
raw_ostream &
|
||||
MachineBlockFrequencyInfo::printBlockFreq(raw_ostream &OS,
|
||||
const MachineBasicBlock *MBB) const {
|
||||
return MBFI->printBlockFreq(OS, MBB);
|
||||
return MBFI ? MBFI->printBlockFreq(OS, MBB) : OS;
|
||||
}
|
||||
|
||||
uint64_t MachineBlockFrequencyInfo::getEntryFreq() const {
|
||||
return MBFI->getEntryFreq();
|
||||
return MBFI ? MBFI->getEntryFreq() : 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user