[PATCH] D155212: [nfc] small maintainability IndirectCallPromotion changes
Mircea Trofin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 13 09:02:49 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.
- we can keep a reference to the `Module` in the promoter class, which also makes it a compile-time error not to initialize
- a few fields can be `const`-ed, same reason - compile-time initialization checking (and we don't need to support `operator=`)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D155212
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
@@ -109,20 +109,20 @@
class ICallPromotionFunc {
private:
Function &F;
- Module *M;
+ Module &M;
// Symtab that maps indirect call profile values to function names and
// defines.
- InstrProfSymtab *Symtab;
+ InstrProfSymtab *const Symtab;
- bool SamplePGO;
+ const bool SamplePGO;
OptimizationRemarkEmitter &ORE;
// A struct that records the direct target and it's call count.
struct PromotionCandidate {
- Function *TargetFunction;
- uint64_t Count;
+ Function *const TargetFunction;
+ const uint64_t Count;
PromotionCandidate(Function *F, uint64_t C) : TargetFunction(F), Count(C) {}
};
@@ -143,9 +143,9 @@
uint64_t &TotalCount);
public:
- ICallPromotionFunc(Function &Func, Module *Modu, InstrProfSymtab *Symtab,
+ ICallPromotionFunc(Function &Func, Module &M, InstrProfSymtab *Symtab,
bool SamplePGO, OptimizationRemarkEmitter &ORE)
- : F(Func), M(Modu), Symtab(Symtab), SamplePGO(SamplePGO), ORE(ORE) {}
+ : F(Func), M(M), Symtab(Symtab), SamplePGO(SamplePGO), ORE(ORE) {}
ICallPromotionFunc(const ICallPromotionFunc &) = delete;
ICallPromotionFunc &operator=(const ICallPromotionFunc &) = delete;
@@ -319,7 +319,7 @@
if (TotalCount == 0 || NumPromoted == NumVals)
continue;
// Otherwise we need update with the un-promoted records back.
- annotateValueSite(*M, *CB, ICallProfDataRef.slice(NumPromoted), TotalCount,
+ annotateValueSite(M, *CB, ICallProfDataRef.slice(NumPromoted), TotalCount,
IPVK_IndirectCallTarget, NumCandidates);
}
return Changed;
@@ -345,7 +345,7 @@
MAM.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()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155212.540066.patch
Type: text/x-patch
Size: 2388 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230713/56350ff6/attachment.bin>
More information about the llvm-commits
mailing list