diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-08-05 15:55:56 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-05 15:55:56 +0000 |
| commit | b6fec3842615dc641e2ebec145f33894de5344c9 (patch) | |
| tree | 6d72adb3d412620039847673ac5b1b8bb9745ccc /llvm/lib/Analysis/ProfileInfoLoaderPass.cpp | |
| parent | 63c5ede173932531fba6232ab73c79d49af94270 (diff) | |
| download | bcm5719-llvm-b6fec3842615dc641e2ebec145f33894de5344c9.tar.gz bcm5719-llvm-b6fec3842615dc641e2ebec145f33894de5344c9.zip | |
Remove unnecessary ProfileInfoLoader methods.
- Part of optimal static profiling patch sequence by Andreas Neustifter.
llvm-svn: 78199
Diffstat (limited to 'llvm/lib/Analysis/ProfileInfoLoaderPass.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ProfileInfoLoaderPass.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/llvm/lib/Analysis/ProfileInfoLoaderPass.cpp b/llvm/lib/Analysis/ProfileInfoLoaderPass.cpp index 0a8a87bd0f9..2d9c8b99625 100644 --- a/llvm/lib/Analysis/ProfileInfoLoaderPass.cpp +++ b/llvm/lib/Analysis/ProfileInfoLoaderPass.cpp @@ -14,6 +14,7 @@ #include "llvm/BasicBlock.h" #include "llvm/InstrTypes.h" +#include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/ProfileInfo.h" @@ -69,23 +70,25 @@ Pass *llvm::createProfileLoaderPass(const std::string &Filename) { bool LoaderPass::runOnModule(Module &M) { ProfileInfoLoader PIL("profile-loader", Filename, M); EdgeCounts.clear(); - bool PrintedWarning = false; - std::vector<std::pair<ProfileInfoLoader::Edge, unsigned> > ECs; - PIL.getEdgeCounts(ECs); - for (unsigned i = 0, e = ECs.size(); i != e; ++i) { - BasicBlock *BB = ECs[i].first.first; - unsigned SuccNum = ECs[i].first.second; - TerminatorInst *TI = BB->getTerminator(); - if (SuccNum >= TI->getNumSuccessors()) { - if (!PrintedWarning) { - cerr << "WARNING: profile information is inconsistent with " - << "the current program!\n"; - PrintedWarning = true; + std::vector<unsigned> ECs = PIL.getRawEdgeCounts(); + // Instrument all of the edges... + unsigned i = 0; + for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) + 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 + // outgoing edge is not critical don't split it, just insert the counter + // in the source or destination of the edge. + TerminatorInst *TI = BB->getTerminator(); + for (unsigned s = 0, e = TI->getNumSuccessors(); s != e; ++s) { + if (i < ECs.size()) + EdgeCounts[std::make_pair(BB, TI->getSuccessor(s))]+= ECs[i++]; } - } else { - EdgeCounts[std::make_pair(BB, TI->getSuccessor(SuccNum))]+= ECs[i].second; } + + if (i != ECs.size()) { + cerr << "WARNING: profile information is inconsistent with " + << "the current program!\n"; } return false; |

