diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-25 18:01:38 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-03-25 18:01:38 +0000 |
commit | 27e1ca8189e0c566092dd165903d0cf3f89f16a3 (patch) | |
tree | 5df62d3b7e607781055049cefae5a5bc6e7b6bf2 /lib/CodeGen/MachineBlockFrequencyInfo.cpp | |
parent | 8451e1baa9fa3921c7820d7f279fcebd5581b01d (diff) | |
download | llvm-27e1ca8189e0c566092dd165903d0cf3f89f16a3.tar.gz llvm-27e1ca8189e0c566092dd165903d0cf3f89f16a3.tar.bz2 llvm-27e1ca8189e0c566092dd165903d0cf3f89f16a3.tar.xz |
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
Diffstat (limited to 'lib/CodeGen/MachineBlockFrequencyInfo.cpp')
-rw-r--r-- | lib/CodeGen/MachineBlockFrequencyInfo.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/lib/CodeGen/MachineBlockFrequencyInfo.cpp index efb0664833..13203d55c4 100644 --- a/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -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; } |