1 //===- ProfileInfoLoaderPass.cpp - LLVM Pass to load profile info ---------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements a concrete implementation of profiling information that
11 // loads the information from a profile dump file.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Pass.h"
16 #include "llvm/Analysis/ProfileInfo.h"
17 #include "llvm/Analysis/ProfileInfoLoader.h"
21 class LoaderPass : public Pass, public ProfileInfo {
24 LoaderPass(const std::string &filename = "llvmprof.out")
25 : Filename(filename) {}
27 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
31 virtual const char *getPassName() const {
32 return "Profiling information loader";
35 /// run - Load the profile information from the specified file.
36 virtual bool run(Module &M);
38 unsigned getExecutionCount(BasicBlock *BB) { return 0; }
41 RegisterOpt<LoaderPass>
42 X("profile-loader", "Load profile information from llvmprof.out");
44 RegisterAnalysisGroup<ProfileInfo, LoaderPass> Y;
45 } // End of anonymous namespace
48 /// createProfileLoaderPass - This function returns a Pass that loads the
49 /// profiling information for the module from the specified filename, making it
50 /// available to the optimizers.
51 Pass *llvm::createProfileLoaderPass(const std::string &Filename) {
52 return new LoaderPass(Filename);
55 bool LoaderPass::run(Module &M) {