diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-08-08 17:43:09 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-08 17:43:09 +0000 |
| commit | 3b5008e23abb2f6fbe85e32670a5437dc3b05a93 (patch) | |
| tree | b5d5fe3856941bfffa31d26ab43c2d9a473c6b2b /llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp | |
| parent | 72dd2eef36d04cff7d3941bb4f4822b4ffee86b2 (diff) | |
| download | llvm-3b5008e23abb2f6fbe85e32670a5437dc3b05a93.zip llvm-3b5008e23abb2f6fbe85e32670a5437dc3b05a93.tar.gz llvm-3b5008e23abb2f6fbe85e32670a5437dc3b05a93.tar.bz2 | |
More ProfileInfo improvements.
- Part of optimal static profiling patch sequence by Andreas Neustifter.
- Store edge, block, and function information separately for each functions
(instead of in one giant map).
- Return frequencies as double instead of int, and use a sentinel value for
missing information.
llvm-svn: 78477
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp index f291b44..283f863 100644 --- a/llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp +++ b/llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp @@ -55,7 +55,10 @@ bool EdgeProfiler::runOnModule(Module &M) { std::set<BasicBlock*> BlocksToInstrument; unsigned NumEdges = 0; - 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; + // Reserve space for (0,entry) edge. + ++NumEdges; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { // Keep track of which blocks need to be instrumented. We don't want to // instrument blocks that are added as the result of breaking critical @@ -63,6 +66,7 @@ bool EdgeProfiler::runOnModule(Module &M) { BlocksToInstrument.insert(BB); NumEdges += BB->getTerminator()->getNumSuccessors(); } + } const Type *ATy = ArrayType::get(Type::Int32Ty, NumEdges); GlobalVariable *Counters = @@ -71,7 +75,10 @@ bool EdgeProfiler::runOnModule(Module &M) { // Instrument all of the edges... unsigned i = 0; - 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; + // Create counter for (0,entry) edge. + IncrementCounterInBlock(&F->getEntryBlock(), i++, Counters); for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) if (BlocksToInstrument.count(BB)) { // Don't instrument inserted blocks // Okay, we have to add a counter of each outgoing edge. If the @@ -94,6 +101,7 @@ bool EdgeProfiler::runOnModule(Module &M) { } } } + } // Add the initialization call to main. InsertProfilingInitCall(Main, "llvm_start_edge_profiling", Counters); |
