[llvm] [Instrumentation] Support MachineFunctionProperties (PR #83668)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 09:56:30 PST 2024
aeubanks wrote:
a general question, is `MachineFunctionProperties` only used for verification? if that's the case, I'd actually rather keep the verification in `MachineFunctionPassManager::run()` so pass instrumentation doesn't have to know about pass manager internals
e.g.
```
diff --git a/llvm/include/llvm/CodeGen/MachinePassManager.h b/llvm/include/llvm/CodeGen/MachinePassManager.h
index 7713c55661cc..c563078be836 100644
--- a/llvm/include/llvm/CodeGen/MachinePassManager.h
+++ b/llvm/include/llvm/CodeGen/MachinePassManager.h
@@ -283,6 +283,18 @@ template <>
PreservedAnalyses
PassManager<MachineFunction>::run(MachineFunction &,
AnalysisManager<MachineFunction> &);
+template <>
+template <typename PassT>
+LLVM_ATTRIBUTE_MINSIZE
+ std::enable_if_t<!std::is_same<PassT, PassManager<MachineFunction>>::value>
+ PassManager<MachineFunction>::addPass(PassT &&Pass) {
+ using MachinePassModelT = detail::MachinePassModel<PassT>;
+ // Do not use make_unique or emplace_back, they cause too many template
+ // instantiations, causing terrible compile times.
+ Passes.push_back(std::unique_ptr<detail::MachinePassConcept>(
+ new MachinePassModelT(std::forward<PassT>(Pass))));
+}
+
extern template class PassManager<MachineFunction>;
/// Convenience typedef for a pass manager over functions.
diff --git a/llvm/lib/CodeGen/MachinePassManager.cpp b/llvm/lib/CodeGen/MachinePassManager.cpp
index 9a750b5bed43..db00f5c2aa1a 100644
--- a/llvm/lib/CodeGen/MachinePassManager.cpp
+++ b/llvm/lib/CodeGen/MachinePassManager.cpp
@@ -119,6 +119,10 @@ PassManager<MachineFunction>::run(MachineFunction &MF,
->getMMI();
PreservedAnalyses PA = PreservedAnalyses::all();
for (auto &Pass : Passes) {
+ // TODO: use in verification
+ (void)static_cast<detail::MachinePassConcept *>(Pass.get())
+ ->getClearedProperties();
+
if (!PI.runBeforePass<MachineFunction>(*Pass, MF))
continue;
```
https://github.com/llvm/llvm-project/pull/83668
More information about the llvm-commits
mailing list