[llvm-commits] [llvm] r78485 - in /llvm/trunk: include/llvm/Analysis/LoopInfo.h include/llvm/Analysis/ProfileInfo.h lib/Analysis/ProfileInfo.cpp lib/Analysis/ProfileInfoLoaderPass.cpp tools/llvm-prof/llvm-prof.cpp
Daniel Dunbar
daniel at zuster.org
Sat Aug 8 11:59:04 PDT 2009
Author: ddunbar
Date: Sat Aug 8 13:59:03 2009
New Revision: 78485
URL: http://llvm.org/viewvc/llvm-project?rev=78485&view=rev
Log:
Some ProfileInfo cleanups.
- Part of optimal static profiling patch sequence by Andreas Neustifter.
Modified:
llvm/trunk/include/llvm/Analysis/LoopInfo.h
llvm/trunk/include/llvm/Analysis/ProfileInfo.h
llvm/trunk/lib/Analysis/ProfileInfo.cpp
llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp
llvm/trunk/tools/llvm-prof/llvm-prof.cpp
Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=78485&r1=78484&r2=78485&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Sat Aug 8 13:59:03 2009
@@ -229,7 +229,7 @@
I != E; ++I)
if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I))
// Not in current loop? It must be an exit block.
- ExitEdges.push_back(std::make_pair(*BI,*I));
+ ExitEdges.push_back(std::make_pair(*BI, *I));
}
/// getUniqueExitBlocks - Return all unique successor blocks of this loop.
Modified: llvm/trunk/include/llvm/Analysis/ProfileInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ProfileInfo.h?rev=78485&r1=78484&r2=78485&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ProfileInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/ProfileInfo.h Sat Aug 8 13:59:03 2009
@@ -67,7 +67,7 @@
// getEdge() - Creates an Edge from two BasicBlocks.
static Edge getEdge(const BasicBlock* Src, const BasicBlock* Dest) {
- return std::make_pair(Src,Dest);
+ return std::make_pair(Src, Dest);
}
//===------------------------------------------------------------------===//
Modified: llvm/trunk/lib/Analysis/ProfileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfo.cpp?rev=78485&r1=78484&r2=78485&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileInfo.cpp Sat Aug 8 13:59:03 2009
@@ -64,6 +64,7 @@
}
double ProfileInfo::getExecutionCount(const Function *F) {
+ if (F->isDeclaration()) return MissingValue;
std::map<const Function*, double>::iterator J =
FunctionInformation.find(F);
if (J != FunctionInformation.end())
Modified: llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp?rev=78485&r1=78484&r2=78485&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp (original)
+++ llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp Sat Aug 8 13:59:03 2009
@@ -77,7 +77,7 @@
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
if (F->isDeclaration()) continue;
if (ei < ECs.size())
- EdgeInformation[F][ProfileInfo::getEdge(0,&F->getEntryBlock())] +=
+ EdgeInformation[F][ProfileInfo::getEdge(0, &F->getEntryBlock())] +=
ECs[ei++];
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
// Okay, we have to add a counter of each outgoing edge. If the
Modified: llvm/trunk/tools/llvm-prof/llvm-prof.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-prof/llvm-prof.cpp?rev=78485&r1=78484&r2=78485&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-prof/llvm-prof.cpp (original)
+++ llvm/trunk/tools/llvm-prof/llvm-prof.cpp Sat Aug 8 13:59:03 2009
@@ -78,24 +78,22 @@
ProfileAnnotator(ProfileInfo& pi) : PI(pi) {}
virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {
- OS << ";;; %" << F->getName() << " called ";
double w = PI.getExecutionCount(F);
- if (w == ProfileInfo::MissingValue)
- OS << "(no value)";
- else
- OS << (unsigned)w;
- OS << " times.\n;;;\n";
+ if (w != ProfileInfo::MissingValue) {
+ OS << ";;; %" << F->getName() << " called "<<(unsigned)w
+ <<" times.\n;;;\n";
+ }
}
virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
raw_ostream &OS) {
double w = PI.getExecutionCount(BB);
- if (w == ProfileInfo::MissingValue)
- OS << "\t;;; (no value)\n";
- else
- if (w != 0)
- OS << "\t;;; Basic block executed " << w << " times.\n";
- else
+ if (w != ProfileInfo::MissingValue) {
+ if (w != 0) {
+ OS << "\t;;; Basic block executed " << (unsigned)w << " times.\n";
+ } else {
OS << "\t;;; Never executed!\n";
+ }
+ }
}
virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
@@ -105,8 +103,9 @@
const TerminatorInst *TI = BB->getTerminator();
for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) {
BasicBlock* Succ = TI->getSuccessor(s);
- double w = ignoreMissing(PI.getEdgeWeight(std::make_pair(BB,Succ)));
- SuccCounts.push_back(std::make_pair(std::make_pair(BB,Succ), w));
+ double w = ignoreMissing(PI.getEdgeWeight(std::make_pair(BB, Succ)));
+ if (w != 0)
+ SuccCounts.push_back(std::make_pair(std::make_pair(BB, Succ), w));
}
if (!SuccCounts.empty()) {
OS << "\t;;; Out-edge counts:";
@@ -157,11 +156,11 @@
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
if (FI->isDeclaration()) continue;
double w = ignoreMissing(PI.getExecutionCount(FI));
- FunctionCounts.push_back(std::make_pair(FI,w));
+ FunctionCounts.push_back(std::make_pair(FI, w));
for (Function::iterator BB = FI->begin(), BBE = FI->end();
BB != BBE; ++BB) {
double w = ignoreMissing(PI.getExecutionCount(BB));
- Counts.push_back(std::make_pair(BB,w));
+ Counts.push_back(std::make_pair(BB, w));
}
}
More information about the llvm-commits
mailing list