forked from OSchip/llvm-project
Some ProfileInfo cleanups.
- Part of optimal static profiling patch sequence by Andreas Neustifter. llvm-svn: 78485
This commit is contained in:
parent
003a1b1c1d
commit
2f140834cf
|
@ -229,7 +229,7 @@ public:
|
||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I))
|
if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I))
|
||||||
// Not in current loop? It must be an exit block.
|
// 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.
|
/// getUniqueExitBlocks - Return all unique successor blocks of this loop.
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace llvm {
|
||||||
|
|
||||||
// getEdge() - Creates an Edge from two BasicBlocks.
|
// getEdge() - Creates an Edge from two BasicBlocks.
|
||||||
static Edge getEdge(const BasicBlock* Src, const BasicBlock* Dest) {
|
static Edge getEdge(const BasicBlock* Src, const BasicBlock* Dest) {
|
||||||
return std::make_pair(Src,Dest);
|
return std::make_pair(Src, Dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
|
|
|
@ -64,6 +64,7 @@ double ProfileInfo::getExecutionCount(const BasicBlock *BB) {
|
||||||
}
|
}
|
||||||
|
|
||||||
double ProfileInfo::getExecutionCount(const Function *F) {
|
double ProfileInfo::getExecutionCount(const Function *F) {
|
||||||
|
if (F->isDeclaration()) return MissingValue;
|
||||||
std::map<const Function*, double>::iterator J =
|
std::map<const Function*, double>::iterator J =
|
||||||
FunctionInformation.find(F);
|
FunctionInformation.find(F);
|
||||||
if (J != FunctionInformation.end())
|
if (J != FunctionInformation.end())
|
||||||
|
|
|
@ -77,7 +77,7 @@ bool LoaderPass::runOnModule(Module &M) {
|
||||||
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
|
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
|
||||||
if (F->isDeclaration()) continue;
|
if (F->isDeclaration()) continue;
|
||||||
if (ei < ECs.size())
|
if (ei < ECs.size())
|
||||||
EdgeInformation[F][ProfileInfo::getEdge(0,&F->getEntryBlock())] +=
|
EdgeInformation[F][ProfileInfo::getEdge(0, &F->getEntryBlock())] +=
|
||||||
ECs[ei++];
|
ECs[ei++];
|
||||||
for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) {
|
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
|
// Okay, we have to add a counter of each outgoing edge. If the
|
||||||
|
|
|
@ -78,24 +78,22 @@ namespace {
|
||||||
ProfileAnnotator(ProfileInfo& pi) : PI(pi) {}
|
ProfileAnnotator(ProfileInfo& pi) : PI(pi) {}
|
||||||
|
|
||||||
virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {
|
virtual void emitFunctionAnnot(const Function *F, raw_ostream &OS) {
|
||||||
OS << ";;; %" << F->getName() << " called ";
|
|
||||||
double w = PI.getExecutionCount(F);
|
double w = PI.getExecutionCount(F);
|
||||||
if (w == ProfileInfo::MissingValue)
|
if (w != ProfileInfo::MissingValue) {
|
||||||
OS << "(no value)";
|
OS << ";;; %" << F->getName() << " called "<<(unsigned)w
|
||||||
else
|
<<" times.\n;;;\n";
|
||||||
OS << (unsigned)w;
|
}
|
||||||
OS << " times.\n;;;\n";
|
|
||||||
}
|
}
|
||||||
virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
|
virtual void emitBasicBlockStartAnnot(const BasicBlock *BB,
|
||||||
raw_ostream &OS) {
|
raw_ostream &OS) {
|
||||||
double w = PI.getExecutionCount(BB);
|
double w = PI.getExecutionCount(BB);
|
||||||
if (w == ProfileInfo::MissingValue)
|
if (w != ProfileInfo::MissingValue) {
|
||||||
OS << "\t;;; (no value)\n";
|
if (w != 0) {
|
||||||
else
|
OS << "\t;;; Basic block executed " << (unsigned)w << " times.\n";
|
||||||
if (w != 0)
|
} else {
|
||||||
OS << "\t;;; Basic block executed " << w << " times.\n";
|
|
||||||
else
|
|
||||||
OS << "\t;;; Never executed!\n";
|
OS << "\t;;; Never executed!\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
|
virtual void emitBasicBlockEndAnnot(const BasicBlock *BB, raw_ostream &OS) {
|
||||||
|
@ -105,8 +103,9 @@ namespace {
|
||||||
const TerminatorInst *TI = BB->getTerminator();
|
const TerminatorInst *TI = BB->getTerminator();
|
||||||
for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) {
|
for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) {
|
||||||
BasicBlock* Succ = TI->getSuccessor(s);
|
BasicBlock* Succ = TI->getSuccessor(s);
|
||||||
double w = ignoreMissing(PI.getEdgeWeight(std::make_pair(BB,Succ)));
|
double w = ignoreMissing(PI.getEdgeWeight(std::make_pair(BB, Succ)));
|
||||||
SuccCounts.push_back(std::make_pair(std::make_pair(BB,Succ), w));
|
if (w != 0)
|
||||||
|
SuccCounts.push_back(std::make_pair(std::make_pair(BB, Succ), w));
|
||||||
}
|
}
|
||||||
if (!SuccCounts.empty()) {
|
if (!SuccCounts.empty()) {
|
||||||
OS << "\t;;; Out-edge counts:";
|
OS << "\t;;; Out-edge counts:";
|
||||||
|
@ -157,11 +156,11 @@ bool ProfileInfoPrinterPass::runOnModule(Module &M) {
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
|
for (Module::iterator FI = M.begin(), FE = M.end(); FI != FE; ++FI) {
|
||||||
if (FI->isDeclaration()) continue;
|
if (FI->isDeclaration()) continue;
|
||||||
double w = ignoreMissing(PI.getExecutionCount(FI));
|
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();
|
for (Function::iterator BB = FI->begin(), BBE = FI->end();
|
||||||
BB != BBE; ++BB) {
|
BB != BBE; ++BB) {
|
||||||
double w = ignoreMissing(PI.getExecutionCount(BB));
|
double w = ignoreMissing(PI.getExecutionCount(BB));
|
||||||
Counts.push_back(std::make_pair(BB,w));
|
Counts.push_back(std::make_pair(BB, w));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue