aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/ProfileInfoLoaderPass.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-05 15:55:56 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-05 15:55:56 +0000
commitee16638bfc9c17068c4b3c2dc130277785a11e20 (patch)
tree6f48bff01b994b5e699c59ea2159f4a187a1da51 /lib/Analysis/ProfileInfoLoaderPass.cpp
parent96a0a02119c0e5a4bb49aa5563ec2ea238c5acb6 (diff)
downloadexternal_llvm-ee16638bfc9c17068c4b3c2dc130277785a11e20.tar.gz
external_llvm-ee16638bfc9c17068c4b3c2dc130277785a11e20.tar.bz2
external_llvm-ee16638bfc9c17068c4b3c2dc130277785a11e20.zip
Remove unnecessary ProfileInfoLoader methods.
- Part of optimal static profiling patch sequence by Andreas Neustifter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78199 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ProfileInfoLoaderPass.cpp')
-rw-r--r--lib/Analysis/ProfileInfoLoaderPass.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp
index 0a8a87bd0f..2d9c8b9962 100644
--- a/lib/Analysis/ProfileInfoLoaderPass.cpp
+++ b/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;