X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FMachineBlockFrequencyInfo.cpp;h=10b0e929f2bba04ef3c193a7fd9eec221587bea2;hb=9cb8e12ce13a21a3eb86af76d93423b6b11d86be;hp=efb0664833901dfc591f503c6bc4c114ca5b0c82;hpb=8451e1baa9fa3921c7820d7f279fcebd5581b01d;p=oota-llvm.git diff --git a/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/lib/CodeGen/MachineBlockFrequencyInfo.cpp index efb06648339..10b0e929f2b 100644 --- a/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -1,4 +1,4 @@ -//====------ MachineBlockFrequencyInfo.cpp - MBB Frequency Analysis ------====// +//===- MachineBlockFrequencyInfo.cpp - MBB Frequency Analysis -------------===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,10 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" -#include "llvm/Analysis/BlockFrequencyImpl.h" +#include "llvm/Analysis/BlockFrequencyInfoImpl.h" #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/InitializePasses.h" #include "llvm/Support/CommandLine.h" @@ -22,6 +24,8 @@ using namespace llvm; +#define DEBUG_TYPE "block-freq" + #ifndef NDEBUG enum GVDAGType { GVDT_None, @@ -112,6 +116,7 @@ struct DOTGraphTraits : INITIALIZE_PASS_BEGIN(MachineBlockFrequencyInfo, "machine-block-freq", "Machine Block Frequency Analysis", true, true) INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo) +INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) INITIALIZE_PASS_END(MachineBlockFrequencyInfo, "machine-block-freq", "Machine Block Frequency Analysis", true, true) @@ -121,24 +126,24 @@ char MachineBlockFrequencyInfo::ID = 0; MachineBlockFrequencyInfo:: MachineBlockFrequencyInfo() :MachineFunctionPass(ID) { initializeMachineBlockFrequencyInfoPass(*PassRegistry::getPassRegistry()); - MBFI = new BlockFrequencyImpl(); } -MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() { - delete MBFI; -} +MachineBlockFrequencyInfo::~MachineBlockFrequencyInfo() {} void MachineBlockFrequencyInfo::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); + AU.addRequired(); AU.setPreservesAll(); MachineFunctionPass::getAnalysisUsage(AU); } bool MachineBlockFrequencyInfo::runOnMachineFunction(MachineFunction &F) { MachineBranchProbabilityInfo &MBPI = - getAnalysis(); - MBFI->doFunction(&F, &MBPI); + getAnalysis(); + MachineLoopInfo &MLI = getAnalysis(); + if (!MBFI) + MBFI.reset(new ImplType); + MBFI->calculate(F, MBPI, MLI); #ifndef NDEBUG if (ViewMachineBlockFreqPropagationDAG != GVDT_None) { view(); @@ -147,6 +152,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 +169,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->getFunction() : 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; }