[llvm] 942cb24 - [CodeGen][NewPM] Consolidate PASS_NAME and CONSTRUCTOR in MachinePassRegistry.def (#80779)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 20:17:13 PST 2024
Author: Arthur Eubanks
Date: 2024-02-05T20:17:09-08:00
New Revision: 942cb2427a0e19f63b2f5b7da3d3fa6a594df3fe
URL: https://github.com/llvm/llvm-project/commit/942cb2427a0e19f63b2f5b7da3d3fa6a594df3fe
DIFF: https://github.com/llvm/llvm-project/commit/942cb2427a0e19f63b2f5b7da3d3fa6a594df3fe.diff
LOG: [CodeGen][NewPM] Consolidate PASS_NAME and CONSTRUCTOR in MachinePassRegistry.def (#80779)
This matches the optimization pipeline's PassRegistry.def.
I ran into a bug where CONSTRUCTOR wasn't always being used (in
PassBuilder::registerMachineFunctionAnalyses()).
Make DUMMY_* just accept a pass name, there's no point in having proper
constructors if the generated dummy class has a templated constructor
accepting arbitrary arguments.
Remove unused getPassNameFromLegacyName() as it was using this but for
no purpose.
Remove DUMMY_MACHINE_FUNCTION_ANALYSIS, we can just add those as we port
them.
This for some reason exposed missing mock calls in existing unittests.
Added:
Modified:
llvm/include/llvm/Passes/CodeGenPassBuilder.h
llvm/include/llvm/Passes/MachinePassRegistry.def
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/Passes/CodeGenPassBuilder.cpp
llvm/lib/Passes/PassBuilder.cpp
llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
index 2c8073ad551b74..40cc0c046531ad 100644
--- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h
+++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h
@@ -78,14 +78,14 @@ namespace llvm {
// FIXME: Dummy target independent passes definitions that have not yet been
// ported to new pass manager. Once they do, remove these.
-#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
+#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME) \
struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
template <typename... Ts> PASS_NAME(Ts &&...) {} \
PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
return PreservedAnalyses::all(); \
} \
};
-#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
+#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME) \
struct PASS_NAME : public MachinePassInfoMixin<PASS_NAME> { \
template <typename... Ts> PASS_NAME(Ts &&...) {} \
Error run(Module &, MachineFunctionAnalysisManager &) { \
@@ -96,7 +96,7 @@ namespace llvm {
llvm_unreachable("this api is to make new PM api happy"); \
} \
};
-#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
+#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME) \
struct PASS_NAME : public MachinePassInfoMixin<PASS_NAME> { \
template <typename... Ts> PASS_NAME(Ts &&...) {} \
PreservedAnalyses run(MachineFunction &, \
@@ -104,17 +104,6 @@ namespace llvm {
return PreservedAnalyses::all(); \
} \
};
-#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- struct PASS_NAME : public AnalysisInfoMixin<PASS_NAME> { \
- template <typename... Ts> PASS_NAME(Ts &&...) {} \
- using Result = struct {}; \
- template <typename IRUnitT, typename AnalysisManagerT, \
- typename... ExtraArgTs> \
- Result run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) { \
- return {}; \
- } \
- static AnalysisKey Key; \
- };
#include "llvm/Passes/MachinePassRegistry.def"
/// This class provides access to building LLVM's passes.
@@ -150,7 +139,6 @@ template <typename DerivedT> class CodeGenPassBuilder {
void registerModuleAnalyses(ModuleAnalysisManager &) const;
void registerFunctionAnalyses(FunctionAnalysisManager &) const;
void registerMachineFunctionAnalyses(MachineFunctionAnalysisManager &) const;
- std::pair<StringRef, bool> getPassNameFromLegacyName(StringRef) const;
void registerAnalyses(MachineFunctionAnalysisManager &MFAM) const {
registerModuleAnalyses(*MFAM.MAM);
@@ -608,8 +596,8 @@ static inline AAManager registerAAAnalyses() {
template <typename Derived>
void CodeGenPassBuilder<Derived>::registerModuleAnalyses(
ModuleAnalysisManager &MAM) const {
-#define MODULE_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- MAM.registerPass([&] { return PASS_NAME CONSTRUCTOR; });
+#define MODULE_ANALYSIS(NAME, CREATE_PASS) \
+ MAM.registerPass([&] { return CREATE_PASS; });
#include "MachinePassRegistry.def"
derived().registerTargetAnalysis(MAM);
}
@@ -619,8 +607,8 @@ void CodeGenPassBuilder<Derived>::registerFunctionAnalyses(
FunctionAnalysisManager &FAM) const {
FAM.registerPass([this] { return registerAAAnalyses(); });
-#define FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- FAM.registerPass([&] { return PASS_NAME CONSTRUCTOR; });
+#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
+ FAM.registerPass([&] { return CREATE_PASS; });
#include "MachinePassRegistry.def"
derived().registerTargetAnalysis(FAM);
}
@@ -628,59 +616,12 @@ void CodeGenPassBuilder<Derived>::registerFunctionAnalyses(
template <typename Derived>
void CodeGenPassBuilder<Derived>::registerMachineFunctionAnalyses(
MachineFunctionAnalysisManager &MFAM) const {
-#define MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- MFAM.registerPass([&] { return PASS_NAME CONSTRUCTOR; });
+#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
+ MFAM.registerPass([&] { return CREATE_PASS; });
#include "MachinePassRegistry.def"
derived().registerTargetAnalysis(MFAM);
}
-// FIXME: For new PM, use pass name directly in commandline seems good.
-// Translate stringfied pass name to its old commandline name. Returns the
-// matching legacy name and a boolean value indicating if the pass is a machine
-// pass.
-template <typename Derived>
-std::pair<StringRef, bool>
-CodeGenPassBuilder<Derived>::getPassNameFromLegacyName(StringRef Name) const {
- std::pair<StringRef, bool> Ret;
- if (Name.empty())
- return Ret;
-
-#define FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, false};
-#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, false};
-#define MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, false};
-#define DUMMY_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, false};
-#define MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, true};
-#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, true};
-#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, true};
-#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- if (Name == NAME) \
- Ret = {#PASS_NAME, true};
-#include "llvm/Passes/MachinePassRegistry.def"
-
- if (Ret.first.empty())
- Ret = derived().getTargetPassNameFromLegacyName(Name);
-
- if (Ret.first.empty())
- report_fatal_error(Twine('\"') + Twine(Name) +
- Twine("\" pass could not be found."));
-
- return Ret;
-}
-
template <typename Derived>
void CodeGenPassBuilder<Derived>::addISelPasses(AddIRPass &addPass) const {
derived().addGlobalMergePass(addPass);
diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def
index e311682a56192e..5c3d2659fdfb7e 100644
--- a/llvm/include/llvm/Passes/MachinePassRegistry.def
+++ b/llvm/include/llvm/Passes/MachinePassRegistry.def
@@ -14,84 +14,82 @@
// NOTE: NO INCLUDE GUARD DESIRED!
#ifndef MODULE_ANALYSIS
-#define MODULE_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR)
+#define MODULE_ANALYSIS(NAME, CREATE_PASS)
#endif
-MODULE_ANALYSIS("collector-metadata", CollectorMetadataAnalysis, ())
-MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis, (PIC))
+MODULE_ANALYSIS("collector-metadata", CollectorMetadataAnalysis())
+MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
#undef MODULE_ANALYSIS
#ifndef MODULE_PASS
-#define MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define MODULE_PASS(NAME, CREATE_PASS)
#endif
-MODULE_PASS("global-merge", GlobalMergePass, (TM, GlobalMergeOptions()))
-MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass, ())
-MODULE_PASS("lower-emutls", LowerEmuTLSPass, ())
-MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass, ())
-MODULE_PASS("shadow-stack-gc-lowering", ShadowStackGCLoweringPass, ())
+MODULE_PASS("global-merge", GlobalMergePass(TM, GlobalMergeOptions()))
+MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
+MODULE_PASS("lower-emutls", LowerEmuTLSPass())
+MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass())
+MODULE_PASS("shadow-stack-gc-lowering", ShadowStackGCLoweringPass())
#undef MODULE_PASS
#ifndef FUNCTION_ANALYSIS
-#define FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR)
+#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
#endif
-FUNCTION_ANALYSIS("gc-function", GCFunctionAnalysis, ())
-FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis, (PIC))
-FUNCTION_ANALYSIS("ssp-layout", SSPLayoutAnalysis, ())
-FUNCTION_ANALYSIS("target-ir", TargetIRAnalysis,
- (std::move(TM.getTargetIRAnalysis())))
+FUNCTION_ANALYSIS("gc-function", GCFunctionAnalysis())
+FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
+FUNCTION_ANALYSIS("ssp-layout", SSPLayoutAnalysis())
+FUNCTION_ANALYSIS("target-ir", TargetIRAnalysis(std::move(TM.getTargetIRAnalysis())))
#undef FUNCTION_ANALYSIS
#ifndef FUNCTION_PASS
-#define FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define FUNCTION_PASS(NAME, CREATE_PASS)
#endif
-FUNCTION_PASS("callbr-prepare", CallBrPreparePass, ())
-FUNCTION_PASS("cfguard", CFGuardPass, ())
-FUNCTION_PASS("codegenprepare", CodeGenPreparePass, (TM))
-FUNCTION_PASS("consthoist", ConstantHoistingPass, ())
-FUNCTION_PASS("dwarf-eh-prepare", DwarfEHPreparePass, (TM))
-FUNCTION_PASS("ee-instrument", EntryExitInstrumenterPass, (false))
-FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass, (TM))
-FUNCTION_PASS("expand-large-fp-convert", ExpandLargeFpConvertPass, (TM))
-FUNCTION_PASS("expand-memcmp", ExpandMemCmpPass, (TM))
-FUNCTION_PASS("expand-reductions", ExpandReductionsPass, ())
-FUNCTION_PASS("expandvp", ExpandVectorPredicationPass, ())
-FUNCTION_PASS("gc-lowering", GCLoweringPass, ())
-FUNCTION_PASS("indirectbr-expand", IndirectBrExpandPass, (TM))
-FUNCTION_PASS("interleaved-access", InterleavedAccessPass, (TM))
-FUNCTION_PASS("interleaved-load-combine", InterleavedLoadCombinePass, (TM))
-FUNCTION_PASS("lower-constant-intrinsics", LowerConstantIntrinsicsPass, ())
-FUNCTION_PASS("lower-invoke", LowerInvokePass, ())
-FUNCTION_PASS("mergeicmps", MergeICmpsPass, ())
-FUNCTION_PASS("partially-inline-libcalls", PartiallyInlineLibCallsPass, ())
-FUNCTION_PASS("post-inline-ee-instrument", EntryExitInstrumenterPass, (true))
-FUNCTION_PASS("replace-with-veclib", ReplaceWithVeclib, ())
-FUNCTION_PASS("safe-stack", SafeStackPass, (TM))
-FUNCTION_PASS("scalarize-masked-mem-intrin", ScalarizeMaskedMemIntrinPass, ())
-FUNCTION_PASS("select-optimize", SelectOptimizePass, (TM))
-FUNCTION_PASS("sjlj-eh-prepare", SjLjEHPreparePass, (TM))
-FUNCTION_PASS("stack-protector", StackProtectorPass, (TM))
-FUNCTION_PASS("tlshoist", TLSVariableHoistPass, ())
-FUNCTION_PASS("unreachableblockelim", UnreachableBlockElimPass, ())
-FUNCTION_PASS("verify", VerifierPass, ())
-FUNCTION_PASS("wasm-eh-prepare", WasmEHPreparePass, ())
-FUNCTION_PASS("win-eh-prepare", WinEHPreparePass, ())
+FUNCTION_PASS("callbr-prepare", CallBrPreparePass())
+FUNCTION_PASS("cfguard", CFGuardPass())
+FUNCTION_PASS("codegenprepare", CodeGenPreparePass(TM))
+FUNCTION_PASS("consthoist", ConstantHoistingPass())
+FUNCTION_PASS("dwarf-eh-prepare", DwarfEHPreparePass(TM))
+FUNCTION_PASS("ee-instrument", EntryExitInstrumenterPass(false))
+FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(TM))
+FUNCTION_PASS("expand-large-fp-convert", ExpandLargeFpConvertPass(TM))
+FUNCTION_PASS("expand-memcmp", ExpandMemCmpPass(TM))
+FUNCTION_PASS("expand-reductions", ExpandReductionsPass())
+FUNCTION_PASS("expandvp", ExpandVectorPredicationPass())
+FUNCTION_PASS("gc-lowering", GCLoweringPass())
+FUNCTION_PASS("indirectbr-expand", IndirectBrExpandPass(TM))
+FUNCTION_PASS("interleaved-access", InterleavedAccessPass(TM))
+FUNCTION_PASS("interleaved-load-combine", InterleavedLoadCombinePass(TM))
+FUNCTION_PASS("lower-constant-intrinsics", LowerConstantIntrinsicsPass())
+FUNCTION_PASS("lower-invoke", LowerInvokePass())
+FUNCTION_PASS("mergeicmps", MergeICmpsPass())
+FUNCTION_PASS("partially-inline-libcalls", PartiallyInlineLibCallsPass())
+FUNCTION_PASS("post-inline-ee-instrument", EntryExitInstrumenterPass(true))
+FUNCTION_PASS("replace-with-veclib", ReplaceWithVeclib())
+FUNCTION_PASS("safe-stack", SafeStackPass(TM))
+FUNCTION_PASS("scalarize-masked-mem-intrin", ScalarizeMaskedMemIntrinPass())
+FUNCTION_PASS("select-optimize", SelectOptimizePass(TM))
+FUNCTION_PASS("sjlj-eh-prepare", SjLjEHPreparePass(TM))
+FUNCTION_PASS("stack-protector", StackProtectorPass(TM))
+FUNCTION_PASS("tlshoist", TLSVariableHoistPass())
+FUNCTION_PASS("unreachableblockelim", UnreachableBlockElimPass())
+FUNCTION_PASS("verify", VerifierPass())
+FUNCTION_PASS("wasm-eh-prepare", WasmEHPreparePass())
+FUNCTION_PASS("win-eh-prepare", WinEHPreparePass())
#undef FUNCTION_PASS
#ifndef LOOP_PASS
-#define LOOP_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define LOOP_PASS(NAME, CREATE_PASS)
#endif
-LOOP_PASS("loop-reduce", LoopStrengthReducePass, ())
+LOOP_PASS("loop-reduce", LoopStrengthReducePass())
#undef LOOP_PASS
#ifndef MACHINE_MODULE_PASS
-#define MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define MACHINE_MODULE_PASS(NAME, CREATE_PASS)
#endif
#undef MACHINE_MODULE_PASS
#ifndef MACHINE_FUNCTION_ANALYSIS
-#define MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR)
+#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS)
#endif
-MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis,
- (PIC))
+MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
// LiveVariables currently requires pure SSA form.
// FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
// LiveVariables can be removed completely, and LiveIntervals can be directly
@@ -123,11 +121,11 @@ MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis,
#undef MACHINE_FUNCTION_ANALYSIS
#ifndef MACHINE_FUNCTION_PASS
-#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
#endif
-// MACHINE_FUNCTION_PASS("free-machine-function", FreeMachineFunctionPass, ())
-MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass, ())
-MACHINE_FUNCTION_PASS("print", PrintMIRPass, ())
+// MACHINE_FUNCTION_PASS("free-machine-function", FreeMachineFunctionPass())
+MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
+MACHINE_FUNCTION_PASS("print", PrintMIRPass())
#undef MACHINE_FUNCTION_PASS
// After a pass is converted to new pass manager, its entry should be moved from
@@ -135,130 +133,101 @@ MACHINE_FUNCTION_PASS("print", PrintMIRPass, ())
// DUMMY_MACHINE_FUNCTION_PASS to MACHINE_FUNCTION_PASS.
#ifndef DUMMY_FUNCTION_PASS
-#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME)
#endif
-DUMMY_FUNCTION_PASS("atomic-expand", AtomicExpandPass, ())
+DUMMY_FUNCTION_PASS("atomic-expand", AtomicExpandPass)
#undef DUMMY_FUNCTION_PASS
#ifndef DUMMY_MACHINE_MODULE_PASS
-#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME)
#endif
-DUMMY_MACHINE_MODULE_PASS("machine-outliner", MachineOutlinerPass, ())
-DUMMY_MACHINE_MODULE_PASS("pseudo-probe-inserter", PseudoProbeInserterPass, ())
-DUMMY_MACHINE_MODULE_PASS("mir-debugify", DebugifyMachineModule, ())
-DUMMY_MACHINE_MODULE_PASS("mir-check-debugify", CheckDebugMachineModulePass, ())
-DUMMY_MACHINE_MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass,
- (OnlyDebugified))
+DUMMY_MACHINE_MODULE_PASS("machine-outliner", MachineOutlinerPass)
+DUMMY_MACHINE_MODULE_PASS("pseudo-probe-inserter", PseudoProbeInserterPass)
+DUMMY_MACHINE_MODULE_PASS("mir-debugify", DebugifyMachineModule)
+DUMMY_MACHINE_MODULE_PASS("mir-check-debugify", CheckDebugMachineModulePass)
+DUMMY_MACHINE_MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass)
#undef DUMMY_MACHINE_MODULE_PASS
#ifndef DUMMY_MACHINE_FUNCTION_PASS
-#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR)
+#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME)
#endif
-DUMMY_MACHINE_FUNCTION_PASS("bbsections-prepare", BasicBlockSectionsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("bbsections-profile-reader",
- BasicBlockSectionsProfileReaderPass, (Buf))
-DUMMY_MACHINE_FUNCTION_PASS("block-placement", MachineBlockPlacementPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("block-placement-stats",
- MachineBlockPlacementStatsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("branch-folder", BranchFolderPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("break-false-deps", BreakFalseDepsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("cfguard-longjmp", CFGuardLongjmpPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("cfi-fixup", CFIFixupPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("cfi-instr-inserter", CFIInstrInserterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("dead-mi-elimination",
- DeadMachineInstructionElimPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("detect-dead-lanes", DetectDeadLanesPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("dot-machine-cfg", MachineCFGPrinter, ())
-DUMMY_MACHINE_FUNCTION_PASS("early-ifcvt", EarlyIfConverterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("early-machinelicm", EarlyMachineLICMPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("early-tailduplication", EarlyTailDuplicatePass, ())
-DUMMY_MACHINE_FUNCTION_PASS("fentry-insert", FEntryInserterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("finalize-isel", FinalizeISelPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("fixup-statepoint-caller-saved",
- FixupStatepointCallerSavedPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("fs-profile-loader", MIRProfileLoaderNewPass,
- (File, ProfileFile, P, FS))
-DUMMY_MACHINE_FUNCTION_PASS("funclet-layout", FuncletLayoutPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("gc-empty-basic-blocks", GCEmptyBasicBlocksPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("implicit-null-checks", ImplicitNullChecksPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("instruction-select", InstructionSelectPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("legalizer", LegalizerPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("livedebugvalues", LiveDebugValuesPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("liveintervals", LiveIntervalsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("localstackalloc", LocalStackSlotPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("lrshrink", LiveRangeShrinkPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-combiner", MachineCombinerPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-cp", MachineCopyPropagationPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-cse", MachineCSEPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-function-splitter",
- MachineFunctionSplitterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-latecleanup", MachineLateInstrsCleanupPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-sanmd", MachineSanitizerBinaryMetadata, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-scheduler", MachineSchedulerPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-sink", MachineSinkingPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machine-uniformity",
- MachineUniformityInfoWrapperPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machineinstr-printer", MachineFunctionPrinterPass,
- (OS, Banner))
-DUMMY_MACHINE_FUNCTION_PASS("machinelicm", MachineLICMPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("machineverifier", MachineVerifierPass, (Banner))
-DUMMY_MACHINE_FUNCTION_PASS("mirfs-discriminators", MIRAddFSDiscriminatorsPass,
- (P))
-DUMMY_MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("patchable-function", PatchableFunctionPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("post-RA-sched", PostRASchedulerPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("postmisched", PostMachineSchedulerPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("postra-machine-sink", PostRAMachineSinkingPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("postrapseudos", ExpandPostRAPseudosPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("print-machine-cycles", MachineCycleInfoPrinterPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("print-machine-uniformity",
- MachineUniformityInfoPrinterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("processimpdefs", ProcessImplicitDefsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("prologepilog", PrologEpilogInserterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("prologepilog-code", PrologEpilogCodeInserterPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("ra-basic", RABasicPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("ra-fast", RAFastPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("ra-greedy", RAGreedyPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("ra-pbqp", RAPBQPPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("reg-usage-collector", RegUsageInfoCollectorPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("reg-usage-propagation",
- RegUsageInfoPropagationPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("regalloc", RegAllocPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("regallocscoringpass", RegAllocScoringPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("regbankselect", RegBankSelectPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("removeredundantdebugvalues",
- RemoveRedundantDebugValuesPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("rename-independent-subregs",
- RenameIndependentSubregsPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("reset-machine-function", ResetMachineFunctionPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("shrink-wrap", ShrinkWrapPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("simple-register-coalescing", RegisterCoalescerPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("stack-coloring", StackColoringPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("stack-frame-layout", StackFrameLayoutAnalysisPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("stack-slot-coloring", StackSlotColoringPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("stackmap-liveness", StackMapLivenessPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("tailduplication", TailDuplicatePass, ())
-DUMMY_MACHINE_FUNCTION_PASS("twoaddressinstruction", TwoAddressInstructionPass,
- ())
-DUMMY_MACHINE_FUNCTION_PASS("unpack-mi-bundles", UnpackMachineBundlesPass,
- (Ftor))
-DUMMY_MACHINE_FUNCTION_PASS("virtregrewriter", VirtRegRewriterPass, ())
-DUMMY_MACHINE_FUNCTION_PASS("xray-instrumentation", XRayInstrumentationPass, ())
+DUMMY_MACHINE_FUNCTION_PASS("bbsections-prepare", BasicBlockSectionsPass)
+DUMMY_MACHINE_FUNCTION_PASS("bbsections-profile-reader", BasicBlockSectionsProfileReaderPass)
+DUMMY_MACHINE_FUNCTION_PASS("block-placement", MachineBlockPlacementPass)
+DUMMY_MACHINE_FUNCTION_PASS("block-placement-stats", MachineBlockPlacementStatsPass)
+DUMMY_MACHINE_FUNCTION_PASS("branch-folder", BranchFolderPass)
+DUMMY_MACHINE_FUNCTION_PASS("break-false-deps", BreakFalseDepsPass)
+DUMMY_MACHINE_FUNCTION_PASS("cfguard-longjmp", CFGuardLongjmpPass)
+DUMMY_MACHINE_FUNCTION_PASS("cfi-fixup", CFIFixupPass)
+DUMMY_MACHINE_FUNCTION_PASS("cfi-instr-inserter", CFIInstrInserterPass)
+DUMMY_MACHINE_FUNCTION_PASS("dead-mi-elimination", DeadMachineInstructionElimPass)
+DUMMY_MACHINE_FUNCTION_PASS("detect-dead-lanes", DetectDeadLanesPass)
+DUMMY_MACHINE_FUNCTION_PASS("dot-machine-cfg", MachineCFGPrinter)
+DUMMY_MACHINE_FUNCTION_PASS("early-ifcvt", EarlyIfConverterPass)
+DUMMY_MACHINE_FUNCTION_PASS("early-machinelicm", EarlyMachineLICMPass)
+DUMMY_MACHINE_FUNCTION_PASS("early-tailduplication", EarlyTailDuplicatePass)
+DUMMY_MACHINE_FUNCTION_PASS("fentry-insert", FEntryInserterPass)
+DUMMY_MACHINE_FUNCTION_PASS("finalize-isel", FinalizeISelPass)
+DUMMY_MACHINE_FUNCTION_PASS("fixup-statepoint-caller-saved", FixupStatepointCallerSavedPass)
+DUMMY_MACHINE_FUNCTION_PASS("fs-profile-loader", MIRProfileLoaderNewPass)
+DUMMY_MACHINE_FUNCTION_PASS("funclet-layout", FuncletLayoutPass)
+DUMMY_MACHINE_FUNCTION_PASS("gc-empty-basic-blocks", GCEmptyBasicBlocksPass)
+DUMMY_MACHINE_FUNCTION_PASS("implicit-null-checks", ImplicitNullChecksPass)
+DUMMY_MACHINE_FUNCTION_PASS("instruction-select", InstructionSelectPass)
+DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
+DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
+DUMMY_MACHINE_FUNCTION_PASS("legalizer", LegalizerPass)
+DUMMY_MACHINE_FUNCTION_PASS("livedebugvalues", LiveDebugValuesPass)
+DUMMY_MACHINE_FUNCTION_PASS("liveintervals", LiveIntervalsPass)
+DUMMY_MACHINE_FUNCTION_PASS("localstackalloc", LocalStackSlotPass)
+DUMMY_MACHINE_FUNCTION_PASS("lrshrink", LiveRangeShrinkPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-combiner", MachineCombinerPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-cp", MachineCopyPropagationPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-cse", MachineCSEPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-function-splitter", MachineFunctionSplitterPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-latecleanup", MachineLateInstrsCleanupPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-sanmd", MachineSanitizerBinaryMetadata)
+DUMMY_MACHINE_FUNCTION_PASS("machine-scheduler", MachineSchedulerPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-sink", MachineSinkingPass)
+DUMMY_MACHINE_FUNCTION_PASS("machine-uniformity", MachineUniformityInfoWrapperPass)
+DUMMY_MACHINE_FUNCTION_PASS("machineinstr-printer", MachineFunctionPrinterPass)
+DUMMY_MACHINE_FUNCTION_PASS("machinelicm", MachineLICMPass)
+DUMMY_MACHINE_FUNCTION_PASS("machineverifier", MachineVerifierPass)
+DUMMY_MACHINE_FUNCTION_PASS("mirfs-discriminators", MIRAddFSDiscriminatorsPass)
+DUMMY_MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass)
+DUMMY_MACHINE_FUNCTION_PASS("patchable-function", PatchableFunctionPass)
+DUMMY_MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass)
+DUMMY_MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass)
+DUMMY_MACHINE_FUNCTION_PASS("post-RA-sched", PostRASchedulerPass)
+DUMMY_MACHINE_FUNCTION_PASS("postmisched", PostMachineSchedulerPass)
+DUMMY_MACHINE_FUNCTION_PASS("postra-machine-sink", PostRAMachineSinkingPass)
+DUMMY_MACHINE_FUNCTION_PASS("postrapseudos", ExpandPostRAPseudosPass)
+DUMMY_MACHINE_FUNCTION_PASS("print-machine-cycles", MachineCycleInfoPrinterPass)
+DUMMY_MACHINE_FUNCTION_PASS("print-machine-uniformity", MachineUniformityInfoPrinterPass)
+DUMMY_MACHINE_FUNCTION_PASS("processimpdefs", ProcessImplicitDefsPass)
+DUMMY_MACHINE_FUNCTION_PASS("prologepilog", PrologEpilogInserterPass)
+DUMMY_MACHINE_FUNCTION_PASS("prologepilog-code", PrologEpilogCodeInserterPass)
+DUMMY_MACHINE_FUNCTION_PASS("ra-basic", RABasicPass)
+DUMMY_MACHINE_FUNCTION_PASS("ra-fast", RAFastPass)
+DUMMY_MACHINE_FUNCTION_PASS("ra-greedy", RAGreedyPass)
+DUMMY_MACHINE_FUNCTION_PASS("ra-pbqp", RAPBQPPass)
+DUMMY_MACHINE_FUNCTION_PASS("reg-usage-collector", RegUsageInfoCollectorPass)
+DUMMY_MACHINE_FUNCTION_PASS("reg-usage-propagation", RegUsageInfoPropagationPass)
+DUMMY_MACHINE_FUNCTION_PASS("regalloc", RegAllocPass)
+DUMMY_MACHINE_FUNCTION_PASS("regallocscoringpass", RegAllocScoringPass)
+DUMMY_MACHINE_FUNCTION_PASS("regbankselect", RegBankSelectPass)
+DUMMY_MACHINE_FUNCTION_PASS("removeredundantdebugvalues", RemoveRedundantDebugValuesPass)
+DUMMY_MACHINE_FUNCTION_PASS("rename-independent-subregs", RenameIndependentSubregsPass)
+DUMMY_MACHINE_FUNCTION_PASS("reset-machine-function", ResetMachineFunctionPass)
+DUMMY_MACHINE_FUNCTION_PASS("shrink-wrap", ShrinkWrapPass)
+DUMMY_MACHINE_FUNCTION_PASS("simple-register-coalescing", RegisterCoalescerPass)
+DUMMY_MACHINE_FUNCTION_PASS("stack-coloring", StackColoringPass)
+DUMMY_MACHINE_FUNCTION_PASS("stack-frame-layout", StackFrameLayoutAnalysisPass)
+DUMMY_MACHINE_FUNCTION_PASS("stack-slot-coloring", StackSlotColoringPass)
+DUMMY_MACHINE_FUNCTION_PASS("stackmap-liveness", StackMapLivenessPass)
+DUMMY_MACHINE_FUNCTION_PASS("tailduplication", TailDuplicatePass)
+DUMMY_MACHINE_FUNCTION_PASS("twoaddressinstruction", TwoAddressInstructionPass)
+DUMMY_MACHINE_FUNCTION_PASS("unpack-mi-bundles", UnpackMachineBundlesPass)
+DUMMY_MACHINE_FUNCTION_PASS("virtregrewriter", VirtRegRewriterPass)
+DUMMY_MACHINE_FUNCTION_PASS("xray-instrumentation", XRayInstrumentationPass)
#undef DUMMY_MACHINE_FUNCTION_PASS
-
-#ifndef DUMMY_MACHINE_FUNCTION_ANALYSIS
-#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR)
-#endif
-DUMMY_MACHINE_FUNCTION_ANALYSIS("gc-analysis", GCMachineCodeAnalysisPass, ())
-#undef DUMMY_MACHINE_FUNCTION_ANALYSIS
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index a522a12299bb02..7462f61d32b566 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -465,11 +465,6 @@ class LLVMTargetMachine : public TargetMachine {
inconvertibleErrorCode());
}
- virtual std::pair<StringRef, bool> getPassNameFromLegacyName(StringRef) {
- llvm_unreachable(
- "getPassNameFromLegacyName parseMIRPipeline is not overridden");
- }
-
/// Add passes to the specified pass manager to get machine code emitted with
/// the MCJIT. This method returns true if machine code is not supported. It
/// fills the MCContext Ctx pointer which can be used to build custom
diff --git a/llvm/lib/Passes/CodeGenPassBuilder.cpp b/llvm/lib/Passes/CodeGenPassBuilder.cpp
index 927727cba6fc6c..16332200f9b4b8 100644
--- a/llvm/lib/Passes/CodeGenPassBuilder.cpp
+++ b/llvm/lib/Passes/CodeGenPassBuilder.cpp
@@ -16,7 +16,7 @@
using namespace llvm;
namespace llvm {
-#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
+#define DUMMY_MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
AnalysisKey PASS_NAME::Key;
#include "llvm/Passes/MachinePassRegistry.def"
} // namespace llvm
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 0f33af22dbd978..89947711d4bfe7 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -398,10 +398,10 @@ PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO,
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
#include "PassRegistry.def"
-#define MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- PIC->addClassToPassName(PASS_NAME::name(), NAME);
-#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- PIC->addClassToPassName(PASS_NAME::name(), NAME);
+#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
+ PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
+#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
+ PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
#include "llvm/Passes/MachinePassRegistry.def"
}
}
@@ -441,8 +441,8 @@ void PassBuilder::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
void PassBuilder::registerMachineFunctionAnalyses(
MachineFunctionAnalysisManager &MFAM) {
-#define MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- MFAM.registerPass([&] { return PASS_NAME(); });
+#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
+ MFAM.registerPass([&] { return CREATE_PASS; });
#include "llvm/Passes/MachinePassRegistry.def"
for (auto &C : MachineFunctionAnalysisRegistrationCallbacks)
@@ -1860,14 +1860,14 @@ Error PassBuilder::parseMachinePass(MachineFunctionPassManager &MFPM,
return make_error<StringError>("invalid pipeline",
inconvertibleErrorCode());
-#define MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
+#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) \
if (Name == NAME) { \
- MFPM.addPass(PASS_NAME()); \
+ MFPM.addPass(CREATE_PASS); \
return Error::success(); \
}
-#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
+#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) \
if (Name == NAME) { \
- MFPM.addPass(PASS_NAME()); \
+ MFPM.addPass(CREATE_PASS); \
return Error::success(); \
}
#include "llvm/Passes/MachinePassRegistry.def"
@@ -2179,18 +2179,15 @@ void PassBuilder::printPassNames(raw_ostream &OS) {
#include "PassRegistry.def"
OS << "Machine module passes (WIP):\n";
-#define MACHINE_MODULE_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- printPassName(NAME, OS);
+#define MACHINE_MODULE_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
#include "llvm/Passes/MachinePassRegistry.def"
OS << "Machine function passes (WIP):\n";
-#define MACHINE_FUNCTION_PASS(NAME, PASS_NAME, CONSTRUCTOR) \
- printPassName(NAME, OS);
+#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS) printPassName(NAME, OS);
#include "llvm/Passes/MachinePassRegistry.def"
OS << "Machine function analyses (WIP):\n";
-#define MACHINE_FUNCTION_ANALYSIS(NAME, PASS_NAME, CONSTRUCTOR) \
- printPassName(NAME, OS);
+#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS) printPassName(NAME, OS);
#include "llvm/Passes/MachinePassRegistry.def"
}
diff --git a/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp b/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
index 88522d45bc6bfa..0527d720f85f73 100644
--- a/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
+++ b/llvm/unittests/MIR/PassBuilderCallbacksTest.cpp
@@ -433,6 +433,12 @@ TEST_F(MachineFunctionCallbacksTest, InstrumentedPasses) {
CallbacksHandle,
runBeforeNonSkippedPass(HasNameRegex("MockPassHandle"), HasName("test")))
.InSequence(PISequence);
+ EXPECT_CALL(CallbacksHandle,
+ runBeforeAnalysis(HasNameRegex("MockAnalysisHandle"), _))
+ .InSequence(PISequence);
+ EXPECT_CALL(CallbacksHandle,
+ runAfterAnalysis(HasNameRegex("MockAnalysisHandle"), _))
+ .InSequence(PISequence);
EXPECT_CALL(CallbacksHandle,
runAfterPass(HasNameRegex("MockPassHandle"), HasName("test"), _))
.InSequence(PISequence);
More information about the llvm-commits
mailing list