Skip to content

Commit 8173bbf

Browse files
paperchalicearsenm
andcommitted
Update llvm/test/tools/llc/new-pm/machine-function-properties.mir
Co-authored-by: Matt Arsenault <[email protected]>
1 parent d2d3dfa commit 8173bbf

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

llvm/include/llvm/CodeGen/MachinePassManager.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ struct MachinePassInfoMixin : public PassInfoMixin<DerivedT> {
8787
MF.getProperties().reset(DerivedT::getClearedProperties());
8888
}
8989
};
90+
91+
PreservedAnalyses run(MachineFunction &MF,
92+
MachineFunctionAnalysisManager &MFAM) {
93+
PropertyChanger PC(MF);
94+
return static_cast<DerivedT *>(this)->run(MF, MFAM);
95+
}
9096
};
9197

9298
using MachineFunctionAnalysisManagerModuleProxy =
@@ -210,6 +216,27 @@ createModuleToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass) {
210216
new PassModelT(std::forward<MachineFunctionPassT>(Pass))));
211217
}
212218

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(std::unique_ptr<PassConceptT>(
236+
new PassModelT(std::forward<PassT>(Pass))));
237+
}
238+
}
239+
213240
template <>
214241
PreservedAnalyses
215242
PassManager<MachineFunction>::run(MachineFunction &,

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ class RequireAllMachineFunctionPropertiesPass
371371
: public MachinePassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
372372
public:
373373
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &) {
374-
PropertyChanger PC(MF);
375374
return PreservedAnalyses::none();
376375
}
377376

llvm/test/tools/llc/new-pm/machine-function-properties.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# REQUIRES: asserts
2-
# RUN: not --crash llc -mtriple=x86_64-pc-linux-gnu -x mir -passes=require-all-machine-function-properties -filetype=null < %s 2>&1 | FileCheck %s
2+
# RUN: not --crash llc -mtriple=x86_64-pc-linux-gnu -passes=require-all-machine-function-properties -filetype=null %s 2>&1 | FileCheck %s
33

44
# CHECK: MachineFunctionProperties required by RequireAllMachineFunctionPropertiesPass pass are not met by function f.
55

0 commit comments

Comments
 (0)