[llvm] r268974 - Cleanup followup of r268710 - [PM] port IR based PGO prof-gen pass to new pass manager

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 14:37:12 PDT 2016


Author: davidxl
Date: Mon May  9 16:37:12 2016
New Revision: 268974

URL: http://llvm.org/viewvc/llvm-project?rev=268974&view=rev
Log:
Cleanup followup of r268710 - [PM] port IR based PGO prof-gen pass to new pass manager

Modified:
    llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h
    llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp

Modified: llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h?rev=268974&r1=268973&r2=268974&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h (original)
+++ llvm/trunk/include/llvm/Transforms/PGOInstrumentation.h Mon May  9 16:37:12 2016
@@ -24,8 +24,6 @@ namespace llvm {
 /// The instrumentation (profile-instr-gen) pass for IR based PGO.
 class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
 public:
-  PGOInstrumentationGen() {}
-
   PreservedAnalyses run(Module &M, AnalysisManager<Module> &AM);
 };
 

Modified: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp?rev=268974&r1=268973&r2=268974&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Mon May  9 16:37:12 2016
@@ -116,7 +116,7 @@ class PGOInstrumentationGenLegacyPass :
 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<BranchProbabilityInfo &(Function &)> LookupBPI,
-      function_ref<BlockFrequencyInfo &(Function &)> LookupBFI);
+      Module &M, function_ref<BranchProbabilityInfo *(Function &)> LookupBPI,
+      function_ref<BlockFrequencyInfo *(Function &)> LookupBFI);
   std::string ProfileFileName;
   std::unique_ptr<IndexedInstrProfReader> PGOReader;
   bool runOnModule(Module &M) override;
@@ -783,15 +782,15 @@ static void createIRLevelProfileFlagVari
 }
 
 static bool InstrumentAllFunctions(
-    Module &M, function_ref<BranchProbabilityInfo &(Function &)> LookupBPI,
-    function_ref<BlockFrequencyInfo &(Function &)> LookupBFI) {
+    Module &M, function_ref<BranchProbabilityInfo *(Function &)> LookupBPI,
+    function_ref<BlockFrequencyInfo *(Function &)> 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::ru
   if (skipModule(M))
     return false;
 
-  auto LookupBPI = [this](Function &F) -> BranchProbabilityInfo & {
-    return this->getAnalysis<BranchProbabilityInfoWrapperPass>(F).getBPI();
+  auto LookupBPI = [this](Function &F) {
+    return &this->getAnalysis<BranchProbabilityInfoWrapperPass>(F).getBPI();
   };
-  auto LookupBFI = [this](Function &F) -> BlockFrequencyInfo & {
-    return this->getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI();
+  auto LookupBFI = [this](Function &F) {
+    return &this->getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI();
   };
   return InstrumentAllFunctions(M, LookupBPI, LookupBFI);
 }
@@ -813,12 +812,12 @@ PreservedAnalyses PGOInstrumentationGen:
                                              AnalysisManager<Module> &AM) {
 
   auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
-  auto LookupBPI = [&FAM](Function &F) -> BranchProbabilityInfo & {
-    return FAM.getResult<BranchProbabilityAnalysis>(F);
+  auto LookupBPI = [&FAM](Function &F) {
+    return &FAM.getResult<BranchProbabilityAnalysis>(F);
   };
 
-  auto LookupBFI = [&FAM](Function &F) -> BlockFrequencyInfo & {
-    return FAM.getResult<BlockFrequencyAnalysis>(F);
+  auto LookupBFI = [&FAM](Function &F) {
+    return &FAM.getResult<BlockFrequencyAnalysis>(F);
   };
 
   if (!InstrumentAllFunctions(M, LookupBPI, LookupBFI))
@@ -837,8 +836,8 @@ static void setPGOCountOnFunc(PGOUseFunc
 }
 
 bool PGOInstrumentationUseLegacyPass::annotateAllFunctions(
-    Module &M, function_ref<BranchProbabilityInfo &(Function &)> LookupBPI,
-    function_ref<BlockFrequencyInfo &(Function &)> LookupBFI) {
+    Module &M, function_ref<BranchProbabilityInfo *(Function &)> LookupBPI,
+    function_ref<BlockFrequencyInfo *(Function &)> LookupBFI) {
   DEBUG(dbgs() << "Read in profile counters: ");
   auto &Ctx = M.getContext();
   // Read the counter array from file.
@@ -867,9 +866,9 @@ bool PGOInstrumentationUseLegacyPass::an
   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::ru
   if (skipModule(M))
     return false;
 
-  auto LookupBPI = [this](Function &F) -> BranchProbabilityInfo & {
-    return this->getAnalysis<BranchProbabilityInfoWrapperPass>(F).getBPI();
+  auto LookupBPI = [this](Function &F) {
+    return &this->getAnalysis<BranchProbabilityInfoWrapperPass>(F).getBPI();
   };
-  auto LookupBFI = [this](Function &F) -> BlockFrequencyInfo & {
-    return this->getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI();
+  auto LookupBFI = [this](Function &F) {
+    return &this->getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI();
   };
 
   return annotateAllFunctions(M, LookupBPI, LookupBFI);




More information about the llvm-commits mailing list