[llvm] cdfd147 - [nfc] simplify promoteIndirectCalls

Mircea Trofin via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 12 14:20:19 PDT 2023


Author: Mircea Trofin
Date: 2023-07-12T14:20:06-07:00
New Revision: cdfd1475c0b8a7f01f11c3cb74b530058bd4017c

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

LOG: [nfc] simplify promoteIndirectCalls

There's no caller to `promoteIndirectCalls` that would pass a nullptr
`ModuleAnalysisManager`, so passing it by reference does away with a
bunch of nullptr tests, and also removes the need for a "OwnedORE".

Differential Revision: https://reviews.llvm.org/D155027

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
index b66e761d53b0c9..c350c73aa10aa6 100644
--- a/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ b/llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -326,9 +326,8 @@ bool ICallPromotionFunc::processFunction(ProfileSummaryInfo *PSI) {
 }
 
 // A wrapper function that does the actual work.
-static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI,
-                                 bool InLTO, bool SamplePGO,
-                                 ModuleAnalysisManager *AM = nullptr) {
+static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI, bool InLTO,
+                                 bool SamplePGO, ModuleAnalysisManager &AM) {
   if (DisableICP)
     return false;
   InstrProfSymtab Symtab;
@@ -342,18 +341,11 @@ static bool promoteIndirectCalls(Module &M, ProfileSummaryInfo *PSI,
     if (F.isDeclaration() || F.hasOptNone())
       continue;
 
-    std::unique_ptr<OptimizationRemarkEmitter> OwnedORE;
-    OptimizationRemarkEmitter *ORE;
-    if (AM) {
-      auto &FAM =
-          AM->getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
-      ORE = &FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
-    } else {
-      OwnedORE = std::make_unique<OptimizationRemarkEmitter>(&F);
-      ORE = OwnedORE.get();
-    }
+    auto &FAM =
+        AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
+    auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
 
-    ICallPromotionFunc ICallPromotion(F, &M, &Symtab, SamplePGO, *ORE);
+    ICallPromotionFunc ICallPromotion(F, &M, &Symtab, SamplePGO, ORE);
     bool FuncChanged = ICallPromotion.processFunction(PSI);
     if (ICPDUMPAFTER && FuncChanged) {
       LLVM_DEBUG(dbgs() << "\n== IR Dump After =="; F.print(dbgs()));
@@ -373,7 +365,7 @@ PreservedAnalyses PGOIndirectCallPromotion::run(Module &M,
   ProfileSummaryInfo *PSI = &AM.getResult<ProfileSummaryAnalysis>(M);
 
   if (!promoteIndirectCalls(M, PSI, InLTO | ICPLTOMode,
-                            SamplePGO | ICPSamplePGOMode, &AM))
+                            SamplePGO | ICPSamplePGOMode, AM))
     return PreservedAnalyses::all();
 
   return PreservedAnalyses::none();


        


More information about the llvm-commits mailing list