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-cse-analysis", GISelCSEAnalysis(TM))
67MACHINE_FUNCTION_ANALYSIS("gisel-value-tracking", GISelValueTrackingAnalysis())
68MACHINE_FUNCTION_ANALYSIS("livedebugvars", LiveDebugVariablesAnalysis())
69MACHINE_FUNCTION_ANALYSIS("live-intervals", LiveIntervalsAnalysis())
70MACHINE_FUNCTION_ANALYSIS("live-reg-matrix", LiveRegMatrixAnalysis())
71MACHINE_FUNCTION_ANALYSIS("live-stacks", LiveStacksAnalysis())
72MACHINE_FUNCTION_ANALYSIS("live-vars", LiveVariablesAnalysis())
73MACHINE_FUNCTION_ANALYSIS("machine-block-freq", MachineBlockFrequencyAnalysis())
74MACHINE_FUNCTION_ANALYSIS("machine-branch-prob",
75 MachineBranchProbabilityAnalysis())
76MACHINE_FUNCTION_ANALYSIS("machine-cycles", MachineCycleAnalysis())
77MACHINE_FUNCTION_ANALYSIS("machine-dom-frontier", MachineDominanceFrontierAnalysis())
78MACHINE_FUNCTION_ANALYSIS("machine-dom-tree", MachineDominatorTreeAnalysis())
79MACHINE_FUNCTION_ANALYSIS("machine-loops", MachineLoopAnalysis())
80MACHINE_FUNCTION_ANALYSIS("machine-opt-remark-emitter",
81 MachineOptimizationRemarkEmitterAnalysis())
82MACHINE_FUNCTION_ANALYSIS("machine-post-dom-tree",
83 MachinePostDominatorTreeAnalysis())
84MACHINE_FUNCTION_ANALYSIS("machine-trace-metrics", MachineTraceMetricsAnalysis())
85MACHINE_FUNCTION_ANALYSIS("machine-uniformity", MachineUniformityAnalysis())
86MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
87MACHINE_FUNCTION_ANALYSIS("reaching-def", ReachingDefAnalysis())
88MACHINE_FUNCTION_ANALYSIS("regalloc-evict", RegAllocEvictionAdvisorAnalysis())
89MACHINE_FUNCTION_ANALYSIS("regalloc-priority", RegAllocPriorityAdvisorAnalysis())
90MACHINE_FUNCTION_ANALYSIS("slot-indexes", SlotIndexesAnalysis())
91MACHINE_FUNCTION_ANALYSIS("spill-code-placement", SpillPlacementAnalysis())
92MACHINE_FUNCTION_ANALYSIS("virtregmap", VirtRegMapAnalysis())
93// MACHINE_FUNCTION_ANALYSIS("lazy-machine-bfi",
94// LazyMachineBlockFrequencyInfoAnalysis())
95// MACHINE_FUNCTION_ANALYSIS("machine-loops", MachineLoopInfoAnalysis())
96// MACHINE_FUNCTION_ANALYSIS("machine-post-dom-tree",
97// MachinePostDominatorTreeAnalysis())
98// MACHINE_FUNCTION_ANALYSIS("machine-region-info",
99// MachineRegionInfoPassAnalysis())
100// MACHINE_FUNCTION_ANALYSIS("gc-analysis",
101// GCMachineCodeAnalysisPass())
102#undef MACHINE_FUNCTION_ANALYSIS
103
104#ifndef MACHINE_FUNCTION_PASS
105#define MACHINE_FUNCTION_PASS(NAME, CREATE_PASS)
106#endif
107MACHINE_FUNCTION_PASS("block-placement-stats", MachineBlockPlacementStatsPass())
108MACHINE_FUNCTION_PASS("branch-relaxation", BranchRelaxationPass())
109MACHINE_FUNCTION_PASS("dead-mi-elimination", DeadMachineInstructionElimPass())
110MACHINE_FUNCTION_PASS("detect-dead-lanes", DetectDeadLanesPass())
111MACHINE_FUNCTION_PASS("early-ifcvt", EarlyIfConverterPass())
112MACHINE_FUNCTION_PASS("early-machinelicm", EarlyMachineLICMPass())
113MACHINE_FUNCTION_PASS("early-tailduplication", EarlyTailDuplicatePass())
114MACHINE_FUNCTION_PASS("fentry-insert", FEntryInserterPass())
115MACHINE_FUNCTION_PASS("finalize-isel", FinalizeISelPass())
116MACHINE_FUNCTION_PASS("finalizebundle-test", FinalizeBundleTestPass())
117MACHINE_FUNCTION_PASS("fixup-statepoint-caller-saved", FixupStatepointCallerSavedPass())
118MACHINE_FUNCTION_PASS("init-undef", InitUndefPass())
119MACHINE_FUNCTION_PASS("gc-empty-basic-blocks", GCEmptyBasicBlocksPass())
120MACHINE_FUNCTION_PASS("localstackalloc", LocalStackSlotAllocationPass())
121MACHINE_FUNCTION_PASS("machine-cp", MachineCopyPropagationPass())
122MACHINE_FUNCTION_PASS("machine-cse", MachineCSEPass())
123MACHINE_FUNCTION_PASS("machine-latecleanup", MachineLateInstrsCleanupPass())
124MACHINE_FUNCTION_PASS("machine-sanmd", MachineSanitizerBinaryMetadataPass())
125MACHINE_FUNCTION_PASS("machine-scheduler", MachineSchedulerPass(TM))
126MACHINE_FUNCTION_PASS("machinelicm", MachineLICMPass())
127MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
128MACHINE_FUNCTION_PASS("opt-phis", OptimizePHIsPass())
129MACHINE_FUNCTION_PASS("patchable-function", PatchableFunctionPass())
130MACHINE_FUNCTION_PASS("peephole-opt", PeepholeOptimizerPass())
131MACHINE_FUNCTION_PASS("phi-node-elimination", PHIEliminationPass())
132MACHINE_FUNCTION_PASS("post-RA-hazard-rec", PostRAHazardRecognizerPass())
133MACHINE_FUNCTION_PASS("post-RA-sched", PostRASchedulerPass(TM))
134MACHINE_FUNCTION_PASS("postra-machine-sink", PostRAMachineSinkingPass())
135MACHINE_FUNCTION_PASS("postmisched", PostMachineSchedulerPass(TM))
136MACHINE_FUNCTION_PASS("post-ra-pseudos", ExpandPostRAPseudosPass())
137MACHINE_FUNCTION_PASS("print", PrintMIRPass())
138MACHINE_FUNCTION_PASS("print<gisel-value-tracking>", GISelValueTrackingPrinterPass(errs()))
139MACHINE_FUNCTION_PASS("print<livedebugvars>", LiveDebugVariablesPrinterPass(errs()))
140MACHINE_FUNCTION_PASS("print<live-intervals>", LiveIntervalsPrinterPass(errs()))
141MACHINE_FUNCTION_PASS("print<live-stacks>", LiveStacksPrinterPass(errs()))
142MACHINE_FUNCTION_PASS("print<live-vars>", LiveVariablesPrinterPass(errs()))
143MACHINE_FUNCTION_PASS("print<machine-block-freq>",
144 MachineBlockFrequencyPrinterPass(errs()))
145MACHINE_FUNCTION_PASS("print<machine-branch-prob>",
146 MachineBranchProbabilityPrinterPass(errs()))
147MACHINE_FUNCTION_PASS("print<machine-cycles>", MachineCycleInfoPrinterPass(errs()))
148MACHINE_FUNCTION_PASS("print<machine-dom-tree>",
149 MachineDominatorTreePrinterPass(errs()))
150MACHINE_FUNCTION_PASS("print<machine-loops>", MachineLoopPrinterPass(errs()))
151MACHINE_FUNCTION_PASS("print<machine-post-dom-tree>",
152 MachinePostDominatorTreePrinterPass(errs()))
153MACHINE_FUNCTION_PASS("print<machine-uniformity>",
154 MachineUniformityPrinterPass(errs()))
155MACHINE_FUNCTION_PASS("print<reaching-def>", ReachingDefPrinterPass(errs()))
156MACHINE_FUNCTION_PASS("print<slot-indexes>", SlotIndexesPrinterPass(errs()))
157MACHINE_FUNCTION_PASS("print<virtregmap>", VirtRegMapPrinterPass(errs()))
158MACHINE_FUNCTION_PASS("process-imp-defs", ProcessImplicitDefsPass())
159MACHINE_FUNCTION_PASS("prolog-epilog", PrologEpilogInserterPass())
160MACHINE_FUNCTION_PASS("reg-usage-collector", RegUsageInfoCollectorPass())
161MACHINE_FUNCTION_PASS("reg-usage-propagation", RegUsageInfoPropagationPass())
162MACHINE_FUNCTION_PASS("register-coalescer", RegisterCoalescerPass())
163MACHINE_FUNCTION_PASS("rename-independent-subregs", RenameIndependentSubregsPass())
164MACHINE_FUNCTION_PASS("remove-loads-into-fake-uses", RemoveLoadsIntoFakeUsesPass())
165MACHINE_FUNCTION_PASS("remove-redundant-debug-values", RemoveRedundantDebugValuesPass())
166MACHINE_FUNCTION_PASS("require-all-machine-function-properties",
167 RequireAllMachineFunctionPropertiesPass())
168MACHINE_FUNCTION_PASS("shrink-wrap", ShrinkWrapPass())
169MACHINE_FUNCTION_PASS("stack-coloring", StackColoringPass())
170MACHINE_FUNCTION_PASS("stack-frame-layout", StackFrameLayoutAnalysisPass())
171MACHINE_FUNCTION_PASS("stack-slot-coloring", StackSlotColoringPass())
172MACHINE_FUNCTION_PASS("tailduplication", TailDuplicatePass())
173MACHINE_FUNCTION_PASS("trigger-verifier-error", TriggerVerifierErrorPass())
174MACHINE_FUNCTION_PASS("two-address-instruction", TwoAddressInstructionPass())
175MACHINE_FUNCTION_PASS("unreachable-mbb-elimination",
176 UnreachableMachineBlockElimPass())
177MACHINE_FUNCTION_PASS("verify", MachineVerifierPass())
178MACHINE_FUNCTION_PASS("verify<machine-trace-metrics>", MachineTraceMetricsVerifierPass())
179MACHINE_FUNCTION_PASS("xray-instrumentation", XRayInstrumentationPass())
180#undef MACHINE_FUNCTION_PASS
181
182#ifndef MACHINE_FUNCTION_PASS_WITH_PARAMS
183#define MACHINE_FUNCTION_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, \
184 PARAMS)
185#endif
186
187MACHINE_FUNCTION_PASS_WITH_PARAMS(
188 "block-placement", "MachineBlockPlacementPass",
189 [](bool AllowTailMerge) {
190 // Default is true.
191 return MachineBlockPlacementPass(AllowTailMerge);
192 },
193 parseMachineBlockPlacementPassOptions, "no-tail-merge;tail-merge")
194
195MACHINE_FUNCTION_PASS_WITH_PARAMS(
196 "branch-folder", "BranchFolderPass",
197 [](bool EnableTailMerge) { return BranchFolderPass(EnableTailMerge); },
198 [](StringRef Params) {
199 return parseSinglePassOption(Params, "enable-tail-merge",
200 "BranchFolderPass");
201 },
202 "enable-tail-merge")
203
204MACHINE_FUNCTION_PASS_WITH_PARAMS(
205 "live-debug-values", "LiveDebugValuesPass",
206 [](bool ShouldEmitDebugEntryValues) {
207 return LiveDebugValuesPass(ShouldEmitDebugEntryValues);
208 },
209 [](StringRef Params) {
210 return parseSinglePassOption(Params, "emit-debug-entry-values",
211 "LiveDebugValuesPass");
212 },
213 "emit-debug-entry-values")
214
215MACHINE_FUNCTION_PASS_WITH_PARAMS(
216 "machine-sink", "MachineSinkingPass",
217 [](bool EnableSinkAndFold) {
218 return MachineSinkingPass(EnableSinkAndFold);
219 },
220 parseMachineSinkingPassOptions, "enable-sink-fold")
221
222MACHINE_FUNCTION_PASS_WITH_PARAMS(
223 "regallocfast", "RegAllocFastPass",
224 [](RegAllocFastPass::Options Opts) { return RegAllocFastPass(Opts); },
225 [PB = this](StringRef Params) {
226 return parseRegAllocFastPassOptions(*PB, Params);
227 },
228 "filter=reg-filter;no-clear-vregs")
229
230// 'all' is the default filter.
231MACHINE_FUNCTION_PASS_WITH_PARAMS(
232 "greedy", "RAGreedyPass",
233 [](RAGreedyPass::Options Opts) { return RAGreedyPass(Opts); },
234 [PB = this](StringRef Params) {
235 return parseRegAllocGreedyFilterFunc(*PB, Params);
236 }, "reg-filter"
237)
238
239MACHINE_FUNCTION_PASS_WITH_PARAMS(
240 "virt-reg-rewriter", "VirtRegRewriterPass",
241 [](bool ClearVirtRegs) { return VirtRegRewriterPass(ClearVirtRegs); },
242 parseVirtRegRewriterPassOptions, "no-clear-vregs;clear-vregs")
243
244#undef MACHINE_FUNCTION_PASS_WITH_PARAMS
245
246// After a pass is converted to new pass manager, its entry should be moved from
247// dummy table to the normal one. For example, for a machine function pass,
248// DUMMY_MACHINE_FUNCTION_PASS to MACHINE_FUNCTION_PASS.
249
250#ifndef DUMMY_FUNCTION_PASS
251#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME)
252#endif
253#undef DUMMY_FUNCTION_PASS
254
255#ifndef DUMMY_MACHINE_MODULE_PASS
256#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME)
257#endif
258DUMMY_MACHINE_MODULE_PASS("machine-outliner", MachineOutlinerPass)
259DUMMY_MACHINE_MODULE_PASS("static-data-annotator", StaticDataAnnotator)
260DUMMY_MACHINE_MODULE_PASS("pseudo-probe-inserter", PseudoProbeInserterPass)
261DUMMY_MACHINE_MODULE_PASS("mir-debugify", DebugifyMachineModule)
262DUMMY_MACHINE_MODULE_PASS("mir-check-debugify", CheckDebugMachineModulePass)
263DUMMY_MACHINE_MODULE_PASS("mir-strip-debug", StripDebugMachineModulePass)
264#undef DUMMY_MACHINE_MODULE_PASS
265
266#ifndef DUMMY_MACHINE_FUNCTION_PASS
267#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME)
268#endif
269DUMMY_MACHINE_FUNCTION_PASS("bbsections-prepare", BasicBlockSectionsPass)
270DUMMY_MACHINE_FUNCTION_PASS("bbsections-profile-reader", BasicBlockSectionsProfileReaderPass)
271DUMMY_MACHINE_FUNCTION_PASS("break-false-deps", BreakFalseDepsPass)
272DUMMY_MACHINE_FUNCTION_PASS("cfguard-longjmp", CFGuardLongjmpPass)
273DUMMY_MACHINE_FUNCTION_PASS("cfi-fixup", CFIFixupPass)
274DUMMY_MACHINE_FUNCTION_PASS("cfi-instr-inserter", CFIInstrInserterPass)
275DUMMY_MACHINE_FUNCTION_PASS("dot-machine-cfg", MachineCFGPrinter)
276DUMMY_MACHINE_FUNCTION_PASS("eh-cont-guard-targets", EHContGuardTargetsPass)
277DUMMY_MACHINE_FUNCTION_PASS("fs-profile-loader", MIRProfileLoaderNewPass)
278DUMMY_MACHINE_FUNCTION_PASS("funclet-layout", FuncletLayoutPass)
279DUMMY_MACHINE_FUNCTION_PASS("implicit-null-checks", ImplicitNullChecksPass)
280DUMMY_MACHINE_FUNCTION_PASS("instruction-select", InstructionSelectPass)
281DUMMY_MACHINE_FUNCTION_PASS("irtranslator", IRTranslatorPass)
282DUMMY_MACHINE_FUNCTION_PASS("kcfi", MachineKCFIPass)
283DUMMY_MACHINE_FUNCTION_PASS("legalizer", LegalizerPass)
284DUMMY_MACHINE_FUNCTION_PASS("lrshrink", LiveRangeShrinkPass)
285DUMMY_MACHINE_FUNCTION_PASS("machine-combiner", MachineCombinerPass)
286DUMMY_MACHINE_FUNCTION_PASS("static-data-splitter", StaticDataSplitter)
287DUMMY_MACHINE_FUNCTION_PASS("machine-function-splitter", MachineFunctionSplitterPass)
288DUMMY_MACHINE_FUNCTION_PASS("machineinstr-printer", MachineFunctionPrinterPass)
289DUMMY_MACHINE_FUNCTION_PASS("mirfs-discriminators", MIRAddFSDiscriminatorsPass)
290DUMMY_MACHINE_FUNCTION_PASS("prologepilog-code", PrologEpilogCodeInserterPass)
291DUMMY_MACHINE_FUNCTION_PASS("ra-basic", RABasicPass)
292DUMMY_MACHINE_FUNCTION_PASS("ra-pbqp", RAPBQPPass)
293DUMMY_MACHINE_FUNCTION_PASS("regalloc", RegAllocPass)
294DUMMY_MACHINE_FUNCTION_PASS("regallocscoringpass", RegAllocScoringPass)
295DUMMY_MACHINE_FUNCTION_PASS("regbankselect", RegBankSelectPass)
296DUMMY_MACHINE_FUNCTION_PASS("reset-machine-function", ResetMachineFunctionPass)
297DUMMY_MACHINE_FUNCTION_PASS("stackmap-liveness", StackMapLivenessPass)
298DUMMY_MACHINE_FUNCTION_PASS("unpack-mi-bundles", UnpackMachineBundlesPass)
299#undef DUMMY_MACHINE_FUNCTION_PASS
300