aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/ProfileInfoLoaderPass.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-02-11 18:21:05 +0000
committerChris Lattner <sabre@nondot.org>2004-02-11 18:21:05 +0000
commit945871df86c4e5e0a12c58f6e12edbd09c813310 (patch)
treefb79862120e7e57c180d43267095f419a32761c5 /lib/Analysis/ProfileInfoLoaderPass.cpp
parentc6fca42a66490dc01b3c79350ab288732df4c855 (diff)
Actually load profiling information now! Block layout can use real, live,
actual profile info, and works! :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11324 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ProfileInfoLoaderPass.cpp')
-rw-r--r--lib/Analysis/ProfileInfoLoaderPass.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp
index 854cc3c6d5..be95669879 100644
--- a/lib/Analysis/ProfileInfoLoaderPass.cpp
+++ b/lib/Analysis/ProfileInfoLoaderPass.cpp
@@ -15,14 +15,22 @@
#include "llvm/Pass.h"
#include "llvm/Analysis/ProfileInfo.h"
#include "llvm/Analysis/ProfileInfoLoader.h"
+#include "Support/CommandLine.h"
using namespace llvm;
namespace {
+ cl::opt<std::string>
+ ProfileInfoFilename("profile-info-file", cl::init("llvmprof.out"),
+ cl::desc(""));
+
class LoaderPass : public Pass, public ProfileInfo {
std::string Filename;
+ std::map<BasicBlock*, unsigned> ExecutionCounts;
public:
- LoaderPass(const std::string &filename = "llvmprof.out")
- : Filename(filename) {}
+ LoaderPass(const std::string &filename = "")
+ : Filename(filename) {
+ if (filename.empty()) Filename = ProfileInfoFilename;
+ }
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
@@ -35,7 +43,10 @@ namespace {
/// run - Load the profile information from the specified file.
virtual bool run(Module &M);
- unsigned getExecutionCount(BasicBlock *BB) { return 0; }
+ virtual unsigned getExecutionCount(BasicBlock *BB) {
+ std::map<BasicBlock*, unsigned>::iterator I = ExecutionCounts.find(BB);
+ return I != ExecutionCounts.end() ? I->second : 0;
+ }
};
RegisterOpt<LoaderPass>
@@ -53,6 +64,11 @@ Pass *llvm::createProfileLoaderPass(const std::string &Filename) {
}
bool LoaderPass::run(Module &M) {
-
+ ProfileInfoLoader PIL("opt", Filename, M);
+ if (PIL.hasAccurateBlockCounts()) {
+ std::vector<std::pair<BasicBlock*, unsigned> > Counts;
+ PIL.getBlockCounts(Counts);
+ ExecutionCounts.insert(Counts.begin(), Counts.end());
+ }
return false;
}