llvm.org GIT mirror llvm / 2fb9a98
Consistently use ModuleAnalysisManager Besides a general consistently benefit, the extra layer of indirection allows the mechanical part of https://reviews.llvm.org/D23256 that requires touching every transformation and analysis to be factored out cleanly. Thanks to David for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278078 91177308-0d34-0410-b5e6-96231b3b80d8 Sean Silva 3 years ago
33 changed file(s) with 37 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
314314
315315 public:
316316 explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}
317 PreservedAnalyses run(Module &M, AnalysisManager &AM);
317 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
318318 };
319319
320320 /// \brief The \c ModulePass which wraps up a \c CallGraph and the logic to
124124 public:
125125 typedef GlobalsAAResult Result;
126126
127 GlobalsAAResult run(Module &M, AnalysisManager &AM);
127 GlobalsAAResult run(Module &M, ModuleAnalysisManager &AM);
128128 };
129129
130130 /// Legacy wrapper pass to provide the GlobalsAAResult object.
104104
105105 public:
106106 explicit ProfileSummaryPrinterPass(raw_ostream &OS) : OS(OS) {}
107 PreservedAnalyses run(Module &M, AnalysisManager &AM);
107 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
108108 };
109109
110110 } // end namespace llvm
2020 class GCOVProfilerPass : public PassInfoMixin {
2121 public:
2222 GCOVProfilerPass(const GCOVOptions &Options = GCOVOptions::getDefault()) : GCOVOpts(Options) { }
23 PreservedAnalyses run(Module &M, AnalysisManager &AM);
23 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
2424
2525 private:
2626 GCOVOptions GCOVOpts;
2020 namespace llvm {
2121 class CrossDSOCFIPass : public PassInfoMixin {
2222 public:
23 PreservedAnalyses run(Module &M, AnalysisManager &AM);
23 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
2424 };
2525 }
2626 #endif // LLVM_TRANSFORMS_IPO_CROSSDSOCFI_H
4949 class ReversePostOrderFunctionAttrsPass
5050 : public PassInfoMixin {
5151 public:
52 PreservedAnalyses run(Module &M, AnalysisManager &AM);
52 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
5353 };
5454 }
5555
6868 public:
6969 FunctionImportPass(const ModuleSummaryIndex *Index = nullptr)
7070 : Index(Index) {}
71 PreservedAnalyses run(Module &M, AnalysisManager &AM);
71 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
7272
7373 private:
7474 const ModuleSummaryIndex *Index;
2323 /// Optimize globals that never have their address taken.
2424 class GlobalOptPass : public PassInfoMixin {
2525 public:
26 PreservedAnalyses run(Module &M, AnalysisManager &AM);
26 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
2727 };
2828
2929 }
2323 /// A pass which infers function attributes from the names and signatures of
2424 /// function declarations in a module.
2525 struct InferFunctionAttrsPass : PassInfoMixin {
26 PreservedAnalyses run(Module &M, AnalysisManager &AM);
26 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
2727 };
2828
2929 /// Create a legacy pass manager instance of a pass to infer function
6262 /// internalizing a function (by removing any edge from the "external node")
6363 bool internalizeModule(Module &TheModule, CallGraph *CG = nullptr);
6464
65 PreservedAnalyses run(Module &M, AnalysisManager &AM);
65 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
6666 };
6767
6868 /// Helper function to internalize functions and variables in a Module.
204204
205205 class LowerTypeTestsPass : public PassInfoMixin {
206206 public:
207 PreservedAnalyses run(Module &M, AnalysisManager &AM);
207 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
208208 };
209209
210210 } // end namespace llvm
2727 /// Pass to perform interprocedural constant propagation.
2828 class IPSCCPPass : public PassInfoMixin {
2929 public:
30 PreservedAnalyses run(Module &M, AnalysisManager &AM);
30 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
3131 };
3232 }
3333 #endif // LLVM_TRANSFORMS_IPO_SCCP_H
2828 InstrProfiling() {}
2929 InstrProfiling(const InstrProfOptions &Options) : Options(Options) {}
3030
31 PreservedAnalyses run(Module &M, AnalysisManager &AM);
31 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
3232 bool run(Module &M);
3333
3434 private:
2121 /// The instrumentation (profile-instr-gen) pass for IR based PGO.
2222 class PGOInstrumentationGen : public PassInfoMixin {
2323 public:
24 PreservedAnalyses run(Module &M, AnalysisManager &AM);
24 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
2525 };
2626
2727 /// The profile annotation (profile-instr-use) pass for IR based PGO.
2828 class PGOInstrumentationUse : public PassInfoMixin {
2929 public:
30 PreservedAnalyses run(Module &M, AnalysisManager &AM);
30 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
3131 PGOInstrumentationUse(std::string Filename = "");
3232
3333 private:
3838 class PGOIndirectCallPromotion : public PassInfoMixin {
3939 public:
4040 PGOIndirectCallPromotion(bool IsInLTO = false) : InLTO(IsInLTO) {}
41 PreservedAnalyses run(Module &M, AnalysisManager &AM);
41 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
4242 private:
4343 bool InLTO;
4444 };
1919 /// The sample profiler data loader pass.
2020 class SampleProfileLoaderPass : public PassInfoMixin {
2121 public:
22 PreservedAnalyses run(Module &M, AnalysisManager &AM);
22 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
2323 };
2424
2525 } // End llvm namespace
260260 char CallGraphAnalysis::PassID;
261261
262262 PreservedAnalyses CallGraphPrinterPass::run(Module &M,
263 AnalysisManager &AM) {
263 ModuleAnalysisManager &AM) {
264264 AM.getResult(M).print(OS);
265265 return PreservedAnalyses::all();
266266 }
938938
939939 char GlobalsAA::PassID;
940940
941 GlobalsAAResult GlobalsAA::run(Module &M, AnalysisManager &AM) {
941 GlobalsAAResult GlobalsAA::run(Module &M, ModuleAnalysisManager &AM) {
942942 return GlobalsAAResult::analyzeModule(M,
943943 AM.getResult(M),
944944 AM.getResult(M));
147147 // FIXME: This only tests isHotFunction and isColdFunction and not the
148148 // isHotCount and isColdCount calls.
149149 PreservedAnalyses ProfileSummaryPrinterPass::run(Module &M,
150 AnalysisManager &AM) {
150 ModuleAnalysisManager &AM) {
151151 ProfileSummaryInfo &PSI = AM.getResult(M);
152152
153153 OS << "Functions in " << M.getName() << " with hot/cold annotations: \n";
2525 : OS(OS), Banner(Banner),
2626 ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
2727
28 PreservedAnalyses PrintModulePass::run(Module &M, AnalysisManager &) {
28 PreservedAnalyses PrintModulePass::run(Module &M, ModuleAnalysisManager &) {
2929 OS << Banner;
3030 if (llvm::isFunctionInPrintList("*"))
3131 M.print(OS, nullptr, ShouldPreserveUseListOrder);
134134
135135 /// \brief No-op module pass which does nothing.
136136 struct NoOpModulePass {
137 PreservedAnalyses run(Module &M, AnalysisManager &) {
137 PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
138138 return PreservedAnalyses::all();
139139 }
140140 static StringRef name() { return "NoOpModulePass"; }
147147
148148 public:
149149 struct Result {};
150 Result run(Module &, AnalysisManager &) { return Result(); }
150 Result run(Module &, ModuleAnalysisManager &) { return Result(); }
151151 static StringRef name() { return "NoOpModuleAnalysis"; }
152152 };
153153
154154 return true;
155155 }
156156
157 PreservedAnalyses CrossDSOCFIPass::run(Module &M, AnalysisManager &AM) {
157 PreservedAnalyses CrossDSOCFIPass::run(Module &M, ModuleAnalysisManager &AM) {
158158 CrossDSOCFI Impl;
159159 bool Changed = Impl.runOnModule(M);
160160 if (!Changed)
12661266 }
12671267
12681268 PreservedAnalyses
1269 ReversePostOrderFunctionAttrsPass::run(Module &M, AnalysisManager &AM) {
1269 ReversePostOrderFunctionAttrsPass::run(Module &M, ModuleAnalysisManager &AM) {
12701270 auto &CG = AM.getResult(M);
12711271
12721272 bool Changed = deduceFunctionAttributeInRPO(M, CG);
784784 } // anonymous namespace
785785
786786 PreservedAnalyses FunctionImportPass::run(Module &M,
787 AnalysisManager &AM) {
787 ModuleAnalysisManager &AM) {
788788 if (!doImportingForModule(M, Index))
789789 return PreservedAnalyses::all();
790790
25642564 return Changed;
25652565 }
25662566
2567 PreservedAnalyses GlobalOptPass::run(Module &M, AnalysisManager &AM) {
2567 PreservedAnalyses GlobalOptPass::run(Module &M, ModuleAnalysisManager &AM) {
25682568 auto &DL = M.getDataLayout();
25692569 auto &TLI = AM.getResult(M);
25702570 auto &FAM =
3333 }
3434
3535 PreservedAnalyses InferFunctionAttrsPass::run(Module &M,
36 AnalysisManager &AM) {
36 ModuleAnalysisManager &AM) {
3737 auto &TLI = AM.getResult(M);
3838
3939 if (!inferAllPrototypeAttributes(M, TLI))
238238
239239 InternalizePass::InternalizePass() : MustPreserveGV(PreserveAPIList()) {}
240240
241 PreservedAnalyses InternalizePass::run(Module &M, AnalysisManager &AM) {
241 PreservedAnalyses InternalizePass::run(Module &M, ModuleAnalysisManager &AM) {
242242 if (!internalizeModule(M, AM.getCachedResult(M)))
243243 return PreservedAnalyses::all();
244244
10601060 }
10611061
10621062 PreservedAnalyses LowerTypeTestsPass::run(Module &M,
1063 AnalysisManager &AM) {
1063 ModuleAnalysisManager &AM) {
10641064 LowerTypeTests Impl;
10651065 init(&Impl, M);
10661066 bool Changed = Impl.lower();
12521252 }
12531253
12541254 PreservedAnalyses SampleProfileLoaderPass::run(Module &M,
1255 AnalysisManager &AM) {
1255 ModuleAnalysisManager &AM) {
12561256
12571257 SampleProfileLoader SampleLoader(SampleProfileFile);
12581258
452452 }
453453
454454 PreservedAnalyses GCOVProfilerPass::run(Module &M,
455 AnalysisManager &AM) {
455 ModuleAnalysisManager &AM) {
456456
457457 GCOVProfiler Profiler(GCOVOpts);
458458
652652 return promoteIndirectCalls(M, InLTO | ICPLTOMode);
653653 }
654654
655 PreservedAnalyses PGOIndirectCallPromotion::run(Module &M, AnalysisManager &AM) {
655 PreservedAnalyses PGOIndirectCallPromotion::run(Module &M, ModuleAnalysisManager &AM) {
656656 if (!promoteIndirectCalls(M, InLTO | ICPLTOMode))
657657 return PreservedAnalyses::all();
658658
6565
6666 } // anonymous namespace
6767
68 PreservedAnalyses InstrProfiling::run(Module &M, AnalysisManager &AM) {
68 PreservedAnalyses InstrProfiling::run(Module &M, ModuleAnalysisManager &AM) {
6969 if (!run(M))
7070 return PreservedAnalyses::all();
7171
963963 }
964964
965965 PreservedAnalyses PGOInstrumentationGen::run(Module &M,
966 AnalysisManager &AM) {
966 ModuleAnalysisManager &AM) {
967967
968968 auto &FAM = AM.getResult(M).getManager();
969969 auto LookupBPI = [&FAM](Function &F) {
10551055 }
10561056
10571057 PreservedAnalyses PGOInstrumentationUse::run(Module &M,
1058 AnalysisManager &AM) {
1058 ModuleAnalysisManager &AM) {
10591059
10601060 auto &FAM = AM.getResult(M).getManager();
10611061 auto LookupBPI = [&FAM](Function &F) {
19401940 return MadeChanges;
19411941 }
19421942
1943 PreservedAnalyses IPSCCPPass::run(Module &M, AnalysisManager &AM) {
1943 PreservedAnalyses IPSCCPPass::run(Module &M, ModuleAnalysisManager &AM) {
19441944 const DataLayout &DL = M.getDataLayout();
19451945 auto &TLI = AM.getResult(M);
19461946 if (!runIPSCCP(M, DL, &TLI))