aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ProfileInfoLoaderPass.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-03-08 22:04:08 +0000
committerChris Lattner <sabre@nondot.org>2004-03-08 22:04:08 +0000
commit96ab5caf2db23939c21c36d9468fa6c95e23129d (patch)
treeb03e785eb8b0154a88673947698e2dbf5c5c29c4 /lib/Analysis/ProfileInfoLoaderPass.cpp
parent7d84dda56044b9731aea613a26ff98c8ceb3b5f9 (diff)
Switch to using edge profiling information as the basic source of profile info
from using basic block counts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12242 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ProfileInfoLoaderPass.cpp')
-rw-r--r--lib/Analysis/ProfileInfoLoaderPass.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp
index c1ff8cf563..b32dcc406a 100644
--- a/lib/Analysis/ProfileInfoLoaderPass.cpp
+++ b/lib/Analysis/ProfileInfoLoaderPass.cpp
@@ -12,6 +12,8 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/BasicBlock.h"
+#include "llvm/InstrTypes.h"
#include "llvm/Pass.h"
#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Analysis/ProfileInfoLoader.h"
@@ -60,11 +62,25 @@ Pass *llvm::createProfileLoaderPass(const std::string &Filename) {
bool LoaderPass::run(Module &M) {
ProfileInfoLoader PIL("profile-loader", Filename, M);
- ExecutionCounts.clear();
- if (PIL.hasAccurateBlockCounts()) {
- std::vector<std::pair<BasicBlock*, unsigned> > Counts;
- PIL.getBlockCounts(Counts);
- ExecutionCounts.insert(Counts.begin(), Counts.end());
+ 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) {
+ std::cerr << "WARNING: profile information is inconsistent with "
+ << "the current program!\n";
+ PrintedWarning = true;
+ }
+ } else {
+ EdgeCounts[std::make_pair(BB, TI->getSuccessor(SuccNum))]+= ECs[i].second;
+ }
}
+
return false;
}