mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
Refactor implementations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12240 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -29,9 +29,7 @@ ProfileInfo::~ProfileInfo() {}
|
|||||||
//
|
//
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct NoProfileInfo : public ImmutablePass, public ProfileInfo {
|
struct NoProfileInfo : public ImmutablePass, public ProfileInfo {};
|
||||||
unsigned getExecutionCount(BasicBlock *BB) { return 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// Register this pass...
|
// Register this pass...
|
||||||
RegisterOpt<NoProfileInfo>
|
RegisterOpt<NoProfileInfo>
|
||||||
|
@@ -26,7 +26,6 @@ namespace {
|
|||||||
|
|
||||||
class LoaderPass : public Pass, public ProfileInfo {
|
class LoaderPass : public Pass, public ProfileInfo {
|
||||||
std::string Filename;
|
std::string Filename;
|
||||||
std::map<BasicBlock*, unsigned> ExecutionCounts;
|
|
||||||
public:
|
public:
|
||||||
LoaderPass(const std::string &filename = "")
|
LoaderPass(const std::string &filename = "")
|
||||||
: Filename(filename) {
|
: Filename(filename) {
|
||||||
@@ -43,11 +42,6 @@ namespace {
|
|||||||
|
|
||||||
/// run - Load the profile information from the specified file.
|
/// run - Load the profile information from the specified file.
|
||||||
virtual bool run(Module &M);
|
virtual bool run(Module &M);
|
||||||
|
|
||||||
virtual unsigned getExecutionCount(BasicBlock *BB) {
|
|
||||||
std::map<BasicBlock*, unsigned>::iterator I = ExecutionCounts.find(BB);
|
|
||||||
return I != ExecutionCounts.end() ? I->second : 0;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
RegisterOpt<LoaderPass>
|
RegisterOpt<LoaderPass>
|
||||||
@@ -65,7 +59,8 @@ Pass *llvm::createProfileLoaderPass(const std::string &Filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool LoaderPass::run(Module &M) {
|
bool LoaderPass::run(Module &M) {
|
||||||
ProfileInfoLoader PIL("opt", Filename, M);
|
ProfileInfoLoader PIL("profile-loader", Filename, M);
|
||||||
|
ExecutionCounts.clear();
|
||||||
if (PIL.hasAccurateBlockCounts()) {
|
if (PIL.hasAccurateBlockCounts()) {
|
||||||
std::vector<std::pair<BasicBlock*, unsigned> > Counts;
|
std::vector<std::pair<BasicBlock*, unsigned> > Counts;
|
||||||
PIL.getBlockCounts(Counts);
|
PIL.getBlockCounts(Counts);
|
||||||
|
Reference in New Issue
Block a user