X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FProfileInfo.cpp;h=36f211e858d2325c0c9b1b28d3eb90cd911097ec;hb=38f7f66fcc6ed5e43be4d9c96c782d4eabdb7342;hp=662576e1d0a4ff2ae554479ebf47f5aaf15f215a;hpb=44424646ac9db5c4d3919462bd0831ec22783085;p=oota-llvm.git diff --git a/lib/Analysis/ProfileInfo.cpp b/lib/Analysis/ProfileInfo.cpp index 662576e1d0a..36f211e858d 100644 --- a/lib/Analysis/ProfileInfo.cpp +++ b/lib/Analysis/ProfileInfo.cpp @@ -24,8 +24,12 @@ #include using namespace llvm; +namespace llvm { + template<> char ProfileInfoT::ID = 0; +} + // Register the ProfileInfo interface, providing a nice name to refer to. -static RegisterAnalysisGroup Z("Profile Information"); +INITIALIZE_ANALYSIS_GROUP(ProfileInfo, "Profile Information", NoProfileInfo) namespace llvm { @@ -43,9 +47,6 @@ ProfileInfoT::~ProfileInfoT() { if (MachineProfile) delete MachineProfile; } -template<> -char ProfileInfoT::ID = 0; - template<> char ProfileInfoT::ID = 0; @@ -71,22 +72,24 @@ ProfileInfoT::getExecutionCount(const BasicBlock *BB) { // Are there zero predecessors of this block? if (PI == PE) { - Edge e = getEdge(0,BB); + Edge e = getEdge(0, BB); Count = getEdgeWeight(e); } else { // Otherwise, if there are predecessors, the execution count of this block is // the sum of the edge frequencies from the incoming edges. std::set ProcessedPreds; Count = 0; - for (; PI != PE; ++PI) - if (ProcessedPreds.insert(*PI).second) { - double w = getEdgeWeight(getEdge(*PI, BB)); + for (; PI != PE; ++PI) { + const BasicBlock *P = *PI; + if (ProcessedPreds.insert(P).second) { + double w = getEdgeWeight(getEdge(P, BB)); if (w == MissingValue) { Count = MissingValue; break; } Count += w; } + } } // If the predecessors did not suffice to get block weight, try successors. @@ -577,8 +580,6 @@ static void readEdge(ProfileInfo *PI, ProfileInfo::Edge e, double &calcw, std::s template<> bool ProfileInfoT::EstimateMissingEdges(const BasicBlock *BB) { - bool hasNoSuccessors = false; - double inWeight = 0; std::set inMissing; std::set ProcessedPreds; @@ -596,10 +597,8 @@ bool ProfileInfoT::EstimateMissingEdges(const BasicBlock *B std::set outMissing; std::set ProcessedSuccs; succ_const_iterator sbbi = succ_begin(BB), sbbe = succ_end(BB); - if (sbbi == sbbe) { + if (sbbi == sbbe) readEdge(this,getEdge(BB,0),outWeight,outMissing); - hasNoSuccessors = true; - } for ( ; sbbi != sbbe; ++sbbi ) { if (ProcessedSuccs.insert(*sbbi).second) { readEdge(this,getEdge(BB,*sbbi),outWeight,outMissing); @@ -890,7 +889,7 @@ void ProfileInfoT::repair(const Function *F) { FI = Unvisited.begin(), FE = Unvisited.end(); while(FI != FE && !FoundPath) { const BasicBlock *BB = *FI; ++FI; - const BasicBlock *Dest; + const BasicBlock *Dest = 0; Path P; bool BackEdgeFound = false; for (const_pred_iterator NBB = pred_begin(BB), End = pred_end(BB); @@ -1078,14 +1077,16 @@ raw_ostream& operator<<(raw_ostream &O, std::pairisPassID(&ProfileInfo::ID)) + virtual void *getAdjustedAnalysisPointer(AnalysisID PI) { + if (PI == &ProfileInfo::ID) return (ProfileInfo*)this; return this; } @@ -1098,10 +1099,7 @@ namespace { char NoProfileInfo::ID = 0; // Register this pass... -static RegisterPass -X("no-profile", "No Profile Information", false, true); - -// Declare that we implement the ProfileInfo interface -static RegisterAnalysisGroup Y(X); +INITIALIZE_AG_PASS(NoProfileInfo, ProfileInfo, "no-profile", + "No Profile Information", false, true, true) ImmutablePass *llvm::createNoProfileInfoPass() { return new NoProfileInfo(); }