[llvm] 122ed55 - [CodeGen] Remove MachinePassKey (#79406)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 24 23:44:28 PST 2024
Author: paperchalice
Date: 2024-01-25T15:44:24+08:00
New Revision: 122ed552fc5d5807f2a96b8456b42f5114cd1a79
URL: https://github.com/llvm/llvm-project/commit/122ed552fc5d5807f2a96b8456b42f5114cd1a79
DIFF: https://github.com/llvm/llvm-project/commit/122ed552fc5d5807f2a96b8456b42f5114cd1a79.diff
LOG: [CodeGen] Remove MachinePassKey (#79406)
We now use PassT::name to distinguish Passes.
Added:
Modified:
llvm/include/llvm/CodeGen/MachinePassManager.h
llvm/include/llvm/Passes/CodeGenPassBuilder.h
llvm/lib/Passes/CodeGenPassBuilder.cpp
llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CodeGen/MachinePassManager.h b/llvm/include/llvm/CodeGen/MachinePassManager.h
index a2641a8223646db..662b7e8689717dc 100644
--- a/llvm/include/llvm/CodeGen/MachinePassManager.h
+++ b/llvm/include/llvm/CodeGen/MachinePassManager.h
@@ -37,20 +37,13 @@ class MachineFunction;
extern template class AnalysisManager<MachineFunction>;
-/// Like \c AnalysisKey, but only for machine passes.
-struct alignas(8) MachinePassKey {};
-
/// A CRTP mix-in that provides informational APIs needed for machine passes.
///
/// This provides some boilerplate for types that are machine passes. It
/// automatically mixes in \c PassInfoMixin.
template <typename DerivedT>
struct MachinePassInfoMixin : public PassInfoMixin<DerivedT> {
- static MachinePassKey *ID() {
- static_assert(std::is_base_of<MachinePassInfoMixin, DerivedT>::value,
- "Must pass the derived type as the template argument!");
- return &DerivedT::Key;
- }
+ // TODO: Add MachineFunctionProperties support.
};
/// An AnalysisManager<MachineFunction> that also exposes IR analysis results.
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 07afac3bcf8401f..c5c53a5bccae73b 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -94,7 +94,6 @@ namespace llvm {
MachineFunctionAnalysisManager &) { \
llvm_unreachable("this api is to make new PM api happy"); \
} \
- static MachinePassKey Key; \
};
#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
struct PASS_NAME : public MachinePassInfoMixin<PASS_NAME> { \
@@ -103,7 +102,6 @@ namespace llvm {
MachineFunctionAnalysisManager &) { \
return PreservedAnalyses::all(); \
} \
- static MachinePassKey Key; \
};
#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
struct PASS_NAME : public AnalysisInfoMixin<PASS_NAME> { \
@@ -164,8 +162,6 @@ template <typename DerivedT> class CodeGenPassBuilder {
}
protected:
- template <typename PassT> using has_key_t = decltype(PassT::Key);
-
template <typename PassT>
using is_module_pass_t = decltype(std::declval<PassT &>().run(
std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
@@ -225,10 +221,6 @@ template <typename DerivedT> class CodeGenPassBuilder {
: PM(PM), PB(PB) {}
template <typename PassT> void operator()(PassT &&Pass) {
- static_assert(
- is_detected<has_key_t, PassT>::value,
- "Machine function pass must define a static member variable `Key`.");
-
if (!PB.runBeforeAdding(PassT::name()))
return;
@@ -238,10 +230,10 @@ template <typename DerivedT> class CodeGenPassBuilder {
C(PassT::name());
}
- template <typename PassT> void insertPass(MachinePassKey *ID, PassT Pass) {
+ template <typename PassT> void insertPass(StringRef PassName, PassT Pass) {
PB.AfterCallbacks.emplace_back(
- [this, ID, Pass = std::move(Pass)](MachinePassKey *PassID) {
- if (PassID == ID)
+ [this, PassName, Pass = std::move(Pass)](StringRef Name) {
+ if (PassName == Name)
this->PM.addPass(std::move(Pass));
});
}
diff --git a/llvm/lib/Passes/CodeGenPassBuilder.cpp b/llvm/lib/Passes/CodeGenPassBuilder.cpp
index c0319e5d6e404a3..927727cba6fc6c8 100644
--- a/llvm/lib/Passes/CodeGenPassBuilder.cpp
+++ b/llvm/lib/Passes/CodeGenPassBuilder.cpp
@@ -16,11 +16,6 @@
using namespace llvm;
namespace llvm {
-#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- MachinePassKey PASS_NAME::Key;
-#include "llvm/Passes/MachinePassRegistry.def"
-#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- MachinePassKey PASS_NAME::Key;
#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
AnalysisKey PASS_NAME::Key;
#include "llvm/Passes/MachinePassRegistry.def"
diff --git a/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp b/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
index 5ab4df1c26df3ef..88522d45bc6bfa9 100644
--- a/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
+++ b/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
@@ -248,7 +248,6 @@ template <typename DerivedT> class MockPassHandleBase {
}
public:
- static MachinePassKey Key;
PreservedAnalyses run(MachineFunction &IR,
MachineFunctionAnalysisManager::Base &AM) {
return Handle->run(IR, AM);
@@ -279,9 +278,6 @@ struct MockAnalysisHandle : public MockAnalysisHandleBase<MockAnalysisHandle> {
MockAnalysisHandle() { setDefaults(); }
};
-template <typename DerivedT>
-MachinePassKey MockPassHandleBase<DerivedT>::Pass::Key;
-
template <typename DerivedT>
AnalysisKey MockAnalysisHandleBase<DerivedT>::Analysis::Key;
More information about the llvm-commits
mailing list