@@ -87,6 +87,12 @@ struct MachinePassInfoMixin : public PassInfoMixin<DerivedT> {
87
87
MF.getProperties ().reset (DerivedT::getClearedProperties ());
88
88
}
89
89
};
90
+
91
+ PreservedAnalyses run (MachineFunction &MF,
92
+ MachineFunctionAnalysisManager &MFAM) {
93
+ PropertyChanger PC (MF);
94
+ return static_cast <DerivedT *>(this )->run (MF, MFAM);
95
+ }
90
96
};
91
97
92
98
using MachineFunctionAnalysisManagerModuleProxy =
@@ -210,6 +216,27 @@ createModuleToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass) {
210
216
new PassModelT (std::forward<MachineFunctionPassT>(Pass))));
211
217
}
212
218
219
+ template <>
220
+ template <typename PassT>
221
+ std::enable_if_t <!std::is_same<PassT, PassManager<MachineFunction>>::value>
222
+ PassManager<MachineFunction>::addPass (PassT &&Pass) {
223
+ using PassModelT =
224
+ detail::PassModel<MachineFunction, PassT, MachineFunctionAnalysisManager>;
225
+ using MachineFunctionPassModelT =
226
+ detail::PassModel<MachineFunction, MachinePassInfoMixin<PassT>,
227
+ MachineFunctionAnalysisManager>;
228
+ // Do not use make_unique or emplace_back, they cause too many template
229
+ // instantiations, causing terrible compile times.
230
+ if constexpr (std::is_base_of_v<MachinePassInfoMixin<PassT>, PassT>) {
231
+ Passes.push_back (
232
+ std::unique_ptr<PassConceptT>(new MachineFunctionPassModelT (
233
+ std::forward<MachinePassInfoMixin<PassT>>(Pass))));
234
+ } else {
235
+ Passes.push_back (
236
+ std::unique_ptr<PassConceptT>(new PassModelT (std::forward (Pass))));
237
+ }
238
+ }
239
+
213
240
template <>
214
241
PreservedAnalyses
215
242
PassManager<MachineFunction>::run (MachineFunction &,
0 commit comments