[PATCH] D155027: [nfc] simplify promoteIndirectCalls
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 11 15:57:52 PDT 2023
mtrofin created this revision.
mtrofin added a reviewer: xur.
Herald added subscribers: Enna1, hiraditya.
Herald added a project: All.
mtrofin requested review of this revision.
Herald added subscribers: llvm-commits, wangpc.
Herald added a project: LLVM.
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".
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155027
Files:
llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
Index: llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
+++ llvm/lib/Transforms/Instrumentation/IndirectCallPromotion.cpp
@@ -326,9 +326,8 @@
}
// 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 @@
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 @@
ProfileSummaryInfo *PSI = &AM.getResult<ProfileSummaryAnalysis>(M);
if (!promoteIndirectCalls(M, PSI, InLTO | ICPLTOMode,
- SamplePGO | ICPSamplePGOMode, &AM))
+ SamplePGO | ICPSamplePGOMode, AM))
return PreservedAnalyses::all();
return PreservedAnalyses::none();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155027.539318.patch
Type: text/x-patch
Size: 2090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230711/a8df2be6/attachment.bin>
More information about the llvm-commits
mailing list