llvm.org GIT mirror llvm / 04d0fe9
[PM] Remove support for omitting the AnalysisManager argument to new pass manager passes' `run` methods. This removes a bunch of SFINAE goop from the pass manager and just requires pass authors to accept `AnalysisManager<IRUnitT> &` as a dead argument. This is a small price to pay for the simplicity of the system as a whole, despite the noise that changing it causes at this stage. This will also helpfull allow us to make the signature of the run methods much more flexible for different kinds af passes to support things like intelligently updating the pass's progression over IR units. While this touches many, many, files, the changes are really boring. Mostly made with the help of my trusty perl one liners. Thanks to Sean and Hal for bouncing ideas for this with me in IRC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272978 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 3 years ago
49 changed file(s) with 122 addition(s) and 180 deletion(s). Raw diff Collapse all Expand all
105105 AssumptionAnalysis &operator=(const AssumptionAnalysis &RHS) { return *this; }
106106 AssumptionAnalysis &operator=(AssumptionAnalysis &&RHS) { return *this; }
107107
108 AssumptionCache run(Function &F) { return AssumptionCache(F); }
108 AssumptionCache run(Function &F, FunctionAnalysisManager &) {
109 return AssumptionCache(F);
110 }
109111 };
110112
111113 /// \brief Printer pass for the \c AssumptionAnalysis results.
305305 /// \brief Compute the \c CallGraph for the module \c M.
306306 ///
307307 /// The real work here is done in the \c CallGraph constructor.
308 CallGraph run(Module &M) { return CallGraph(M); }
308 CallGraph run(Module &M, ModuleAnalysisManager &) { return CallGraph(M); }
309309 };
310310
311311 /// \brief Printer pass for the \c CallGraphAnalysis results.
906906 ///
907907 /// This just builds the set of entry points to the call graph. The rest is
908908 /// built lazily as it is walked.
909 LazyCallGraph run(Module &M) { return LazyCallGraph(M); }
909 LazyCallGraph run(Module &M, ModuleAnalysisManager &) {
910 return LazyCallGraph(M);
911 }
910912 };
911913
912914 /// A pass which prints the call graph to a \c raw_ostream.
825825 PrintLoopPass();
826826 PrintLoopPass(raw_ostream &OS, const std::string &Banner = "");
827827
828 PreservedAnalyses run(Loop &L);
828 PreservedAnalyses run(Loop &L, AnalysisManager &);
829829 };
830830
831831 } // End llvm namespace
4747
4848 /// \brief Run the analysis pass over a function and produce a post dominator
4949 /// tree.
50 PostDominatorTree run(Function &F);
50 PostDominatorTree run(Function &F, FunctionAnalysisManager &);
5151 };
5252
5353 /// \brief Printer pass for the \c PostDominatorTree.
9090 return *this;
9191 }
9292
93 Result run(Module &M);
93 Result run(Module &M, ModuleAnalysisManager &);
9494
9595 private:
9696 friend AnalysisInfoMixin;
303303 return *this;
304304 }
305305
306 TargetLibraryInfo run(Module &M);
307 TargetLibraryInfo run(Function &F);
306 TargetLibraryInfo run(Module &M, ModuleAnalysisManager &);
307 TargetLibraryInfo run(Function &F, FunctionAnalysisManager &);
308308
309309 private:
310310 friend AnalysisInfoMixin;
994994 return *this;
995995 }
996996
997 Result run(const Function &F);
997 Result run(const Function &F, AnalysisManager &);
998998
999999 private:
10001000 friend AnalysisInfoMixin;
1515 #define LLVM_BITCODE_BITCODEWRITERPASS_H
1616
1717 #include "llvm/ADT/StringRef.h"
18 #include "llvm/IR/PassManager.h"
1819
1920 namespace llvm {
2021 class Module;
2122 class ModulePass;
2223 class raw_ostream;
23 class PreservedAnalyses;
2424
2525 /// \brief Create and return a pass that writes the module to the specified
2626 /// ostream. Note that this pass is designed for use with the legacy pass
6666
6767 /// \brief Run the bitcode writer pass, and output the module to the selected
6868 /// output stream.
69 PreservedAnalyses run(Module &M);
69 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
7070
7171 static StringRef name() { return "BitcodeWriterPass"; }
7272 };
186186 typedef DominatorTree Result;
187187
188188 /// \brief Run the analysis pass over a function and produce a dominator tree.
189 DominatorTree run(Function &F);
189 DominatorTree run(Function &F, AnalysisManager &);
190190 };
191191
192192 /// \brief Printer pass for the \c DominatorTree.
2929 class ModulePass;
3030 class PreservedAnalyses;
3131 class raw_ostream;
32 template class AnalysisManager;
3233
3334 /// \brief Create and return a pass that writes the module to the specified
3435 /// \c raw_ostream.
6667 PrintModulePass(raw_ostream &OS, const std::string &Banner = "",
6768 bool ShouldPreserveUseListOrder = false);
6869
69 PreservedAnalyses run(Module &M);
70 PreservedAnalyses run(Module &M, AnalysisManager &);
7071
7172 static StringRef name() { return "PrintModulePass"; }
7273 };
8384 PrintFunctionPass();
8485 PrintFunctionPass(raw_ostream &OS, const std::string &Banner = "");
8586
86 PreservedAnalyses run(Function &F);
87 PreservedAnalyses run(Function &F, AnalysisManager &);
8788
8889 static StringRef name() { return "PrintFunctionPass"; }
8990 };
749749 /// In debug builds, it will also assert that the analysis manager is empty
750750 /// as no queries should arrive at the function analysis manager prior to
751751 /// this analysis being requested.
752 Result run(IRUnitT &IR) { return Result(*AM); }
752 Result run(IRUnitT &IR, AnalysisManager &) { return Result(*AM); }
753753
754754 private:
755755 friend AnalysisInfoMixin<
822822 /// \brief Run the analysis pass and create our proxy result object.
823823 /// Nothing to see here, it just forwards the \c AM reference into the
824824 /// result.
825 Result run(IRUnitT &) { return Result(*AM); }
825 Result run(IRUnitT &, AnalysisManager &) { return Result(*AM); }
826826
827827 private:
828828 friend AnalysisInfoMixin<
980980 /// analysis passes to be re-run to produce fresh results if any are needed.
981981 struct InvalidateAllAnalysesPass : PassInfoMixin {
982982 /// \brief Run this pass over some unit of IR.
983 template PreservedAnalyses run(IRUnitT &Arg) {
983 template
984 PreservedAnalyses run(IRUnitT &, AnalysisManager &) {
984985 return PreservedAnalyses::none();
985986 }
986987 };
4545 virtual StringRef name() = 0;
4646 };
4747
48 /// \brief SFINAE metafunction for computing whether \c PassT has a run method
49 /// accepting an \c AnalysisManager.
50 template
51 class PassRunAcceptsAnalysisManager {
52 typedef char SmallType;
53 struct BigType {
54 char a, b;
55 };
56
57 template &)>
58 struct Checker;
59
60 template static SmallType f(Checker *);
61 template static BigType f(...);
62
63 public:
64 enum { Value = sizeof(f(nullptr)) == sizeof(SmallType) };
65 };
66
6748 /// \brief A template wrapper used to implement the polymorphic API.
6849 ///
6950 /// Can be instantiated for any object which provides a \c run method accepting
70 /// an \c IRUnitT. It requires the pass to be a copyable object. When the
71 /// \c run method also accepts an \c AnalysisManager*, we pass it
72 /// along.
51 /// an \c IRUnitT& and an \c AnalysisManager&. It requires the pass to
52 /// be a copyable object. When the
7353 template
74 typename PreservedAnalysesT = PreservedAnalyses,
75 bool AcceptsAnalysisManager = PassRunAcceptsAnalysisManager<
76 IRUnitT, PassT, PreservedAnalysesT>::Value>
77 struct PassModel;
78
79 /// \brief Specialization of \c PassModel for passes that accept an analyis
80 /// manager.
81 template
82 struct PassModel
83 : PassConcept {
54 typename PreservedAnalysesT = PreservedAnalyses>
55 struct PassModel : PassConcept {
8456 explicit PassModel(PassT Pass) : Pass(std::move(Pass)) {}
8557 // We have to explicitly define all the special member functions because MSVC
8658 // refuses to generate them.
9769
9870 PreservedAnalysesT run(IRUnitT &IR, AnalysisManager &AM) override {
9971 return Pass.run(IR, AM);
100 }
101 StringRef name() override { return PassT::name(); }
102 PassT Pass;
103 };
104
105 /// \brief Specialization of \c PassModel for passes that accept an analyis
106 /// manager.
107 template
108 struct PassModel
109 : PassConcept {
110 explicit PassModel(PassT Pass) : Pass(std::move(Pass)) {}
111 // We have to explicitly define all the special member functions because MSVC
112 // refuses to generate them.
113 PassModel(const PassModel &Arg) : Pass(Arg.Pass) {}
114 PassModel(PassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
115 friend void swap(PassModel &LHS, PassModel &RHS) {
116 using std::swap;
117 swap(LHS.Pass, RHS.Pass);
118 }
119 PassModel &operator=(PassModel RHS) {
120 swap(*this, RHS);
121 return *this;
122 }
123
124 PreservedAnalysesT run(IRUnitT &IR, AnalysisManager &) override {
125 return Pass.run(IR);
12672 }
12773 StringRef name() override { return PassT::name(); }
12874 PassT Pass;
260206 /// \brief Wrapper to model the analysis pass concept.
261207 ///
262208 /// Can wrap any type which implements a suitable \c run method. The method
263 /// must accept the IRUnitT as an argument and produce an object which can be
264 /// wrapped in a \c AnalysisResultModel.
265 template
266 bool AcceptsAnalysisManager = PassRunAcceptsAnalysisManager<
267 IRUnitT, PassT, typename PassT::Result>::Value>
268 struct AnalysisPassModel;
269
270 /// \brief Specialization of \c AnalysisPassModel which passes an
271 /// \c AnalysisManager to PassT's run method.
209 /// must accept an \c IRUnitT& and an \c AnalysisManager& as arguments
210 /// and produce an object which can be wrapped in a \c AnalysisResultModel.
272211 template
273 struct AnalysisPassModel : AnalysisPassConcept {
212 struct AnalysisPassModel : AnalysisPassConcept {
274213 explicit AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {}
275214 // We have to explicitly define all the special member functions because MSVC
276215 // refuses to generate them.
305244 PassT Pass;
306245 };
307246
308 /// \brief Specialization of \c AnalysisPassModel which does not pass an
309 /// \c AnalysisManager to PassT's run method.
310 template
311 struct AnalysisPassModel : AnalysisPassConcept {
312 explicit AnalysisPassModel(PassT Pass) : Pass(std::move(Pass)) {}
313 // We have to explicitly define all the special member functions because MSVC
314 // refuses to generate them.
315 AnalysisPassModel(const AnalysisPassModel &Arg) : Pass(Arg.Pass) {}
316 AnalysisPassModel(AnalysisPassModel &&Arg) : Pass(std::move(Arg.Pass)) {}
317 friend void swap(AnalysisPassModel &LHS, AnalysisPassModel &RHS) {
318 using std::swap;
319 swap(LHS.Pass, RHS.Pass);
320 }
321 AnalysisPassModel &operator=(AnalysisPassModel RHS) {
322 swap(*this, RHS);
323 return *this;
324 }
325
326 // FIXME: Replace PassT::Result with type traits when we use C++11.
327 typedef AnalysisResultModel
328 ResultModelT;
329
330 /// \brief The model delegates to the \c PassT::run method.
331 ///
332 /// The return is wrapped in an \c AnalysisResultModel.
333 std::unique_ptr>
334 run(IRUnitT &IR, AnalysisManager &) override {
335 return make_unique(Pass.run(IR));
336 }
337
338 /// \brief The model delegates to a static \c PassT::name method.
339 ///
340 /// The returned string ref must point to constant immutable data!
341 StringRef name() override { return PassT::name(); }
342
343 PassT Pass;
344 };
345
346247 } // End namespace detail
347248 }
348249
6464 bool IRBroken, DebugInfoBroken;
6565 };
6666 static void *ID() { return (void *)&PassID; }
67 Result run(Module &M);
68 Result run(Function &F);
67 Result run(Module &M, ModuleAnalysisManager &);
68 Result run(Function &F, FunctionAnalysisManager &);
6969 };
7070
7171 /// Check a module for errors, but report debug info errors separately.
2727 /// A pass that merges duplicate global constants into a single constant.
2828 class ConstantMergePass : public PassInfoMixin {
2929 public:
30 PreservedAnalyses run(Module &M);
30 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
3131 };
3232 }
3333
109109 public:
110110 DeadArgumentEliminationPass(bool ShouldHackArguments_ = false)
111111 : ShouldHackArguments(ShouldHackArguments_) {}
112 PreservedAnalyses run(Module &M);
112 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
113113
114114 private:
115115 Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses);
2323 class EliminateAvailableExternallyPass
2424 : public PassInfoMixin {
2525 public:
26 PreservedAnalyses run(Module &M);
26 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
2727 };
2828 }
2929
2121 /// Pass which forces specific function attributes into the IR, primarily as
2222 /// a debugging tool.
2323 struct ForceFunctionAttrsPass : PassInfoMixin {
24 PreservedAnalyses run(Module &M);
24 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
2525 };
2626
2727 /// Create a legacy pass manager instance of a pass to force function attrs.
2626 /// Pass to remove unused function declarations.
2727 class GlobalDCEPass : public PassInfoMixin {
2828 public:
29 PreservedAnalyses run(Module &M);
29 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
3030
3131 private:
3232 SmallPtrSet AliveGlobals;
2323
2424 /// Pass to remove unused function declarations.
2525 struct StripDeadPrototypesPass : PassInfoMixin {
26 PreservedAnalyses run(Module &M);
26 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
2727 };
2828
2929 }
213213 } // end namespace wholeprogramdevirt
214214
215215 struct WholeProgramDevirtPass : public PassInfoMixin {
216 PreservedAnalyses run(Module &M);
216 PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
217217 };
218218
219219 } // end namespace llvm
2828 /// dead computations that other DCE passes do not catch, particularly involving
2929 /// loop computations.
3030 struct ADCEPass : PassInfoMixin {
31 PreservedAnalyses run(Function &F);
31 PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
3232 };
3333 }
3434
2121 /// A pass that lowers atomic intrinsic into non-atomic intrinsics.
2222 class LowerAtomicPass : public PassInfoMixin {
2323 public:
24 PreservedAnalyses run(Function &F);
24 PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
2525 };
2626 }
2727
2828 /// of the probabilities and frequencies of the CFG. After running this pass,
2929 /// no more expect intrinsics remain, allowing the rest of the optimizer to
3030 /// ignore them.
31 PreservedAnalyses run(Function &F);
31 PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
3232 };
3333
3434 }
6161 bool MadeChange;
6262
6363 public:
64 PreservedAnalyses run(Function &F);
64 PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
6565
6666 private:
6767 void BuildRankMap(Function &F, ReversePostOrderTraversal &RPOT);
669669 PrintLoopPass::PrintLoopPass(raw_ostream &OS, const std::string &Banner)
670670 : OS(OS), Banner(Banner) {}
671671
672 PreservedAnalyses PrintLoopPass::run(Loop &L) {
672 PreservedAnalyses PrintLoopPass::run(Loop &L, AnalysisManager &) {
673673 OS << Banner;
674674 for (auto *Block : L.blocks())
675675 if (Block)
4545 auto BBI = find_if(L->blocks().begin(), L->blocks().end(),
4646 [](BasicBlock *BB) { return BB; });
4747 if (BBI != L->blocks().end() &&
48 isFunctionInPrintList((*BBI)->getParent()->getName()))
49 P.run(*L);
48 isFunctionInPrintList((*BBI)->getParent()->getName())) {
49 AnalysisManager DummyLAM;
50 P.run(*L, DummyLAM);
51 }
5052 return false;
5153 }
5254 };
4545
4646 char PostDominatorTreeAnalysis::PassID;
4747
48 PostDominatorTree PostDominatorTreeAnalysis::run(Function &F) {
48 PostDominatorTree PostDominatorTreeAnalysis::run(Function &F,
49 FunctionAnalysisManager &) {
4950 PostDominatorTree PDT;
5051 PDT.recalculate(F);
5152 return PDT;
139139 }
140140
141141 char ProfileSummaryAnalysis::PassID;
142 ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M) {
142 ProfileSummaryInfo ProfileSummaryAnalysis::run(Module &M,
143 ModuleAnalysisManager &) {
143144 return ProfileSummaryInfo(M);
144145 }
145146
11261126 return I->ScalarFnName;
11271127 }
11281128
1129 TargetLibraryInfo TargetLibraryAnalysis::run(Module &M) {
1129 TargetLibraryInfo TargetLibraryAnalysis::run(Module &M,
1130 ModuleAnalysisManager &) {
11301131 if (PresetInfoImpl)
11311132 return TargetLibraryInfo(*PresetInfoImpl);
11321133
11331134 return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
11341135 }
11351136
1136 TargetLibraryInfo TargetLibraryAnalysis::run(Function &F) {
1137 TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
1138 FunctionAnalysisManager &) {
11371139 if (PresetInfoImpl)
11381140 return TargetLibraryInfo(*PresetInfoImpl);
11391141
403403 std::function TTICallback)
404404 : TTICallback(std::move(TTICallback)) {}
405405
406 TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F) {
406 TargetIRAnalysis::Result TargetIRAnalysis::run(const Function &F,
407 AnalysisManager &) {
407408 return TTICallback(F);
408409 }
409410
434435 }
435436
436437 TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(const Function &F) {
437 TTI = TIRA.run(F);
438 AnalysisManager DummyFAM;
439 TTI = TIRA.run(F, DummyFAM);
438440 return *TTI;
439441 }
440442
1818 #include "llvm/Pass.h"
1919 using namespace llvm;
2020
21 PreservedAnalyses BitcodeWriterPass::run(Module &M) {
21 PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &) {
2222 std::unique_ptr Index;
2323 if (EmitSummaryIndex)
2424 Index = ModuleSummaryIndexBuilder(&M).takeIndex();
299299 //
300300 //===----------------------------------------------------------------------===//
301301
302 DominatorTree DominatorTreeAnalysis::run(Function &F) {
302 DominatorTree DominatorTreeAnalysis::run(Function &F,
303 AnalysisManager &) {
303304 DominatorTree DT;
304305 DT.recalculate(F);
305306 return DT;
2525 : OS(OS), Banner(Banner),
2626 ShouldPreserveUseListOrder(ShouldPreserveUseListOrder) {}
2727
28 PreservedAnalyses PrintModulePass::run(Module &M) {
28 PreservedAnalyses PrintModulePass::run(Module &M, AnalysisManager &) {
2929 OS << Banner;
3030 if (llvm::isFunctionInPrintList("*"))
3131 M.print(OS, nullptr, ShouldPreserveUseListOrder);
4141 PrintFunctionPass::PrintFunctionPass(raw_ostream &OS, const std::string &Banner)
4242 : OS(OS), Banner(Banner) {}
4343
44 PreservedAnalyses PrintFunctionPass::run(Function &F) {
44 PreservedAnalyses PrintFunctionPass::run(Function &F,
45 AnalysisManager &) {
4546 if (isFunctionInPrintList(F.getName()))
4647 OS << Banner << static_cast(F);
4748 return PreservedAnalyses::all();
6061 : ModulePass(ID), P(OS, Banner, ShouldPreserveUseListOrder) {}
6162
6263 bool runOnModule(Module &M) override {
63 P.run(M);
64 ModuleAnalysisManager DummyMAM;
65 P.run(M, DummyMAM);
6466 return false;
6567 }
6668
8082
8183 // This pass just prints a banner followed by the function as it's processed.
8284 bool runOnFunction(Function &F) override {
83 P.run(F);
85 FunctionAnalysisManager DummyFAM;
86 P.run(F, DummyFAM);
8487 return false;
8588 }
8689
45114511 }
45124512
45134513 char VerifierAnalysis::PassID;
4514 VerifierAnalysis::Result VerifierAnalysis::run(Module &M) {
4514 VerifierAnalysis::Result VerifierAnalysis::run(Module &M,
4515 ModuleAnalysisManager &) {
45154516 Result Res;
45164517 Res.IRBroken = llvm::verifyModule(M, &dbgs(), &Res.DebugInfoBroken);
45174518 return Res;
45184519 }
45194520
4520 VerifierAnalysis::Result VerifierAnalysis::run(Function &F) {
4521 VerifierAnalysis::Result VerifierAnalysis::run(Function &F,
4522 FunctionAnalysisManager &) {
45214523 return { llvm::verifyFunction(F, &dbgs()), false };
45224524 }
45234525
104104
105105 /// \brief No-op module pass which does nothing.
106106 struct NoOpModulePass {
107 PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
107 PreservedAnalyses run(Module &M, AnalysisManager &) {
108 return PreservedAnalyses::all();
109 }
108110 static StringRef name() { return "NoOpModulePass"; }
109111 };
110112
115117
116118 public:
117119 struct Result {};
118 Result run(Module &) { return Result(); }
120 Result run(Module &, AnalysisManager &) { return Result(); }
119121 static StringRef name() { return "NoOpModuleAnalysis"; }
120122 };
121123
122124 /// \brief No-op CGSCC pass which does nothing.
123125 struct NoOpCGSCCPass {
124 PreservedAnalyses run(LazyCallGraph::SCC &C) {
126 PreservedAnalyses run(LazyCallGraph::SCC &C,
127 AnalysisManager &) {
125128 return PreservedAnalyses::all();
126129 }
127130 static StringRef name() { return "NoOpCGSCCPass"; }
134137
135138 public:
136139 struct Result {};
137 Result run(LazyCallGraph::SCC &) { return Result(); }
140 Result run(LazyCallGraph::SCC &, AnalysisManager &) {
141 return Result();
142 }
138143 static StringRef name() { return "NoOpCGSCCAnalysis"; }
139144 };
140145
141146 /// \brief No-op function pass which does nothing.
142147 struct NoOpFunctionPass {
143 PreservedAnalyses run(Function &F) { return PreservedAnalyses::all(); }
148 PreservedAnalyses run(Function &F, AnalysisManager &) {
149 return PreservedAnalyses::all();
150 }
144151 static StringRef name() { return "NoOpFunctionPass"; }
145152 };
146153
151158
152159 public:
153160 struct Result {};
154 Result run(Function &) { return Result(); }
161 Result run(Function &, AnalysisManager &) { return Result(); }
155162 static StringRef name() { return "NoOpFunctionAnalysis"; }
156163 };
157164
158165 /// \brief No-op loop pass which does nothing.
159166 struct NoOpLoopPass {
160 PreservedAnalyses run(Loop &L) { return PreservedAnalyses::all(); }
167 PreservedAnalyses run(Loop &L, AnalysisManager &) {
168 return PreservedAnalyses::all();
169 }
161170 static StringRef name() { return "NoOpLoopPass"; }
162171 };
163172
168177
169178 public:
170179 struct Result {};
171 Result run(Loop &) { return Result(); }
180 Result run(Loop &, AnalysisManager &) { return Result(); }
172181 static StringRef name() { return "NoOpLoopAnalysis"; }
173182 };
174183
191191 }
192192 }
193193
194 PreservedAnalyses ConstantMergePass::run(Module &M) {
194 PreservedAnalyses ConstantMergePass::run(Module &M, ModuleAnalysisManager &) {
195195 if (!mergeConstants(M))
196196 return PreservedAnalyses::all();
197197 return PreservedAnalyses::none();
6363 if (skipModule(M))
6464 return false;
6565 DeadArgumentEliminationPass DAEP(ShouldHackArguments());
66 PreservedAnalyses PA = DAEP.run(M);
66 ModuleAnalysisManager DummyMAM;
67 PreservedAnalyses PA = DAEP.run(M, DummyMAM);
6768 return !PA.areAllPreserved();
6869 }
6970
10281029 return true;
10291030 }
10301031
1031 PreservedAnalyses DeadArgumentEliminationPass::run(Module &M) {
1032 PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
1033 ModuleAnalysisManager &) {
10321034 bool Changed = false;
10331035
10341036 // First pass: Do a simple check to see if any functions can have their "..."
6060 return Changed;
6161 }
6262
63 PreservedAnalyses EliminateAvailableExternallyPass::run(Module &M) {
63 PreservedAnalyses
64 EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &) {
6465 if (!eliminateAvailableExternally(M))
6566 return PreservedAnalyses::all();
6667 return PreservedAnalyses::none();
7979 }
8080 }
8181
82 PreservedAnalyses ForceFunctionAttrsPass::run(Module &M) {
82 PreservedAnalyses ForceFunctionAttrsPass::run(Module &M,
83 ModuleAnalysisManager &) {
8384 if (ForceAttributes.empty())
8485 return PreservedAnalyses::all();
8586
4949 if (skipModule(M))
5050 return false;
5151
52 auto PA = Impl.run(M);
52 ModuleAnalysisManager DummyMAM;
53 auto PA = Impl.run(M, DummyMAM);
5354 return !PA.areAllPreserved();
5455 }
5556
7677 return RI.getReturnValue() == nullptr;
7778 }
7879
79 PreservedAnalyses GlobalDCEPass::run(Module &M) {
80 PreservedAnalyses GlobalDCEPass::run(Module &M, ModuleAnalysisManager &) {
8081 bool Changed = false;
8182
8283 // Remove empty functions from the global ctors list.
5252 return MadeChange;
5353 }
5454
55 PreservedAnalyses StripDeadPrototypesPass::run(Module &M) {
55 PreservedAnalyses StripDeadPrototypesPass::run(Module &M,
56 ModuleAnalysisManager &) {
5657 if (stripDeadPrototypes(M))
5758 return PreservedAnalyses::none();
5859 return PreservedAnalyses::all();
279279 return new WholeProgramDevirt;
280280 }
281281
282 PreservedAnalyses WholeProgramDevirtPass::run(Module &M) {
282 PreservedAnalyses WholeProgramDevirtPass::run(Module &M,
283 ModuleAnalysisManager &) {
283284 if (!DevirtModule(M).run())
284285 return PreservedAnalyses::all();
285286 return PreservedAnalyses::none();
144144 return !Worklist.empty();
145145 }
146146
147 PreservedAnalyses ADCEPass::run(Function &F) {
147 PreservedAnalyses ADCEPass::run(Function &F, FunctionAnalysisManager &) {
148148 if (!aggressiveDCE(F))
149149 return PreservedAnalyses::all();
150150
138138 return Changed;
139139 }
140140
141 PreservedAnalyses LowerAtomicPass::run(Function &F) {
141 PreservedAnalyses LowerAtomicPass::run(Function &F, FunctionAnalysisManager &) {
142142 if (lowerAtomics(F))
143143 return PreservedAnalyses::none();
144144 return PreservedAnalyses::all();
156156 bool runOnFunction(Function &F) override {
157157 if (skipFunction(F))
158158 return false;
159 auto PA = Impl.run(F);
159 FunctionAnalysisManager DummyFAM;
160 auto PA = Impl.run(F, DummyFAM);
160161 return !PA.areAllPreserved();
161162 }
162163
169169 return Changed;
170170 }
171171
172 PreservedAnalyses LowerExpectIntrinsicPass::run(Function &F) {
172 PreservedAnalyses LowerExpectIntrinsicPass::run(Function &F,
173 FunctionAnalysisManager &) {
173174 if (lowerExpectIntrinsic(F))
174175 return PreservedAnalyses::none();
175176
21722172 RewriteExprTree(I, Ops);
21732173 }
21742174
2175 PreservedAnalyses ReassociatePass::run(Function &F) {
2175 PreservedAnalyses ReassociatePass::run(Function &F, FunctionAnalysisManager &) {
21762176 // Reassociate needs for each instruction to have its operands already
21772177 // processed, so we first perform a RPOT of the basic blocks so that
21782178 // when we process a basic block, all its dominators have been processed
22502250 if (skipFunction(F))
22512251 return false;
22522252
2253 auto PA = Impl.run(F);
2253 FunctionAnalysisManager DummyFAM;
2254 auto PA = Impl.run(F, DummyFAM);
22542255 return !PA.areAllPreserved();
22552256 }
22562257
198198 struct TestFunctionPass {
199199 TestFunctionPass(int &RunCount) : RunCount(RunCount) {}
200200
201 PreservedAnalyses run(Function &M) {
201 PreservedAnalyses run(Function &F, AnalysisManager &) {
202202 ++RunCount;
203203 return PreservedAnalyses::none();
204204 }
7676 struct TestModulePass : PassInfoMixin {
7777 TestModulePass(int &RunCount) : RunCount(RunCount) {}
7878
79 PreservedAnalyses run(Module &M) {
79 PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
8080 ++RunCount;
8181 return PreservedAnalyses::none();
8282 }
8585 };
8686
8787 struct TestPreservingModulePass : PassInfoMixin {
88 PreservedAnalyses run(Module &M) { return PreservedAnalyses::all(); }
88 PreservedAnalyses run(Module &M, ModuleAnalysisManager &) {
89 return PreservedAnalyses::all();
90 }
8991 };
9092
9193 struct TestMinPreservingModulePass
144146 : PassInfoMixin {
145147 TestInvalidationFunctionPass(StringRef FunctionName) : Name(FunctionName) {}
146148
147 PreservedAnalyses run(Function &F) {
149 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM) {
148150 return F.getName() == Name ? PreservedAnalyses::none()
149151 : PreservedAnalyses::all();
150152 }