1//===- MachinePassRegistry.def - Registry of passes -------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is used as the registry of passes that are for target-independent
10// code generator.
11//
12//===----------------------------------------------------------------------===//
13
14// NOTE: NO INCLUDE GUARD DESIRED!
15
16#ifndef MODULE_ANALYSIS
17#define MODULE_ANALYSIS(NAME, CREATE_PASS)
18#endif
19MODULE_ANALYSIS("collector-metadata", CollectorMetadataAnalysis())
20MODULE_ANALYSIS("machine-module-info", MachineModuleAnalysis())
21MODULE_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
22#undef MODULE_ANALYSIS
23
24#ifndef MODULE_PASS
25#define MODULE_PASS(NAME, CREATE_PASS)
26#endif
27MODULE_PASS("global-merge", GlobalMergePass(TM, GlobalMergeOptions()))
28MODULE_PASS("jmc-instrumenter", JMCInstrumenterPass())
29MODULE_PASS("lower-emutls", LowerEmuTLSPass())
30MODULE_PASS("pre-isel-intrinsic-lowering", PreISelIntrinsicLoweringPass())
31MODULE_PASS("print<regusage>", PhysicalRegisterUsageInfoPrinterPass(errs()))
32MODULE_PASS("shadow-stack-gc-lowering", ShadowStackGCLoweringPass())
33MODULE_PASS("global-merge-func", GlobalMergeFuncPass())
34#undef MODULE_PASS
35
36#ifndef FUNCTION_ANALYSIS
37#define FUNCTION_ANALYSIS(NAME, CREATE_PASS)
38#endif
39FUNCTION_ANALYSIS("gc-function", GCFunctionAnalysis())
40FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
41FUNCTION_ANALYSIS("ssp-layout", SSPLayoutAnalysis())
42FUNCTION_ANALYSIS("target-ir", TargetIRAnalysis(std::move(TM.getTargetIRAnalysis())))
43#undef FUNCTION_ANALYSIS
44
45#ifndef LOOP_PASS
46#define LOOP_PASS(NAME, CREATE_PASS)
47#endif
48LOOP_PASS("loop-reduce", LoopStrengthReducePass())
49LOOP_PASS("loop-term-fold", LoopTermFoldPass())
50#undef LOOP_PASS
51
52#ifndef MACHINE_MODULE_PASS
53#define MACHINE_MODULE_PASS(NAME, CREATE_PASS)
54#endif
55#undef MACHINE_MODULE_PASS
56
57#ifndef MACHINE_FUNCTION_ANALYSIS
58#define MACHINE_FUNCTION_ANALYSIS(NAME, CREATE_PASS)
59#endif
60// LiveVariables currently requires pure SSA form.
61// FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
62// LiveVariables can be removed completely, and LiveIntervals can be directly
63// computed. (We still either need to regenerate kill flags after regalloc, or
64// preferably fix the scavenger to not depend on them).
65MACHINE_FUNCTION_ANALYSIS("edge-bundles", EdgeBundlesAnalysis())
66MACHINE_FUNCTION_ANALYSIS("gisel-value-tracking", GISelValueTrackingAnalysis())
67MACHINE_FUNCTION_ANALYSIS("livedebugvars", LiveDebugVariablesAnalysis())
68MACHINE_FUNCTION_ANALYSIS("live-intervals", LiveIntervalsAnalysis())
69MACHINE_FUNCTION_ANALYSIS("live-reg-matrix", LiveRegMatrixAnalysis())
70MACHINE_FUNCTION_ANALYSIS("live-stacks", LiveStacksAnalysis())
71MACHINE_FUNCTION_ANALYSIS("live-vars", LiveVariablesAnalysis())
72MACHINE_FUNCTION_ANALYSIS("machine-block-freq", MachineBlockFrequencyAnalysis())
73MACHINE_FUNCTION_ANALYSIS("machine-branch-prob",
74 MachineBranchProbabilityAnalysis())
75MACHINE_FUNCTION_ANALYSIS("machine-cycles", MachineCycleAnalysis())
76MACHINE_FUNCTION_ANALYSIS("machine-dom-frontier", MachineDominanceFrontierAnalysis())
77MACHINE_FUNCTION_ANALYSIS("machine-dom-tree", MachineDominatorTreeAnalysis())
78MACHINE_FUNCTION_ANALYSIS("machine-loops", MachineLoopAnalysis())
79MACHINE_FUNCTION_ANALYSIS("machine-opt-remark-emitter",
80 MachineOptimizationRemarkEmitterAnalysis())
81MACHINE_FUNCTION_ANALYSIS("machine-post-dom-tree",
82 MachinePostDominatorTreeAnalysis())
83MACHINE_FUNCTION_ANALYSIS("machine-trace-metrics", MachineTraceMetricsAnalysis())
84MACHINE_FUNCTION_ANALYSIS("machine-uniformity", MachineUniformityAnalysis())
85MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
86MACHINE_FUNCTION_ANALYSIS("reaching-def", ReachingDefAnalysis())
87MACHINE_FUNCTION_ANALYSIS("regalloc-evict", RegAllocEvictionAdvisorAnalysis())
88MACHINE_FUNCTION_ANALYSIS("regalloc-priority", RegAllocPriorityAdvisorAnalysis())
89MACHINE_FUNCTION_ANALYSIS("slot-indexes", SlotIndexesAnalysis())
90MACHINE_FUNCTION_ANALYSIS("spill-code-placement", SpillPlacementAnalysis())
91MACHINE_FUNCTION_ANALYSIS("virtregmap", VirtRegMapAnalysis())
92// MACHINE_FUNCTION_ANALYSIS("lazy-machine-bfi",
93// LazyMachineBlockFrequencyInfoAnalysis())
94// MACHINE_FUNCTION_ANALYSIS("machine-loops", MachineLoopInfoAnalysis())
95// MACHINE_FUNCTION_ANALYSIS("machine-post-dom-tree",
96// MachinePostDominatorTreeAnalysis())
97// MACHINE_FUNCTION_ANALYSIS("machine-region-info",
98// MachineRegionInfoPassAnalysis())
99// MACHINE_FUNCTION_ANALYSIS("gc-analysis",
100// GCMachineCodeAnalysisPass())
101#undef MACHINE_FUNCTION_ANALYSIS
102
103#ifndef MACHINE_FUNCTION_PASS
104#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
105#endif
106MACHINE_FUNCTION_PASS("block-placement-stats", MachineBlockPlacementStatsPass())
107MACHINE_FUNCTION_PASS("branch-relaxation", BranchRelaxationPass())
108MACHINE_FUNCTION_PASS("dead-mi-elimination", DeadMachineInstructionElimPass())
109MACHINE_FUNCTION_PASS("detect-dead-lanes", DetectDeadLanesPass())
110MACHINE_FUNCTION_PASS("early-ifcvt", EarlyIfConverterPass())
111MACHINE_FUNCTION_PASS("early-machinelicm", EarlyMachineLICMPass())
112MACHINE_FUNCTION_PASS("early-tailduplication", EarlyTailDuplicatePass())
113MACHINE_FUNCTION_PASS("fentry-insert", FEntryInserterPass())
114MACHINE_FUNCTION_PASS("finalize-isel", FinalizeISelPass())
115MACHINE_FUNCTION_PASS("finalizebundle-test", FinalizeBundleTestPass())
116MACHINE_FUNCTION_PASS("fixup-statepoint-caller-saved", FixupStatepointCallerSavedPass())
117MACHINE_FUNCTION_PASS("init-undef", InitUndefPass())
118MACHINE_FUNCTION_PASS("gc-empty-basic-blocks", GCEmptyBasicBlocksPass())
119MACHINE_FUNCTION_PASS("localstackalloc", LocalStackSlotAllocationPass())
120MACHINE_FUNCTION_PASS("machine-cp", MachineCopyPropagationPass())
121MACHINE_FUNCTION_PASS("machine-cse", MachineCSEPass())
122MACHINE_FUNCTION_PASS("machine-latecleanup", MachineLateInstrsCleanupPass())
123MACHINE_FUNCTION_PASS("machine-sanmd", MachineSanitizerBinaryMetadataPass())
124MACHINE_FUNCTION_PASS("machine-scheduler", MachineSchedulerPass(TM))
125MACHINE_FUNCTION_PASS("machinelicm", MachineLICMPass())
126MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
127MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass())
128MACHINE_FUNCTION_PASS("patchable-function", PatchableFunctionPass())
129MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass())
130MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass())
131MACHINE_FUNCTION_PASS("post-RA-hazard-rec", PostRAHazardRecognizerPass())
132MACHINE_FUNCTION_PASS("post-RA-sched", PostRASchedulerPass(TM))
133MACHINE_FUNCTION_PASS("postra-machine-sink", PostRAMachineSinkingPass())
134MACHINE_FUNCTION_PASS("postmisched", PostMachineSchedulerPass(TM))
135MACHINE_FUNCTION_PASS("post-ra-pseudos", ExpandPostRAPseudosPass())
136MACHINE_FUNCTION_PASS("print", PrintMIRPass())
137MACHINE_FUNCTION_PASS("print<gisel-value-tracking>", GISelValueTrackingPrinterPass(errs()))
138MACHINE_FUNCTION_PASS("print<livedebugvars>", LiveDebugVariablesPrinterPass(errs()))
139MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(errs()))
140MACHINE_FUNCTION_PASS("print<live-stacks>", LiveStacksPrinterPass(errs()))
141MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(errs()))
142MACHINE_FUNCTION_PASS("print<machine-block-freq>",
143 MachineBlockFrequencyPrinterPass(errs()))
144MACHINE_FUNCTION_PASS("print<machine-branch-prob>",
145 MachineBranchProbabilityPrinterPass(errs()))
146MACHINE_FUNCTION_PASS("print<machine-cycles>", MachineCycleInfoPrinterPass(errs()))
147MACHINE_FUNCTION_PASS("print<machine-dom-tree>",
148 MachineDominatorTreePrinterPass(errs()))
149MACHINE_FUNCTION_PASS("print<machine-loops>", MachineLoopPrinterPass(errs()))
150MACHINE_FUNCTION_PASS("print<machine-post-dom-tree>",
151 MachinePostDominatorTreePrinterPass(errs()))
152MACHINE_FUNCTION_PASS("print<machine-uniformity>",
153 MachineUniformityPrinterPass(errs()))
154MACHINE_FUNCTION_PASS("print<reaching-def>", ReachingDefPrinterPass(errs()))
155MACHINE_FUNCTION_PASS("print<slot-indexes>", SlotIndexesPrinterPass(errs()))
156MACHINE_FUNCTION_PASS("print<virtregmap>", VirtRegMapPrinterPass(errs()))
157MACHINE_FUNCTION_PASS("process-imp-defs", ProcessImplicitDefsPass())
158MACHINE_FUNCTION_PASS("prolog-epilog", PrologEpilogInserterPass())
159MACHINE_FUNCTION_PASS("reg-usage-collector", RegUsageInfoCollectorPass())
160MACHINE_FUNCTION_PASS("reg-usage-propagation", RegUsageInfoPropagationPass())
161MACHINE_FUNCTION_PASS("register-coalescer", RegisterCoalescerPass())
162MACHINE_FUNCTION_PASS("rename-independent-subregs", RenameIndependentSubregsPass())
163MACHINE_FUNCTION_PASS("remove-loads-into-fake-uses", RemoveLoadsIntoFakeUsesPass())
164MACHINE_FUNCTION_PASS("remove-redundant-debug-values", RemoveRedundantDebugValuesPass())
165MACHINE_FUNCTION_PASS("require-all-machine-function-properties",
166 RequireAllMachineFunctionPropertiesPass())
167MACHINE_FUNCTION_PASS("shrink-wrap", ShrinkWrapPass())
168MACHINE_FUNCTION_PASS("stack-coloring", StackColoringPass())
169MACHINE_FUNCTION_PASS("stack-frame-layout", StackFrameLayoutAnalysisPass())
170MACHINE_FUNCTION_PASS("stack-slot-coloring", StackSlotColoringPass())
171MACHINE_FUNCTION_PASS("tailduplication", TailDuplicatePass())
172MACHINE_FUNCTION_PASS("trigger-verifier-error", TriggerVerifierErrorPass())
173MACHINE_FUNCTION_PASS("two-address-instruction", TwoAddressInstructionPass())
174MACHINE_FUNCTION_PASS("unreachable-mbb-elimination",
175 UnreachableMachineBlockElimPass())
176MACHINE_FUNCTION_PASS("verify", MachineVerifierPass())
177MACHINE_FUNCTION_PASS("verify<machine-trace-metrics>", MachineTraceMetricsVerifierPass())
178MACHINE_FUNCTION_PASS("xray-instrumentation", XRayInstrumentationPass())
179#undef MACHINE_FUNCTION_PASS
180
181#ifndef MACHINE_FUNCTION_PASS_WITH_PARAMS
182#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
183 PARAMS)
184#endif
185
186MACHINE_FUNCTION_PASS_WITH_PARAMS(
187 "block-placement", "MachineBlockPlacementPass",
188 [](bool AllowTailMerge) {
189 // Default is true.
190 return MachineBlockPlacementPass(AllowTailMerge);
191 },
192 parseMachineBlockPlacementPassOptions, "no-tail-merge;tail-merge")
193
194MACHINE_FUNCTION_PASS_WITH_PARAMS(
195 "branch-folder", "BranchFolderPass",
196 [](bool EnableTailMerge) { return BranchFolderPass(EnableTailMerge); },
197 [](StringRef Params) {
198 return parseSinglePassOption(Params, "enable-tail-merge",
199 "BranchFolderPass");
200 },
201 "enable-tail-merge")
202
203MACHINE_FUNCTION_PASS_WITH_PARAMS(
204 "live-debug-values", "LiveDebugValuesPass",
205 [](bool ShouldEmitDebugEntryValues) {
206 return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
207 },
208 [](StringRef Params) {
209 return parseSinglePassOption(Params, "emit-debug-entry-values",
210 "LiveDebugValuesPass");
211 },
212 "emit-debug-entry-values")
213
214MACHINE_FUNCTION_PASS_WITH_PARAMS(
215 "machine-sink", "MachineSinkingPass",
216 [](bool EnableSinkAndFold) {
217 return MachineSinkingPass(EnableSinkAndFold);
218 },
219 parseMachineSinkingPassOptions, "enable-sink-fold")
220
221MACHINE_FUNCTION_PASS_WITH_PARAMS(
222 "regallocfast", "RegAllocFastPass",
223 [](RegAllocFastPass::Options Opts) { return RegAllocFastPass(Opts); },
224 [PB = this](StringRef Params) {
225 return parseRegAllocFastPassOptions(*PB, Params);
226 },
227 "filter=reg-filter;no-clear-vregs")
228
229// 'all' is the default filter.
230MACHINE_FUNCTION_PASS_WITH_PARAMS(
231 "greedy", "RAGreedyPass",
232 [](RAGreedyPass::Options Opts) { return RAGreedyPass(Opts); },
233 [PB = this](StringRef Params) {
234 return parseRegAllocGreedyFilterFunc(*PB, Params);
235 }, "reg-filter"
236)
237
238MACHINE_FUNCTION_PASS_WITH_PARAMS(
239 "virt-reg-rewriter", "VirtRegRewriterPass",
240 [](bool ClearVirtRegs) { return VirtRegRewriterPass(ClearVirtRegs); },
241 parseVirtRegRewriterPassOptions, "no-clear-vregs;clear-vregs")
242
243#undef MACHINE_FUNCTION_PASS_WITH_PARAMS
244
245// After a pass is converted to new pass manager, its entry should be moved from
246// dummy table to the normal one. For example, for a machine function pass,
247// DUMMY_MACHINE_FUNCTION_PASS to MACHINE_FUNCTION_PASS.
248
249#ifndef DUMMY_FUNCTION_PASS
250#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME)
251#endif
252#undef DUMMY_FUNCTION_PASS
253
254#ifndef DUMMY_MACHINE_MODULE_PASS
255#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME)
256#endif
257DUMMY_MACHINE_MODULE_PASS("machine-outliner", MachineOutlinerPass)
258DUMMY_MACHINE_MODULE_PASS("static-data-annotator", StaticDataAnnotator)
259DUMMY_MACHINE_MODULE_PASS("pseudo-probe-inserter", PseudoProbeInserterPass)
260DUMMY_MACHINE_MODULE_PASS("mir-debugify", DebugifyMachineModule)
261DUMMY_MACHINE_MODULE_PASS("mir-check-debugify", CheckDebugMachineModulePass)
262DUMMY_MACHINE_MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass)
263#undef DUMMY_MACHINE_MODULE_PASS
264
265#ifndef DUMMY_MACHINE_FUNCTION_PASS
266#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME)
267#endif
268DUMMY_MACHINE_FUNCTION_PASS("bbsections-prepare", BasicBlockSectionsPass)
269DUMMY_MACHINE_FUNCTION_PASS("bbsections-profile-reader", BasicBlockSectionsProfileReaderPass)
270DUMMY_MACHINE_FUNCTION_PASS("break-false-deps", BreakFalseDepsPass)
271DUMMY_MACHINE_FUNCTION_PASS("cfguard-longjmp", CFGuardLongjmpPass)
272DUMMY_MACHINE_FUNCTION_PASS("cfi-fixup", CFIFixupPass)
273DUMMY_MACHINE_FUNCTION_PASS("cfi-instr-inserter", CFIInstrInserterPass)
274DUMMY_MACHINE_FUNCTION_PASS("dot-machine-cfg", MachineCFGPrinter)
275DUMMY_MACHINE_FUNCTION_PASS("eh-cont-guard-targets", EHContGuardTargetsPass)
276DUMMY_MACHINE_FUNCTION_PASS("fs-profile-loader", MIRProfileLoaderNewPass)
277DUMMY_MACHINE_FUNCTION_PASS("funclet-layout", FuncletLayoutPass)
278DUMMY_MACHINE_FUNCTION_PASS("implicit-null-checks", ImplicitNullChecksPass)
279DUMMY_MACHINE_FUNCTION_PASS("instruction-select", InstructionSelectPass)
280DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
281DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
282DUMMY_MACHINE_FUNCTION_PASS("legalizer", LegalizerPass)
283DUMMY_MACHINE_FUNCTION_PASS("lrshrink", LiveRangeShrinkPass)
284DUMMY_MACHINE_FUNCTION_PASS("machine-combiner", MachineCombinerPass)
285DUMMY_MACHINE_FUNCTION_PASS("static-data-splitter", StaticDataSplitter)
286DUMMY_MACHINE_FUNCTION_PASS("machine-function-splitter", MachineFunctionSplitterPass)
287DUMMY_MACHINE_FUNCTION_PASS("machineinstr-printer", MachineFunctionPrinterPass)
288DUMMY_MACHINE_FUNCTION_PASS("mirfs-discriminators", MIRAddFSDiscriminatorsPass)
289DUMMY_MACHINE_FUNCTION_PASS("prologepilog-code", PrologEpilogCodeInserterPass)
290DUMMY_MACHINE_FUNCTION_PASS("ra-basic", RABasicPass)
291DUMMY_MACHINE_FUNCTION_PASS("ra-pbqp", RAPBQPPass)
292DUMMY_MACHINE_FUNCTION_PASS("regalloc", RegAllocPass)
293DUMMY_MACHINE_FUNCTION_PASS("regallocscoringpass", RegAllocScoringPass)
294DUMMY_MACHINE_FUNCTION_PASS("regbankselect", RegBankSelectPass)
295DUMMY_MACHINE_FUNCTION_PASS("reset-machine-function", ResetMachineFunctionPass)
296DUMMY_MACHINE_FUNCTION_PASS("stackmap-liveness", StackMapLivenessPass)
297DUMMY_MACHINE_FUNCTION_PASS("unpack-mi-bundles", UnpackMachineBundlesPass)
298#undef DUMMY_MACHINE_FUNCTION_PASS
299