[llvm] b82083b - [CGProfile] Remove unnecessary analysis callbacks (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 28 05:50:57 PST 2023


Author: Nikita Popov
Date: 2023-02-28T14:49:38+01:00
New Revision: b82083b32b0516c3cb2dcf00e96b3e273b89b7d0

URL: https://github.com/llvm/llvm-project/commit/b82083b32b0516c3cb2dcf00e96b3e273b89b7d0
DIFF: https://github.com/llvm/llvm-project/commit/b82083b32b0516c3cb2dcf00e96b3e273b89b7d0.diff

LOG: [CGProfile] Remove unnecessary analysis callbacks (NFC)

These were used to abstract between NewPM and LegacyPM. Now that
the LegacyPM implementation is gone, we can fetch the analyses
directly from the FAM.

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/CGProfile.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
index 1c630e9ee424d..638790eea9a35 100644
--- a/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
+++ b/llvm/lib/Transforms/Instrumentation/CGProfile.cpp
@@ -46,8 +46,7 @@ addModuleFlags(Module &M,
 }
 
 static bool runCGProfilePass(
-    Module &M, function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
-    function_ref<TargetTransformInfo &(Function &)> GetTTI, bool LazyBFI) {
+    Module &M, FunctionAnalysisManager &FAM, bool LazyBFI) {
   MapVector<std::pair<Function *, Function *>, uint64_t> Counts;
   InstrProfSymtab Symtab;
   auto UpdateCounts = [&](TargetTransformInfo &TTI, Function *F,
@@ -69,10 +68,10 @@ static bool runCGProfilePass(
     // TODO: Remove LazyBFI when LazyBlockFrequencyInfoPass is available in NPM.
     if (F.isDeclaration() || (LazyBFI && !F.getEntryCount()))
       continue;
-    auto &BFI = GetBFI(F);
+    auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
     if (BFI.getEntryFreq() == 0)
       continue;
-    TargetTransformInfo &TTI = GetTTI(F);
+    TargetTransformInfo &TTI = FAM.getResult<TargetIRAnalysis>(F);
     for (auto &BB : F) {
       std::optional<uint64_t> BBCount = BFI.getBlockProfileCount(&BB);
       if (!BBCount)
@@ -105,14 +104,7 @@ static bool runCGProfilePass(
 PreservedAnalyses CGProfilePass::run(Module &M, ModuleAnalysisManager &MAM) {
   FunctionAnalysisManager &FAM =
       MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
-  auto GetBFI = [&FAM](Function &F) -> BlockFrequencyInfo & {
-    return FAM.getResult<BlockFrequencyAnalysis>(F);
-  };
-  auto GetTTI = [&FAM](Function &F) -> TargetTransformInfo & {
-    return FAM.getResult<TargetIRAnalysis>(F);
-  };
-
-  runCGProfilePass(M, GetBFI, GetTTI, false);
+  runCGProfilePass(M, FAM, false);
 
   return PreservedAnalyses::all();
 }


        


More information about the llvm-commits mailing list