From 05e004f012485fb8c49b9d4f39d0e57b49f321b9 Mon Sep 17 00:00:00 2001 From: Xinliang David Li Date: Mon, 9 May 2016 21:37:12 +0000 Subject: [PATCH] Cleanup followup of r268710 - [PM] port IR based PGO prof-gen pass to new pass manager git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268974 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/PGOInstrumentation.h | 2 - .../Instrumentation/PGOInstrumentation.cpp | 51 +++++++++---------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/llvm/Transforms/PGOInstrumentation.h b/include/llvm/Transforms/PGOInstrumentation.h index dca5a089414..42f1e175b5b 100644 --- a/include/llvm/Transforms/PGOInstrumentation.h +++ b/include/llvm/Transforms/PGOInstrumentation.h @@ -24,8 +24,6 @@ namespace llvm { /// The instrumentation (profile-instr-gen) pass for IR based PGO. class PGOInstrumentationGen : public PassInfoMixin { public: - PGOInstrumentationGen() {} - PreservedAnalyses run(Module &M, AnalysisManager &AM); }; diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 5d52dc847d2..ef496840fab 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -116,7 +116,7 @@ class PGOInstrumentationGenLegacyPass : public ModulePass { public: static char ID; - PGOInstrumentationGenLegacyPass() : ModulePass(ID), PGOInstrGen() { + PGOInstrumentationGenLegacyPass() : ModulePass(ID) { initializePGOInstrumentationGenLegacyPassPass( *PassRegistry::getPassRegistry()); } @@ -126,7 +126,6 @@ public: } private: - PGOInstrumentationGen PGOInstrGen; bool runOnModule(Module &M) override; void getAnalysisUsage(AnalysisUsage &AU) const override { @@ -153,8 +152,8 @@ public: private: bool annotateAllFunctions( - Module &M, function_ref LookupBPI, - function_ref LookupBFI); + Module &M, function_ref LookupBPI, + function_ref LookupBFI); std::string ProfileFileName; std::unique_ptr PGOReader; bool runOnModule(Module &M) override; @@ -783,15 +782,15 @@ static void createIRLevelProfileFlagVariable(Module &M) { } static bool InstrumentAllFunctions( - Module &M, function_ref LookupBPI, - function_ref LookupBFI) { + Module &M, function_ref LookupBPI, + function_ref LookupBFI) { createIRLevelProfileFlagVariable(M); for (auto &F : M) { if (F.isDeclaration()) continue; - auto &BPI = LookupBPI(F); - auto &BFI = LookupBFI(F); - instrumentOneFunc(F, &M, &BPI, &BFI); + auto *BPI = LookupBPI(F); + auto *BFI = LookupBFI(F); + instrumentOneFunc(F, &M, BPI, BFI); } return true; } @@ -800,11 +799,11 @@ bool PGOInstrumentationGenLegacyPass::runOnModule(Module &M) { if (skipModule(M)) return false; - auto LookupBPI = [this](Function &F) -> BranchProbabilityInfo & { - return this->getAnalysis(F).getBPI(); + auto LookupBPI = [this](Function &F) { + return &this->getAnalysis(F).getBPI(); }; - auto LookupBFI = [this](Function &F) -> BlockFrequencyInfo & { - return this->getAnalysis(F).getBFI(); + auto LookupBFI = [this](Function &F) { + return &this->getAnalysis(F).getBFI(); }; return InstrumentAllFunctions(M, LookupBPI, LookupBFI); } @@ -813,12 +812,12 @@ PreservedAnalyses PGOInstrumentationGen::run(Module &M, AnalysisManager &AM) { auto &FAM = AM.getResult(M).getManager(); - auto LookupBPI = [&FAM](Function &F) -> BranchProbabilityInfo & { - return FAM.getResult(F); + auto LookupBPI = [&FAM](Function &F) { + return &FAM.getResult(F); }; - auto LookupBFI = [&FAM](Function &F) -> BlockFrequencyInfo & { - return FAM.getResult(F); + auto LookupBFI = [&FAM](Function &F) { + return &FAM.getResult(F); }; if (!InstrumentAllFunctions(M, LookupBPI, LookupBFI)) @@ -837,8 +836,8 @@ static void setPGOCountOnFunc(PGOUseFunc &Func, } bool PGOInstrumentationUseLegacyPass::annotateAllFunctions( - Module &M, function_ref LookupBPI, - function_ref LookupBFI) { + Module &M, function_ref LookupBPI, + function_ref LookupBFI) { DEBUG(dbgs() << "Read in profile counters: "); auto &Ctx = M.getContext(); // Read the counter array from file. @@ -867,9 +866,9 @@ bool PGOInstrumentationUseLegacyPass::annotateAllFunctions( for (auto &F : M) { if (F.isDeclaration()) continue; - auto &BPI = LookupBPI(F); - auto &BFI = LookupBFI(F); - PGOUseFunc Func(F, &M, &BPI, &BFI); + auto *BPI = LookupBPI(F); + auto *BFI = LookupBFI(F); + PGOUseFunc Func(F, &M, BPI, BFI); setPGOCountOnFunc(Func, PGOReader.get()); PGOUseFunc::FuncFreqAttr FreqAttr = Func.getFuncFreqAttr(); if (FreqAttr == PGOUseFunc::FFA_Cold) @@ -896,11 +895,11 @@ bool PGOInstrumentationUseLegacyPass::runOnModule(Module &M) { if (skipModule(M)) return false; - auto LookupBPI = [this](Function &F) -> BranchProbabilityInfo & { - return this->getAnalysis(F).getBPI(); + auto LookupBPI = [this](Function &F) { + return &this->getAnalysis(F).getBPI(); }; - auto LookupBFI = [this](Function &F) -> BlockFrequencyInfo & { - return this->getAnalysis(F).getBFI(); + auto LookupBFI = [this](Function &F) { + return &this->getAnalysis(F).getBFI(); }; return annotateAllFunctions(M, LookupBPI, LookupBFI); -- 2.50.1