LLVM 20.0.0git
TargetPassConfig.cpp
Go to the documentation of this file.
1//===- TargetPassConfig.cpp - Target independent code generation passes ---===//
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 defines interfaces to access the target independent code
10// generation passes provided by the LLVM backend.
11//
12//===---------------------------------------------------------------------===//
13
15#include "llvm/ADT/DenseMap.h"
17#include "llvm/ADT/StringRef.h"
28#include "llvm/CodeGen/Passes.h"
33#include "llvm/IR/Verifier.h"
35#include "llvm/MC/MCAsmInfo.h"
37#include "llvm/Pass.h"
41#include "llvm/Support/Debug.h"
53#include <cassert>
54#include <optional>
55#include <string>
56
57using namespace llvm;
58
59static cl::opt<bool>
60 EnableIPRA("enable-ipra", cl::init(false), cl::Hidden,
61 cl::desc("Enable interprocedural register allocation "
62 "to reduce load/store at procedure calls."));
64 cl::desc("Disable Post Regalloc Scheduler"));
65static cl::opt<bool> DisableBranchFold("disable-branch-fold", cl::Hidden,
66 cl::desc("Disable branch folding"));
67static cl::opt<bool> DisableTailDuplicate("disable-tail-duplicate", cl::Hidden,
68 cl::desc("Disable tail duplication"));
69static cl::opt<bool> DisableEarlyTailDup("disable-early-taildup", cl::Hidden,
70 cl::desc("Disable pre-register allocation tail duplication"));
71static cl::opt<bool> DisableBlockPlacement("disable-block-placement",
72 cl::Hidden, cl::desc("Disable probability-driven block placement"));
73static cl::opt<bool> EnableBlockPlacementStats("enable-block-placement-stats",
74 cl::Hidden, cl::desc("Collect probability-driven block placement stats"));
75static cl::opt<bool> DisableSSC("disable-ssc", cl::Hidden,
76 cl::desc("Disable Stack Slot Coloring"));
77static cl::opt<bool> DisableMachineDCE("disable-machine-dce", cl::Hidden,
78 cl::desc("Disable Machine Dead Code Elimination"));
80 cl::desc("Disable Early If-conversion"));
81static cl::opt<bool> DisableMachineLICM("disable-machine-licm", cl::Hidden,
82 cl::desc("Disable Machine LICM"));
83static cl::opt<bool> DisableMachineCSE("disable-machine-cse", cl::Hidden,
84 cl::desc("Disable Machine Common Subexpression Elimination"));
86 "optimize-regalloc", cl::Hidden,
87 cl::desc("Enable optimized register allocation compilation path."));
88static cl::opt<bool> DisablePostRAMachineLICM("disable-postra-machine-licm",
90 cl::desc("Disable Machine LICM"));
91static cl::opt<bool> DisableMachineSink("disable-machine-sink", cl::Hidden,
92 cl::desc("Disable Machine Sinking"));
93static cl::opt<bool> DisablePostRAMachineSink("disable-postra-machine-sink",
95 cl::desc("Disable PostRA Machine Sinking"));
96static cl::opt<bool> DisableLSR("disable-lsr", cl::Hidden,
97 cl::desc("Disable Loop Strength Reduction Pass"));
98static cl::opt<bool> DisableConstantHoisting("disable-constant-hoisting",
99 cl::Hidden, cl::desc("Disable ConstantHoisting"));
100static cl::opt<bool> DisableCGP("disable-cgp", cl::Hidden,
101 cl::desc("Disable Codegen Prepare"));
102static cl::opt<bool> DisableCopyProp("disable-copyprop", cl::Hidden,
103 cl::desc("Disable Copy Propagation pass"));
104static cl::opt<bool> DisablePartialLibcallInlining("disable-partial-libcall-inlining",
105 cl::Hidden, cl::desc("Disable Partial Libcall Inlining"));
107 "disable-atexit-based-global-dtor-lowering", cl::Hidden,
108 cl::desc("For MachO, disable atexit()-based global destructor lowering"));
110 "enable-implicit-null-checks",
111 cl::desc("Fold null checks into faulting memory operations"),
112 cl::init(false), cl::Hidden);
113static cl::opt<bool> DisableMergeICmps("disable-mergeicmps",
114 cl::desc("Disable MergeICmps Pass"),
115 cl::init(false), cl::Hidden);
116static cl::opt<bool> PrintLSR("print-lsr-output", cl::Hidden,
117 cl::desc("Print LLVM IR produced by the loop-reduce pass"));
118static cl::opt<bool>
119 PrintISelInput("print-isel-input", cl::Hidden,
120 cl::desc("Print LLVM IR input to isel pass"));
122 VerifyMachineCode("verify-machineinstrs", cl::Hidden,
123 cl::desc("Verify generated machine code"));
125 DebugifyAndStripAll("debugify-and-strip-all-safe", cl::Hidden,
126 cl::desc("Debugify MIR before and Strip debug after "
127 "each pass except those known to be unsafe "
128 "when debug info is present"));
130 "debugify-check-and-strip-all-safe", cl::Hidden,
131 cl::desc(
132 "Debugify MIR before, by checking and stripping the debug info after, "
133 "each pass except those known to be unsafe when debug info is "
134 "present"));
135// Enable or disable the MachineOutliner.
137 "enable-machine-outliner", cl::desc("Enable the machine outliner"),
138 cl::Hidden, cl::ValueOptional, cl::init(RunOutliner::TargetDefault),
139 cl::values(clEnumValN(RunOutliner::AlwaysOutline, "always",
140 "Run on all functions guaranteed to be beneficial"),
141 clEnumValN(RunOutliner::NeverOutline, "never",
142 "Disable all outlining"),
143 // Sentinel value for unspecified option.
144 clEnumValN(RunOutliner::AlwaysOutline, "", "")));
146 "enable-global-merge-func", cl::Hidden,
147 cl::desc("Enable global merge functions that are based on hash function"));
148// Disable the pass to fix unwind information. Whether the pass is included in
149// the pipeline is controlled via the target options, this option serves as
150// manual override.
151static cl::opt<bool> DisableCFIFixup("disable-cfi-fixup", cl::Hidden,
152 cl::desc("Disable the CFI fixup pass"));
153// Enable or disable FastISel. Both options are needed, because
154// FastISel is enabled by default with -fast, and we wish to be
155// able to enable or disable fast-isel independently from -O0.
158 cl::desc("Enable the \"fast\" instruction selector"));
159
161 "global-isel", cl::Hidden,
162 cl::desc("Enable the \"global\" instruction selector"));
163
164// FIXME: remove this after switching to NPM or GlobalISel, whichever gets there
165// first...
166static cl::opt<bool>
167 PrintAfterISel("print-after-isel", cl::init(false), cl::Hidden,
168 cl::desc("Print machine instrs after ISel"));
169
171 "global-isel-abort", cl::Hidden,
172 cl::desc("Enable abort calls when \"global\" instruction selection "
173 "fails to lower/select an instruction"),
175 clEnumValN(GlobalISelAbortMode::Disable, "0", "Disable the abort"),
176 clEnumValN(GlobalISelAbortMode::Enable, "1", "Enable the abort"),
177 clEnumValN(GlobalISelAbortMode::DisableWithDiag, "2",
178 "Disable the abort but emit a diagnostic on failure")));
179
180// Disable MIRProfileLoader before RegAlloc. This is for for debugging and
181// tuning purpose.
183 "disable-ra-fsprofile-loader", cl::init(false), cl::Hidden,
184 cl::desc("Disable MIRProfileLoader before RegAlloc"));
185// Disable MIRProfileLoader before BloackPlacement. This is for for debugging
186// and tuning purpose.
188 "disable-layout-fsprofile-loader", cl::init(false), cl::Hidden,
189 cl::desc("Disable MIRProfileLoader before BlockPlacement"));
190// Specify FSProfile file name.
192 FSProfileFile("fs-profile-file", cl::init(""), cl::value_desc("filename"),
193 cl::desc("Flow Sensitive profile file name."), cl::Hidden);
194// Specify Remapping file for FSProfile.
196 "fs-remapping-file", cl::init(""), cl::value_desc("filename"),
197 cl::desc("Flow Sensitive profile remapping file name."), cl::Hidden);
198
199// Temporary option to allow experimenting with MachineScheduler as a post-RA
200// scheduler. Targets can "properly" enable this with
201// substitutePass(&PostRASchedulerID, &PostMachineSchedulerID).
202// Targets can return true in targetSchedulesPostRAScheduling() and
203// insert a PostRA scheduling pass wherever it wants.
205 "misched-postra", cl::Hidden,
206 cl::desc(
207 "Run MachineScheduler post regalloc (independent of preRA sched)"));
208
209// Experimental option to run live interval analysis early.
210static cl::opt<bool> EarlyLiveIntervals("early-live-intervals", cl::Hidden,
211 cl::desc("Run live interval analysis earlier in the pipeline"));
212
214 "disable-replace-with-vec-lib", cl::Hidden,
215 cl::desc("Disable replace with vector math call pass"));
216
217/// Option names for limiting the codegen pipeline.
218/// Those are used in error reporting and we didn't want
219/// to duplicate their names all over the place.
220static const char StartAfterOptName[] = "start-after";
221static const char StartBeforeOptName[] = "start-before";
222static const char StopAfterOptName[] = "stop-after";
223static const char StopBeforeOptName[] = "stop-before";
224
227 cl::desc("Resume compilation after a specific pass"),
228 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
229
232 cl::desc("Resume compilation before a specific pass"),
233 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
234
237 cl::desc("Stop compilation after a specific pass"),
238 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
239
242 cl::desc("Stop compilation before a specific pass"),
243 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
244
245/// Enable the machine function splitter pass.
247 "enable-split-machine-functions", cl::Hidden,
248 cl::desc("Split out cold blocks from machine functions based on profile "
249 "information."));
250
251/// Disable the expand reductions pass for testing.
253 "disable-expand-reductions", cl::init(false), cl::Hidden,
254 cl::desc("Disable the expand reduction intrinsics pass from running"));
255
256/// Disable the select optimization pass.
258 "disable-select-optimize", cl::init(true), cl::Hidden,
259 cl::desc("Disable the select-optimization pass from running"));
260
261/// Enable garbage-collecting empty basic blocks.
262static cl::opt<bool>
263 GCEmptyBlocks("gc-empty-basic-blocks", cl::init(false), cl::Hidden,
264 cl::desc("Enable garbage-collecting empty basic blocks"));
265
266/// Allow standard passes to be disabled by command line options. This supports
267/// simple binary flags that either suppress the pass or do nothing.
268/// i.e. -disable-mypass=false has no effect.
269/// These should be converted to boolOrDefault in order to use applyOverride.
271 bool Override) {
272 if (Override)
273 return IdentifyingPassPtr();
274 return PassID;
275}
276
277/// Allow standard passes to be disabled by the command line, regardless of who
278/// is adding the pass.
279///
280/// StandardID is the pass identified in the standard pass pipeline and provided
281/// to addPass(). It may be a target-specific ID in the case that the target
282/// directly adds its own pass, but in that case we harmlessly fall through.
283///
284/// TargetID is the pass that the target has configured to override StandardID.
285///
286/// StandardID may be a pseudo ID. In that case TargetID is the name of the real
287/// pass to run. This allows multiple options to control a single pass depending
288/// on where in the pipeline that pass is added.
290 IdentifyingPassPtr TargetID) {
291 if (StandardID == &PostRASchedulerID)
292 return applyDisable(TargetID, DisablePostRASched);
293
294 if (StandardID == &BranchFolderPassID)
295 return applyDisable(TargetID, DisableBranchFold);
296
297 if (StandardID == &TailDuplicateLegacyID)
298 return applyDisable(TargetID, DisableTailDuplicate);
299
300 if (StandardID == &EarlyTailDuplicateLegacyID)
301 return applyDisable(TargetID, DisableEarlyTailDup);
302
303 if (StandardID == &MachineBlockPlacementID)
304 return applyDisable(TargetID, DisableBlockPlacement);
305
306 if (StandardID == &StackSlotColoringID)
307 return applyDisable(TargetID, DisableSSC);
308
309 if (StandardID == &DeadMachineInstructionElimID)
310 return applyDisable(TargetID, DisableMachineDCE);
311
312 if (StandardID == &EarlyIfConverterLegacyID)
313 return applyDisable(TargetID, DisableEarlyIfConversion);
314
315 if (StandardID == &EarlyMachineLICMID)
316 return applyDisable(TargetID, DisableMachineLICM);
317
318 if (StandardID == &MachineCSELegacyID)
319 return applyDisable(TargetID, DisableMachineCSE);
320
321 if (StandardID == &MachineLICMID)
322 return applyDisable(TargetID, DisablePostRAMachineLICM);
323
324 if (StandardID == &MachineSinkingID)
325 return applyDisable(TargetID, DisableMachineSink);
326
327 if (StandardID == &PostRAMachineSinkingID)
328 return applyDisable(TargetID, DisablePostRAMachineSink);
329
330 if (StandardID == &MachineCopyPropagationID)
331 return applyDisable(TargetID, DisableCopyProp);
332
333 return TargetID;
334}
335
336// Find the FSProfile file name. The internal option takes the precedence
337// before getting from TargetMachine.
338static std::string getFSProfileFile(const TargetMachine *TM) {
339 if (!FSProfileFile.empty())
340 return FSProfileFile.getValue();
341 const std::optional<PGOOptions> &PGOOpt = TM->getPGOOption();
342 if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse)
343 return std::string();
344 return PGOOpt->ProfileFile;
345}
346
347// Find the Profile remapping file name. The internal option takes the
348// precedence before getting from TargetMachine.
349static std::string getFSRemappingFile(const TargetMachine *TM) {
350 if (!FSRemappingFile.empty())
351 return FSRemappingFile.getValue();
352 const std::optional<PGOOptions> &PGOOpt = TM->getPGOOption();
353 if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse)
354 return std::string();
355 return PGOOpt->ProfileRemappingFile;
356}
357
358//===---------------------------------------------------------------------===//
359/// TargetPassConfig
360//===---------------------------------------------------------------------===//
361
362INITIALIZE_PASS(TargetPassConfig, "targetpassconfig",
363 "Target Pass Configuration", false, false)
365
366namespace {
367
371
372 InsertedPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID)
373 : TargetPassID(TargetPassID), InsertedPassID(InsertedPassID) {}
374
376 assert(InsertedPassID.isValid() && "Illegal Pass ID!");
377 if (InsertedPassID.isInstance())
378 return InsertedPassID.getInstance();
379 Pass *NP = Pass::createPass(InsertedPassID.getID());
380 assert(NP && "Pass ID not registered");
381 return NP;
382 }
383};
384
385} // end anonymous namespace
386
387namespace llvm {
388
390
392public:
393 // List of passes explicitly substituted by this target. Normally this is
394 // empty, but it is a convenient way to suppress or replace specific passes
395 // that are part of a standard pass pipeline without overridding the entire
396 // pipeline. This mechanism allows target options to inherit a standard pass's
397 // user interface. For example, a target may disable a standard pass by
398 // default by substituting a pass ID of zero, and the user may still enable
399 // that standard pass with an explicit command line option.
401
402 /// Store the pairs of <AnalysisID, AnalysisID> of which the second pass
403 /// is inserted after each instance of the first one.
405};
406
407} // end namespace llvm
408
409// Out of line virtual method.
411 delete Impl;
412}
413
415 if (PassName.empty())
416 return nullptr;
417
419 const PassInfo *PI = PR.getPassInfo(PassName);
420 if (!PI)
422 Twine("\" pass is not registered."));
423 return PI;
424}
425
427 const PassInfo *PI = getPassInfo(PassName);
428 return PI ? PI->getTypeInfo() : nullptr;
429}
430
431static std::pair<StringRef, unsigned>
433 StringRef Name, InstanceNumStr;
434 std::tie(Name, InstanceNumStr) = PassName.split(',');
435
436 unsigned InstanceNum = 0;
437 if (!InstanceNumStr.empty() && InstanceNumStr.getAsInteger(10, InstanceNum))
438 report_fatal_error("invalid pass instance specifier " + PassName);
439
440 return std::make_pair(Name, InstanceNum);
441}
442
443void TargetPassConfig::setStartStopPasses() {
444 StringRef StartBeforeName;
445 std::tie(StartBeforeName, StartBeforeInstanceNum) =
447
448 StringRef StartAfterName;
449 std::tie(StartAfterName, StartAfterInstanceNum) =
451
452 StringRef StopBeforeName;
453 std::tie(StopBeforeName, StopBeforeInstanceNum)
455
456 StringRef StopAfterName;
457 std::tie(StopAfterName, StopAfterInstanceNum)
459
460 StartBefore = getPassIDFromName(StartBeforeName);
461 StartAfter = getPassIDFromName(StartAfterName);
462 StopBefore = getPassIDFromName(StopBeforeName);
463 StopAfter = getPassIDFromName(StopAfterName);
464 if (StartBefore && StartAfter)
466 Twine(StartAfterOptName) + Twine(" specified!"));
467 if (StopBefore && StopAfter)
469 Twine(StopAfterOptName) + Twine(" specified!"));
470 Started = (StartAfter == nullptr) && (StartBefore == nullptr);
471}
472
475
476#define SET_OPTION(Option) \
477 if (Option.getNumOccurrences()) \
478 Opt.Option = Option;
479
491
492#define SET_BOOLEAN_OPTION(Option) Opt.Option = Option;
493
513
514 return Opt;
515}
516
518 TargetMachine &TM) {
519
520 // Register a callback for disabling passes.
522
523#define DISABLE_PASS(Option, Name) \
524 if (Option && P.contains(#Name)) \
525 return false;
526 DISABLE_PASS(DisableBlockPlacement, MachineBlockPlacementPass)
527 DISABLE_PASS(DisableBranchFold, BranchFolderPass)
528 DISABLE_PASS(DisableCopyProp, MachineCopyPropagationPass)
529 DISABLE_PASS(DisableEarlyIfConversion, EarlyIfConverterLegacyPass)
531 DISABLE_PASS(DisableMachineCSE, MachineCSELegacyPass)
534 DISABLE_PASS(DisableMachineSink, MachineSinkingPass)
536 DISABLE_PASS(DisablePostRAMachineSink, PostRAMachineSinkingPass)
537 DISABLE_PASS(DisablePostRASched, PostRASchedulerPass)
538 DISABLE_PASS(DisableSSC, StackSlotColoringPass)
540
541 return true;
542 });
543}
544
547 auto [StartBefore, StartBeforeInstanceNum] =
549 auto [StartAfter, StartAfterInstanceNum] =
551 auto [StopBefore, StopBeforeInstanceNum] =
553 auto [StopAfter, StopAfterInstanceNum] =
555
556 if (!StartBefore.empty() && !StartAfter.empty())
557 return make_error<StringError>(
558 Twine(StartBeforeOptName) + " and " + StartAfterOptName + " specified!",
559 std::make_error_code(std::errc::invalid_argument));
560 if (!StopBefore.empty() && !StopAfter.empty())
561 return make_error<StringError>(
562 Twine(StopBeforeOptName) + " and " + StopAfterOptName + " specified!",
563 std::make_error_code(std::errc::invalid_argument));
564
565 StartStopInfo Result;
566 Result.StartPass = StartBefore.empty() ? StartAfter : StartBefore;
567 Result.StopPass = StopBefore.empty() ? StopAfter : StopBefore;
568 Result.StartInstanceNum =
569 StartBefore.empty() ? StartAfterInstanceNum : StartBeforeInstanceNum;
570 Result.StopInstanceNum =
571 StopBefore.empty() ? StopAfterInstanceNum : StopBeforeInstanceNum;
572 Result.StartAfter = !StartAfter.empty();
573 Result.StopAfter = !StopAfter.empty();
574 Result.StartInstanceNum += Result.StartInstanceNum == 0;
575 Result.StopInstanceNum += Result.StopInstanceNum == 0;
576 return Result;
577}
578
579// Out of line constructor provides default values for pass options and
580// registers all common codegen passes.
582 : ImmutablePass(ID), PM(&PM), TM(&TM) {
583 Impl = new PassConfigImpl();
584
585 // Register all target independent codegen passes to activate their PassIDs,
586 // including this pass itself.
588
589 // Also register alias analysis passes required by codegen passes.
592
593 if (EnableIPRA.getNumOccurrences())
595 else {
596 // If not explicitly specified, use target default.
598 }
599
602
603 if (EnableGlobalISelAbort.getNumOccurrences())
605
606 setStartStopPasses();
607}
608
610 return TM->getOptLevel();
611}
612
613/// Insert InsertedPassID pass after TargetPassID.
615 IdentifyingPassPtr InsertedPassID) {
616 assert(((!InsertedPassID.isInstance() &&
617 TargetPassID != InsertedPassID.getID()) ||
618 (InsertedPassID.isInstance() &&
619 TargetPassID != InsertedPassID.getInstance()->getPassID())) &&
620 "Insert a pass after itself!");
621 Impl->InsertedPasses.emplace_back(TargetPassID, InsertedPassID);
622}
623
624/// createPassConfig - Create a pass configuration object to be used by
625/// addPassToEmitX methods for generating a pipeline of CodeGen passes.
626///
627/// Targets may override this to extend TargetPassConfig.
630 return new TargetPassConfig(*this, PM);
631}
632
634 : ImmutablePass(ID) {
635 report_fatal_error("Trying to construct TargetPassConfig without a target "
636 "machine. Scheduling a CodeGen pass without a target "
637 "triple set?");
638}
639
641 return StopBeforeOpt.empty() && StopAfterOpt.empty();
642}
643
645 return !StartBeforeOpt.empty() || !StartAfterOpt.empty() ||
647}
648
651 return std::string();
652 std::string Res;
653 static cl::opt<std::string> *PassNames[] = {&StartAfterOpt, &StartBeforeOpt,
655 static const char *OptNames[] = {StartAfterOptName, StartBeforeOptName,
657 bool IsFirst = true;
658 for (int Idx = 0; Idx < 4; ++Idx)
659 if (!PassNames[Idx]->empty()) {
660 if (!IsFirst)
661 Res += " and ";
662 IsFirst = false;
663 Res += OptNames[Idx];
664 }
665 return Res;
666}
667
668// Helper to verify the analysis is really immutable.
669void TargetPassConfig::setOpt(bool &Opt, bool Val) {
670 assert(!Initialized && "PassConfig is immutable");
671 Opt = Val;
672}
673
675 IdentifyingPassPtr TargetID) {
676 Impl->TargetPasses[StandardID] = TargetID;
677}
678
681 I = Impl->TargetPasses.find(ID);
682 if (I == Impl->TargetPasses.end())
683 return ID;
684 return I->second;
685}
686
689 IdentifyingPassPtr FinalPtr = overridePass(ID, TargetID);
690 return !FinalPtr.isValid() || FinalPtr.isInstance() ||
691 FinalPtr.getID() != ID;
692}
693
694/// Add a pass to the PassManager if that pass is supposed to be run. If the
695/// Started/Stopped flags indicate either that the compilation should start at
696/// a later pass or that it should stop after an earlier pass, then do not add
697/// the pass. Finally, compare the current pass against the StartAfter
698/// and StopAfter options and change the Started/Stopped flags accordingly.
700 assert(!Initialized && "PassConfig is immutable");
701
702 // Cache the Pass ID here in case the pass manager finds this pass is
703 // redundant with ones already scheduled / available, and deletes it.
704 // Fundamentally, once we add the pass to the manager, we no longer own it
705 // and shouldn't reference it.
706 AnalysisID PassID = P->getPassID();
707
708 if (StartBefore == PassID && StartBeforeCount++ == StartBeforeInstanceNum)
709 Started = true;
710 if (StopBefore == PassID && StopBeforeCount++ == StopBeforeInstanceNum)
711 Stopped = true;
712 if (Started && !Stopped) {
713 if (AddingMachinePasses) {
714 // Construct banner message before PM->add() as that may delete the pass.
715 std::string Banner =
716 std::string("After ") + std::string(P->getPassName());
718 PM->add(P);
719 addMachinePostPasses(Banner);
720 } else {
721 PM->add(P);
722 }
723
724 // Add the passes after the pass P if there is any.
725 for (const auto &IP : Impl->InsertedPasses)
726 if (IP.TargetPassID == PassID)
727 addPass(IP.getInsertedPass());
728 } else {
729 delete P;
730 }
731
732 if (StopAfter == PassID && StopAfterCount++ == StopAfterInstanceNum)
733 Stopped = true;
734
735 if (StartAfter == PassID && StartAfterCount++ == StartAfterInstanceNum)
736 Started = true;
737 if (Stopped && !Started)
738 report_fatal_error("Cannot stop compilation after pass that is not run");
739}
740
741/// Add a CodeGen pass at this point in the pipeline after checking for target
742/// and command line overrides.
743///
744/// addPass cannot return a pointer to the pass instance because is internal the
745/// PassManager and the instance we create here may already be freed.
747 IdentifyingPassPtr TargetID = getPassSubstitution(PassID);
748 IdentifyingPassPtr FinalPtr = overridePass(PassID, TargetID);
749 if (!FinalPtr.isValid())
750 return nullptr;
751
752 Pass *P;
753 if (FinalPtr.isInstance())
754 P = FinalPtr.getInstance();
755 else {
756 P = Pass::createPass(FinalPtr.getID());
757 if (!P)
758 llvm_unreachable("Pass ID not registered");
759 }
760 AnalysisID FinalID = P->getPassID();
761 addPass(P); // Ends the lifetime of P.
762
763 return FinalID;
764}
765
766void TargetPassConfig::printAndVerify(const std::string &Banner) {
767 addPrintPass(Banner);
768 addVerifyPass(Banner);
769}
770
771void TargetPassConfig::addPrintPass(const std::string &Banner) {
772 if (PrintAfterISel)
774}
775
776void TargetPassConfig::addVerifyPass(const std::string &Banner) {
778#ifdef EXPENSIVE_CHECKS
781#endif
782 if (Verify)
783 PM->add(createMachineVerifierPass(Banner));
784}
785
788}
789
791 PM->add(createStripDebugMachineModulePass(/*OnlyDebugified=*/true));
792}
793
796}
797
799 if (AllowDebugify && DebugifyIsSafe &&
803}
804
805void TargetPassConfig::addMachinePostPasses(const std::string &Banner) {
806 if (DebugifyIsSafe) {
810 } else if (DebugifyAndStripAll == cl::BOU_TRUE)
812 }
813 addVerifyPass(Banner);
814}
815
816/// Add common target configurable passes that perform LLVM IR to IR transforms
817/// following machine independent optimization.
819 // Before running any passes, run the verifier to determine if the input
820 // coming from the front-end and/or optimizer is valid.
821 if (!DisableVerify)
823
825 // Basic AliasAnalysis support.
826 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
827 // BasicAliasAnalysis wins if they disagree. This is intended to help
828 // support "obvious" type-punning idioms.
832
833 // Run loop strength reduction before anything else.
834 if (!DisableLSR) {
839 if (PrintLSR)
841 "\n\n*** Code after LSR ***\n"));
842 }
843
844 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
845 // loads and compares. ExpandMemCmpPass then tries to expand those calls
846 // into optimally-sized loads and compares. The transforms are enabled by a
847 // target lowering hook.
851 }
852
853 // Run GC lowering passes for builtin collectors
854 // TODO: add a pass insertion point here
857
858 // For MachO, lower @llvm.global_dtors into @llvm.global_ctors with
859 // __cxa_atexit() calls to avoid emitting the deprecated __mod_term_func.
863
864 // Make sure that no unreachable blocks are instruction selected.
866
867 // Prepare expensive constants for SelectionDAG.
870
873
876
877 // Instrument function entry after all inlining.
879
880 // Add scalarization of target's unsupported masked memory intrinsics pass.
881 // the unsupported intrinsic will be replaced with a chain of basic blocks,
882 // that stores/loads element one-by-one if the appropriate mask bit is set.
884
885 // Expand reduction intrinsics into shuffle sequences if the target wants to.
886 // Allow disabling it for testing purposes.
889
890 // Convert conditional moves to conditional jumps when profitable.
893
896}
897
898/// Turn exception handling constructs into something the code generators can
899/// handle.
901 const MCAsmInfo *MCAI = TM->getMCAsmInfo();
902 assert(MCAI && "No MCAsmInfo");
903 switch (MCAI->getExceptionHandlingType()) {
905 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
906 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
907 // catch info can get misplaced when a selector ends up more than one block
908 // removed from the parent invoke(s). This could happen when a landing
909 // pad is shared by multiple invokes and is also a target of a normal
910 // edge from elsewhere.
912 [[fallthrough]];
918 break;
920 // We support using both GCC-style and MSVC-style exceptions on Windows, so
921 // add both preparation passes. Each pass will only actually run if it
922 // recognizes the personality function.
925 break;
927 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
928 // on catchpads and cleanuppads because it does not outline them into
929 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
930 // should remove PHIs there.
931 addPass(createWinEHPass(/*DemoteCatchSwitchPHIOnly=*/true));
933 break;
936
937 // The lower invoke pass may create unreachable code. Remove it.
939 break;
940 }
941}
942
943/// Add pass to prepare the LLVM IR for code generation. This should be done
944/// before exception handling preparation passes.
948}
949
950/// Add common passes that perform LLVM IR to IR transforms in preparation for
951/// instruction selection.
953 addPreISel();
954
955 // Force codegen to run according to the callgraph.
958
961
963
964 // Add both the safe stack and the stack protection passes: each of them will
965 // only protect functions that have corresponding attributes.
968
969 if (PrintISelInput)
971 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"));
972
973 // All passes which modify the LLVM IR are now complete; run the verifier
974 // to ensure that the IR is valid.
975 if (!DisableVerify)
977}
978
980 // Enable FastISel with -fast-isel, but allow that to be overridden.
982
983 // Determine an instruction selector.
984 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
985 SelectorType Selector;
986
988 Selector = SelectorType::FastISel;
992 Selector = SelectorType::GlobalISel;
993 else if (TM->getOptLevel() == CodeGenOptLevel::None &&
995 Selector = SelectorType::FastISel;
996 else
997 Selector = SelectorType::SelectionDAG;
998
999 // Set consistently TM->Options.EnableFastISel and EnableGlobalISel.
1000 if (Selector == SelectorType::FastISel) {
1001 TM->setFastISel(true);
1002 TM->setGlobalISel(false);
1003 } else if (Selector == SelectorType::GlobalISel) {
1004 TM->setFastISel(false);
1005 TM->setGlobalISel(true);
1006 }
1007
1008 // FIXME: Injecting into the DAGISel pipeline seems to cause issues with
1009 // analyses needing to be re-run. This can result in being unable to
1010 // schedule passes (particularly with 'Function Alias Analysis
1011 // Results'). It's not entirely clear why but AFAICT this seems to be
1012 // due to one FunctionPassManager not being able to use analyses from a
1013 // previous one. As we're injecting a ModulePass we break the usual
1014 // pass manager into two. GlobalISel with the fallback path disabled
1015 // and -run-pass seem to be unaffected. The majority of GlobalISel
1016 // testing uses -run-pass so this probably isn't too bad.
1017 SaveAndRestore SavedDebugifyIsSafe(DebugifyIsSafe);
1018 if (Selector != SelectorType::GlobalISel || !isGlobalISelAbortEnabled())
1019 DebugifyIsSafe = false;
1020
1021 // Add instruction selector passes.
1022 if (Selector == SelectorType::GlobalISel) {
1023 SaveAndRestore SavedAddingMachinePasses(AddingMachinePasses, true);
1024 if (addIRTranslator())
1025 return true;
1026
1028
1030 return true;
1031
1032 // Before running the register bank selector, ask the target if it
1033 // wants to run some passes.
1035
1036 if (addRegBankSelect())
1037 return true;
1038
1040
1042 return true;
1043
1044 // Pass to reset the MachineFunction if the ISel failed.
1047
1048 // Provide a fallback path when we do not want to abort on
1049 // not-yet-supported input.
1051 return true;
1052
1053 } else if (addInstSelector())
1054 return true;
1055
1056 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
1057 // FinalizeISel.
1059
1060 // Print the instruction selected machine code...
1061 printAndVerify("After Instruction Selection");
1062
1063 return false;
1064}
1065
1067 if (TM->useEmulatedTLS())
1069
1074 addIRPasses();
1078
1079 return addCoreISelPasses();
1080}
1081
1082/// -regalloc=... command line option.
1083static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
1087 cl::desc("Register allocator to use"));
1088
1089/// Add the complete set of target-independent postISel code generator passes.
1090///
1091/// This can be read as the standard order of major LLVM CodeGen stages. Stages
1092/// with nontrivial configuration or multiple passes are broken out below in
1093/// add%Stage routines.
1094///
1095/// Any TargetPassConfig::addXX routine may be overriden by the Target. The
1096/// addPre/Post methods with empty header implementations allow injecting
1097/// target-specific fixups just before or after major stages. Additionally,
1098/// targets have the flexibility to change pass order within a stage by
1099/// overriding default implementation of add%Stage routines below. Each
1100/// technique has maintainability tradeoffs because alternate pass orders are
1101/// not well supported. addPre/Post works better if the target pass is easily
1102/// tied to a common pass. But if it has subtle dependencies on multiple passes,
1103/// the target should override the stage instead.
1104///
1105/// TODO: We could use a single addPre/Post(ID) hook to allow pass injection
1106/// before/after any target-independent pass. But it's currently overkill.
1108 AddingMachinePasses = true;
1109
1110 // Add passes that optimize machine instructions in SSA form.
1113 } else {
1114 // If the target requests it, assign local variables to stack slots relative
1115 // to one another and simplify frame index references where possible.
1117 }
1118
1119 if (TM->Options.EnableIPRA)
1121
1122 // Run pre-ra passes.
1124
1125 // Debugifying the register allocator passes seems to provoke some
1126 // non-determinism that affects CodeGen and there doesn't seem to be a point
1127 // where it becomes safe again so stop debugifying here.
1128 DebugifyIsSafe = false;
1129
1130 // Add a FSDiscriminator pass right before RA, so that we could get
1131 // more precise SampleFDO profile for RA.
1135 const std::string ProfileFile = getFSProfileFile(TM);
1136 if (!ProfileFile.empty() && !DisableRAFSProfileLoader)
1139 nullptr));
1140 }
1141
1142 // Run register allocation and passes that are tightly coupled with it,
1143 // including phi elimination and scheduling.
1144 if (getOptimizeRegAlloc())
1146 else
1148
1149 // Run post-ra passes.
1151
1153
1155
1156 // Insert prolog/epilog code. Eliminate abstract frame index references...
1160 }
1161
1162 // Prolog/Epilog inserter needs a TargetMachine to instantiate. But only
1163 // do so if it hasn't been disabled, substituted, or overridden.
1166
1167 /// Add passes that optimize machine instructions after register allocation.
1170
1171 // Expand pseudo instructions before second scheduling pass.
1173
1174 // Run pre-sched2 passes.
1175 addPreSched2();
1176
1179
1180 // Second pass scheduler.
1181 // Let Target optionally insert this pass by itself at some other
1182 // point.
1185 if (MISchedPostRA)
1187 else
1189 }
1190
1191 // GC
1192 addGCPasses();
1193
1194 // Basic block placement.
1197
1198 // Insert before XRay Instrumentation.
1200
1203
1205
1206 if (TM->Options.EnableIPRA)
1207 // Collect register usage information and produce a register mask of
1208 // clobbered registers, to be used to optimize call sites.
1210
1211 // FIXME: Some backends are incompatible with running the verifier after
1212 // addPreEmitPass. Maybe only pass "false" here for those targets?
1214
1219
1223 bool RunOnAllFunctions =
1225 bool AddOutliner =
1226 RunOnAllFunctions || TM->Options.SupportsDefaultOutlining;
1227 if (AddOutliner)
1228 addPass(createMachineOutlinerPass(RunOnAllFunctions));
1229 }
1230
1231 if (GCEmptyBlocks)
1233
1237
1238 // Machine function splitter uses the basic block sections feature.
1239 // When used along with `-basic-block-sections=`, the basic-block-sections
1240 // feature takes precedence. This means functions eligible for
1241 // basic-block-sections optimizations (`=all`, or `=list=` with function
1242 // included in the list profile) will get that optimization instead.
1245 const std::string ProfileFile = getFSProfileFile(TM);
1246 if (!ProfileFile.empty()) {
1249 ProfileFile, getFSRemappingFile(TM),
1251 } else {
1252 // Sample profile is given, but FSDiscriminator is not
1253 // enabled, this may result in performance regression.
1255 << "Using AutoFDO without FSDiscriminator for MFS may regress "
1256 "performance.\n";
1257 }
1258 }
1260 }
1261 // We run the BasicBlockSections pass if either we need BB sections or BB
1262 // address map (or both).
1264 TM->Options.BBAddrMap) {
1269 }
1271 }
1272
1274
1277
1279
1280 // Add passes that directly emit MI after all other MI passes.
1282
1283 AddingMachinePasses = false;
1284}
1285
1286/// Add passes that optimize machine instructions in SSA form.
1288 // Pre-ra tail duplication.
1290
1291 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1292 // instructions dead.
1294
1295 // This pass merges large allocas. StackSlotColoring is a different pass
1296 // which merges spill slots.
1298
1299 // If the target requests it, assign local variables to stack slots relative
1300 // to one another and simplify frame index references where possible.
1302
1303 // With optimization, dead code should already be eliminated. However
1304 // there is one known exception: lowered code for arguments that are only
1305 // used by tail calls, where the tail calls reuse the incoming stack
1306 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1308
1309 // Allow targets to insert passes that improve instruction level parallelism,
1310 // like if-conversion. Such passes will typically need dominator trees and
1311 // loop info, just like LICM and CSE below.
1312 addILPOpts();
1313
1316
1318
1320 // Clean-up the dead code that may have been generated by peephole
1321 // rewriting.
1323}
1324
1325//===---------------------------------------------------------------------===//
1326/// Register Allocation Pass Configuration
1327//===---------------------------------------------------------------------===//
1328
1330 switch (OptimizeRegAlloc) {
1331 case cl::BOU_UNSET:
1333 case cl::BOU_TRUE: return true;
1334 case cl::BOU_FALSE: return false;
1335 }
1336 llvm_unreachable("Invalid optimize-regalloc state");
1337}
1338
1339/// A dummy default pass factory indicates whether the register allocator is
1340/// overridden on the command line.
1342
1343static RegisterRegAlloc
1345 "pick register allocator based on -O option",
1347
1351}
1352
1353/// Instantiate the default register allocator pass for this target for either
1354/// the optimized or unoptimized allocation path. This will be added to the pass
1355/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1356/// in the optimized case.
1357///
1358/// A target that uses the standard regalloc pass order for fast or optimized
1359/// allocation may still override this for per-target regalloc
1360/// selection. But -regalloc=... always takes precedence.
1362 if (Optimized)
1364 else
1366}
1367
1368/// Find and instantiate the register allocation pass requested by this target
1369/// at the current optimization level. Different register allocators are
1370/// defined as separate passes because they may require different analysis.
1371///
1372/// This helper ensures that the regalloc= option is always available,
1373/// even for targets that override the default allocator.
1374///
1375/// FIXME: When MachinePassRegistry register pass IDs instead of function ptrs,
1376/// this can be folded into addPass.
1378 // Initialize the global default.
1381
1383 if (Ctor != useDefaultRegisterAllocator)
1384 return Ctor();
1385
1386 // With no -regalloc= override, ask the target for a regalloc pass.
1387 return createTargetRegisterAllocator(Optimized);
1388}
1389
1391 return RegAlloc !=
1393}
1394
1398 report_fatal_error("Must use fast (default) register allocator for unoptimized regalloc.");
1399
1401
1402 // Allow targets to change the register assignments after
1403 // fast register allocation.
1405 return true;
1406}
1407
1409 // Add the selected register allocation pass.
1411
1412 // Allow targets to change the register assignments before rewriting.
1413 addPreRewrite();
1414
1415 // Finally rewrite virtual registers.
1417
1418 // Regalloc scoring for ML-driven eviction - noop except when learning a new
1419 // eviction policy.
1421 return true;
1422}
1423
1424/// Return true if the default global register allocator is in use and
1425/// has not be overriden on the command line with '-regalloc=...'
1427 return RegAlloc.getNumOccurrences() == 0;
1428}
1429
1430/// Add the minimum set of target-independent passes that are required for
1431/// register allocation. No coalescing or scheduling.
1435
1437}
1438
1439/// Add standard target-independent passes that are tightly coupled with
1440/// optimized register allocation, including coalescing, machine instruction
1441/// scheduling, and register allocation itself.
1444
1446
1448
1449 // LiveVariables currently requires pure SSA form.
1450 //
1451 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1452 // LiveVariables can be removed completely, and LiveIntervals can be directly
1453 // computed. (We still either need to regenerate kill flags after regalloc, or
1454 // preferably fix the scavenger to not depend on them).
1455 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1456 // When LiveVariables is removed this has to be removed/moved either.
1457 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1458 // after it with -stop-before/-stop-after.
1461
1462 // Edge splitting is smarter with machine loop info.
1465
1466 // Eventually, we want to run LiveIntervals before PHI elimination.
1469
1472
1473 // The machine scheduler may accidentally create disconnected components
1474 // when moving subregister definitions around, avoid this by splitting them to
1475 // separate vregs before. Splitting can also improve reg. allocation quality.
1477
1478 // PreRA instruction scheduling.
1480
1482 // Perform stack slot coloring and post-ra machine LICM.
1484
1485 // Allow targets to expand pseudo instructions depending on the choice of
1486 // registers before MachineCopyPropagation.
1488
1489 // Copy propagate to forward register uses and try to eliminate COPYs that
1490 // were not coalesced.
1492
1493 // Run post-ra machine LICM to hoist reloads / remats.
1494 //
1495 // FIXME: can this move into MachineLateOptimization?
1497 }
1498}
1499
1500//===---------------------------------------------------------------------===//
1501/// Post RegAlloc Pass Configuration
1502//===---------------------------------------------------------------------===//
1503
1504/// Add passes that optimize machine instructions after register allocation.
1506 // Cleanup of redundant immediate/address loads.
1508
1509 // Branch folding must be run after regalloc and prolog/epilog insertion.
1511
1512 // Tail duplication.
1513 // Note that duplicating tail just increases code size and degrades
1514 // performance for targets that require Structured Control Flow.
1515 // In addition it can also make CFG irreducible. Thus we disable it.
1516 if (!TM->requiresStructuredCFG())
1518
1519 // Copy propagation.
1521}
1522
1523/// Add standard GC passes.
1526 return true;
1527}
1528
1529/// Add standard basic block placement passes.
1534 const std::string ProfileFile = getFSProfileFile(TM);
1535 if (!ProfileFile.empty() && !DisableLayoutFSProfileLoader)
1538 nullptr));
1539 }
1541 // Run a separate pass to collect block placement statistics.
1544 }
1545}
1546
1547//===---------------------------------------------------------------------===//
1548/// GlobalISel Configuration
1549//===---------------------------------------------------------------------===//
1552}
1553
1556}
1557
1559 return true;
1560}
1561
1562std::unique_ptr<CSEConfigBase> TargetPassConfig::getCSEConfig() const {
1563 return std::make_unique<CSEConfigBase>();
1564}
This is the interface for LLVM's primary stateless and local alias analysis.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:686
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
std::string Name
This file contains an interface for creating legacy passes to print out IR in various granularities.
#define I(x, y, z)
Definition: MD5.cpp:58
#define P(N)
ppc ctr loops PowerPC CTR Loops Verify
PassInstrumentationCallbacks PIC
This file defines the Pass Instrumentation classes that provide instrumentation points into the pass ...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:38
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file provides utility classes that use RAII to save and restore values.
This is the interface for a metadata-based scoped no-alias analysis.
This file defines the SmallVector class.
static const char StopAfterOptName[]
static cl::opt< bool > DisableExpandReductions("disable-expand-reductions", cl::init(false), cl::Hidden, cl::desc("Disable the expand reduction intrinsics pass from running"))
Disable the expand reductions pass for testing.
static cl::opt< bool > EnableImplicitNullChecks("enable-implicit-null-checks", cl::desc("Fold null checks into faulting memory operations"), cl::init(false), cl::Hidden)
static cl::opt< bool > DisableMachineSink("disable-machine-sink", cl::Hidden, cl::desc("Disable Machine Sinking"))
static cl::opt< cl::boolOrDefault > DebugifyAndStripAll("debugify-and-strip-all-safe", cl::Hidden, cl::desc("Debugify MIR before and Strip debug after " "each pass except those known to be unsafe " "when debug info is present"))
static llvm::once_flag InitializeDefaultRegisterAllocatorFlag
A dummy default pass factory indicates whether the register allocator is overridden on the command li...
static cl::opt< bool > DisableAtExitBasedGlobalDtorLowering("disable-atexit-based-global-dtor-lowering", cl::Hidden, cl::desc("For MachO, disable atexit()-based global destructor lowering"))
static cl::opt< RegisterRegAlloc::FunctionPassCtor, false, RegisterPassParser< RegisterRegAlloc > > RegAlloc("regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator), cl::desc("Register allocator to use"))
static cl::opt< bool > PrintISelInput("print-isel-input", cl::Hidden, cl::desc("Print LLVM IR input to isel pass"))
static FunctionPass * useDefaultRegisterAllocator()
-regalloc=... command line option.
static cl::opt< bool > DisablePostRASched("disable-post-ra", cl::Hidden, cl::desc("Disable Post Regalloc Scheduler"))
static cl::opt< bool > EnableBlockPlacementStats("enable-block-placement-stats", cl::Hidden, cl::desc("Collect probability-driven block placement stats"))
static cl::opt< bool > DisableMachineDCE("disable-machine-dce", cl::Hidden, cl::desc("Disable Machine Dead Code Elimination"))
static std::string getFSRemappingFile(const TargetMachine *TM)
static const char StopBeforeOptName[]
static AnalysisID getPassIDFromName(StringRef PassName)
static cl::opt< bool > DisableEarlyIfConversion("disable-early-ifcvt", cl::Hidden, cl::desc("Disable Early If-conversion"))
static cl::opt< bool > DisableReplaceWithVecLib("disable-replace-with-vec-lib", cl::Hidden, cl::desc("Disable replace with vector math call pass"))
static cl::opt< bool > EnableMachineFunctionSplitter("enable-split-machine-functions", cl::Hidden, cl::desc("Split out cold blocks from machine functions based on profile " "information."))
Enable the machine function splitter pass.
static IdentifyingPassPtr overridePass(AnalysisID StandardID, IdentifyingPassPtr TargetID)
Allow standard passes to be disabled by the command line, regardless of who is adding the pass.
static std::pair< StringRef, unsigned > getPassNameAndInstanceNum(StringRef PassName)
static cl::opt< bool > PrintAfterISel("print-after-isel", cl::init(false), cl::Hidden, cl::desc("Print machine instrs after ISel"))
static cl::opt< cl::boolOrDefault > VerifyMachineCode("verify-machineinstrs", cl::Hidden, cl::desc("Verify generated machine code"))
static cl::opt< bool > DisablePartialLibcallInlining("disable-partial-libcall-inlining", cl::Hidden, cl::desc("Disable Partial Libcall Inlining"))
#define SET_BOOLEAN_OPTION(Option)
static cl::opt< std::string > StartAfterOpt(StringRef(StartAfterOptName), cl::desc("Resume compilation after a specific pass"), cl::value_desc("pass-name"), cl::init(""), cl::Hidden)
static cl::opt< bool > DisableBlockPlacement("disable-block-placement", cl::Hidden, cl::desc("Disable probability-driven block placement"))
static cl::opt< bool > DisableRAFSProfileLoader("disable-ra-fsprofile-loader", cl::init(false), cl::Hidden, cl::desc("Disable MIRProfileLoader before RegAlloc"))
static cl::opt< std::string > StopAfterOpt(StringRef(StopAfterOptName), cl::desc("Stop compilation after a specific pass"), cl::value_desc("pass-name"), cl::init(""), cl::Hidden)
static void initializeDefaultRegisterAllocatorOnce()
static cl::opt< bool > PrintLSR("print-lsr-output", cl::Hidden, cl::desc("Print LLVM IR produced by the loop-reduce pass"))
static cl::opt< bool > DisableSelectOptimize("disable-select-optimize", cl::init(true), cl::Hidden, cl::desc("Disable the select-optimization pass from running"))
Disable the select optimization pass.
static cl::opt< std::string > FSRemappingFile("fs-remapping-file", cl::init(""), cl::value_desc("filename"), cl::desc("Flow Sensitive profile remapping file name."), cl::Hidden)
static cl::opt< bool > DisableCFIFixup("disable-cfi-fixup", cl::Hidden, cl::desc("Disable the CFI fixup pass"))
static cl::opt< bool > DisablePostRAMachineLICM("disable-postra-machine-licm", cl::Hidden, cl::desc("Disable Machine LICM"))
static const char StartBeforeOptName[]
static const PassInfo * getPassInfo(StringRef PassName)
static cl::opt< bool > EarlyLiveIntervals("early-live-intervals", cl::Hidden, cl::desc("Run live interval analysis earlier in the pipeline"))
static cl::opt< bool > DisableMachineLICM("disable-machine-licm", cl::Hidden, cl::desc("Disable Machine LICM"))
static cl::opt< cl::boolOrDefault > EnableGlobalISelOption("global-isel", cl::Hidden, cl::desc("Enable the \"global\" instruction selector"))
static cl::opt< bool > DisableTailDuplicate("disable-tail-duplicate", cl::Hidden, cl::desc("Disable tail duplication"))
static cl::opt< bool > DisablePostRAMachineSink("disable-postra-machine-sink", cl::Hidden, cl::desc("Disable PostRA Machine Sinking"))
static const char StartAfterOptName[]
Option names for limiting the codegen pipeline.
static cl::opt< bool > EnableIPRA("enable-ipra", cl::init(false), cl::Hidden, cl::desc("Enable interprocedural register allocation " "to reduce load/store at procedure calls."))
static cl::opt< bool > DisableCGP("disable-cgp", cl::Hidden, cl::desc("Disable Codegen Prepare"))
static std::string getFSProfileFile(const TargetMachine *TM)
static cl::opt< std::string > StartBeforeOpt(StringRef(StartBeforeOptName), cl::desc("Resume compilation before a specific pass"), cl::value_desc("pass-name"), cl::init(""), cl::Hidden)
static IdentifyingPassPtr applyDisable(IdentifyingPassPtr PassID, bool Override)
Allow standard passes to be disabled by command line options.
static cl::opt< bool > GCEmptyBlocks("gc-empty-basic-blocks", cl::init(false), cl::Hidden, cl::desc("Enable garbage-collecting empty basic blocks"))
Enable garbage-collecting empty basic blocks.
static cl::opt< GlobalISelAbortMode > EnableGlobalISelAbort("global-isel-abort", cl::Hidden, cl::desc("Enable abort calls when \"global\" instruction selection " "fails to lower/select an instruction"), cl::values(clEnumValN(GlobalISelAbortMode::Disable, "0", "Disable the abort"), clEnumValN(GlobalISelAbortMode::Enable, "1", "Enable the abort"), clEnumValN(GlobalISelAbortMode::DisableWithDiag, "2", "Disable the abort but emit a diagnostic on failure")))
static cl::opt< bool > DisableEarlyTailDup("disable-early-taildup", cl::Hidden, cl::desc("Disable pre-register allocation tail duplication"))
static cl::opt< bool > DisableConstantHoisting("disable-constant-hoisting", cl::Hidden, cl::desc("Disable ConstantHoisting"))
static cl::opt< cl::boolOrDefault > EnableFastISelOption("fast-isel", cl::Hidden, cl::desc("Enable the \"fast\" instruction selector"))
static cl::opt< bool > DisableSSC("disable-ssc", cl::Hidden, cl::desc("Disable Stack Slot Coloring"))
static cl::opt< bool > EnableGlobalMergeFunc("enable-global-merge-func", cl::Hidden, cl::desc("Enable global merge functions that are based on hash function"))
static cl::opt< bool > DisableBranchFold("disable-branch-fold", cl::Hidden, cl::desc("Disable branch folding"))
#define DISABLE_PASS(Option, Name)
static RegisterRegAlloc defaultRegAlloc("default", "pick register allocator based on -O option", useDefaultRegisterAllocator)
static cl::opt< std::string > StopBeforeOpt(StringRef(StopBeforeOptName), cl::desc("Stop compilation before a specific pass"), cl::value_desc("pass-name"), cl::init(""), cl::Hidden)
static cl::opt< bool > DisableMachineCSE("disable-machine-cse", cl::Hidden, cl::desc("Disable Machine Common Subexpression Elimination"))
static cl::opt< bool > DisableLayoutFSProfileLoader("disable-layout-fsprofile-loader", cl::init(false), cl::Hidden, cl::desc("Disable MIRProfileLoader before BlockPlacement"))
static cl::opt< bool > MISchedPostRA("misched-postra", cl::Hidden, cl::desc("Run MachineScheduler post regalloc (independent of preRA sched)"))
static cl::opt< bool > DisableMergeICmps("disable-mergeicmps", cl::desc("Disable MergeICmps Pass"), cl::init(false), cl::Hidden)
static cl::opt< RunOutliner > EnableMachineOutliner("enable-machine-outliner", cl::desc("Enable the machine outliner"), cl::Hidden, cl::ValueOptional, cl::init(RunOutliner::TargetDefault), cl::values(clEnumValN(RunOutliner::AlwaysOutline, "always", "Run on all functions guaranteed to be beneficial"), clEnumValN(RunOutliner::NeverOutline, "never", "Disable all outlining"), clEnumValN(RunOutliner::AlwaysOutline, "", "")))
static cl::opt< bool > DisableCopyProp("disable-copyprop", cl::Hidden, cl::desc("Disable Copy Propagation pass"))
static cl::opt< cl::boolOrDefault > OptimizeRegAlloc("optimize-regalloc", cl::Hidden, cl::desc("Enable optimized register allocation compilation path."))
static cl::opt< bool > DisableLSR("disable-lsr", cl::Hidden, cl::desc("Disable Loop Strength Reduction Pass"))
static cl::opt< std::string > FSProfileFile("fs-profile-file", cl::init(""), cl::value_desc("filename"), cl::desc("Flow Sensitive profile file name."), cl::Hidden)
static cl::opt< cl::boolOrDefault > DebugifyCheckAndStripAll("debugify-check-and-strip-all-safe", cl::Hidden, cl::desc("Debugify MIR before, by checking and stripping the debug info after, " "each pass except those known to be unsafe when debug info is " "present"))
#define SET_OPTION(Option)
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
This is the interface for a metadata-based TBAA.
Defines the virtual file system interface vfs::FileSystem.
static const char PassName[]
Definition: Any.h:28
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
This pass is required by interprocedural register allocation.
Tagged union holding either a T or a Error.
Definition: Error.h:481
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition: FastISel.h:66
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
Discriminated union of Pass ID types.
AnalysisID getID() const
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:281
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
ExceptionHandling getExceptionHandlingType() const
Definition: MCAsmInfo.h:740
DenseMap< AnalysisID, IdentifyingPassPtr > TargetPasses
SmallVector< InsertedPass, 4 > InsertedPasses
Store the pairs of <AnalysisID, AnalysisID> of which the second pass is inserted after each instance ...
PassInfo class - An instance of this class exists for every pass known by the system,...
Definition: PassInfo.h:30
const void * getTypeInfo() const
getTypeInfo - Return the id object for the pass... TODO : Rename
Definition: PassInfo.h:63
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:37
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
const PassInfo * getPassInfo(const void *TI) const
getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass' type identifier (&MyPass::...
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
static Pass * createPass(AnalysisID ID)
Definition: Pass.cpp:200
AnalysisID getPassID() const
getPassID - Return the PassID number that corresponds to this pass.
Definition: Pass.h:113
RegisterPassParser class - Handle the addition of new machine passes.
static void setDefault(FunctionPassCtor C)
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:228
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:937
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition: StringRef.h:470
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:147
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
const Triple & getTargetTriple() const
void setFastISel(bool Enable)
const MemoryBuffer * getBBSectionsFuncListBuf() const
Get the list of functions and basic block ids that need unique sections.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
virtual bool targetSchedulesPostRAScheduling() const
True if subtarget inserts the final scheduling pass on its own.
bool requiresStructuredCFG() const
virtual bool isMachineVerifierClean() const
Returns true if the target is expected to pass all machine verifier checks.
void setGlobalISel(bool Enable)
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
TargetOptions Options
void setO0WantsFastISel(bool Enable)
virtual bool useIPRA() const
True if the target wants to use interprocedural register allocation by default.
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
unsigned EnableCFIFixup
Enable the CFIFixup pass.
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
unsigned EnableMachineFunctionSplitter
Enables the MachineFunctionSplitter pass.
unsigned EnableIPRA
This flag enables InterProcedural Register Allocation (IPRA).
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
Target-Independent Code Generator Pass Configuration Options.
bool usingDefaultRegAlloc() const
Return true if the default global register allocator is in use and has not be overriden on the comman...
bool requiresCodeGenSCCOrder() const
void addCheckDebugPass()
Add a pass to check synthesized debug info for MIR.
virtual void addPreLegalizeMachineIR()
This method may be implemented by targets that want to run passes immediately before legalization.
void addPrintPass(const std::string &Banner)
Add a pass to print the machine function if printing is enabled.
virtual void addPreEmitPass2()
Targets may add passes immediately before machine code is emitted in this callback.
virtual std::unique_ptr< CSEConfigBase > getCSEConfig() const
Returns the CSEConfig object to use for the current optimization level.
bool EnableLoopTermFold
Enable LoopTermFold immediately after LSR.
void printAndVerify(const std::string &Banner)
printAndVerify - Add a pass to dump then verify the machine function, if those steps are enabled.
static bool hasLimitedCodeGenPipeline()
Returns true if one of the -start-after, -start-before, -stop-after or -stop-before options is set.
static Expected< StartStopInfo > getStartStopInfo(PassInstrumentationCallbacks &PIC)
Returns pass name in -stop-before or -stop-after NOTE: New pass manager migration only.
virtual void addCodeGenPrepare()
Add pass to prepare the LLVM IR for code generation.
void insertPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID)
Insert InsertedPassID pass after TargetPassID pass.
void addMachinePostPasses(const std::string &Banner)
Add standard passes after a pass that has just been added.
virtual void addPreSched2()
This method may be implemented by targets that want to run passes after prolog-epilog insertion and b...
virtual bool isGISelCSEEnabled() const
Check whether continuous CSE should be enabled in GISel passes.
virtual bool addILPOpts()
Add passes that optimize instruction level parallelism for out-of-order targets.
virtual void addPostRegAlloc()
This method may be implemented by targets that want to run passes after register allocation pass pipe...
void addDebugifyPass()
Add a pass to add synthesized debug info to the MIR.
virtual bool addInstSelector()
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
CodeGenOptLevel getOptLevel() const
virtual bool addPreISel()
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
void setOpt(bool &Opt, bool Val)
virtual void addBlockPlacement()
Add standard basic block placement passes.
virtual FunctionPass * createRegAllocPass(bool Optimized)
addMachinePasses helper to create the target-selected or overriden regalloc pass.
virtual void addPostBBSections()
This pass may be implemented by targets that want to run passes immediately after basic block section...
virtual void addOptimizedRegAlloc()
addOptimizedRegAlloc - Add passes related to register allocation.
virtual bool addRegAssignAndRewriteFast()
Add core register allocator passes which do the actual register assignment and rewriting.
virtual void addPreEmitPass()
This pass may be implemented by targets that want to run passes immediately before machine code is em...
bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
bool getOptimizeRegAlloc() const
Return true if the optimized regalloc pipeline is enabled.
bool isCustomizedRegAlloc()
Return true if register allocator is specified by -regalloc=override.
virtual void addPreRegBankSelect()
This method may be implemented by targets that want to run passes immediately before the register ban...
virtual bool reportDiagnosticWhenGlobalISelFallback() const
Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path.
virtual bool addPreRewrite()
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is...
virtual bool addRegBankSelect()
This method should install a register bank selector pass, which assigns register banks to virtual reg...
void setRequiresCodeGenSCCOrder(bool Enable=true)
virtual void addMachineLateOptimization()
Add passes that optimize machine instructions after register allocation.
virtual void addMachinePasses()
Add the complete, standard set of LLVM CodeGen passes.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
virtual void addPreGlobalInstructionSelect()
This method may be implemented by targets that want to run passes immediately before the (global) ins...
virtual void addFastRegAlloc()
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
virtual bool addLegalizeMachineIR()
This method should install a legalize pass, which converts the instruction sequence into one that can...
virtual void addMachineSSAOptimization()
addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form.
void substitutePass(AnalysisID StandardID, IdentifyingPassPtr TargetID)
Allow the target to override a specific pass without overriding the pass pipeline.
virtual bool addRegAssignAndRewriteOptimized()
virtual bool addGlobalInstructionSelect()
This method should install a (global) instruction selector pass, which converts possibly generic inst...
virtual void addPreRegAlloc()
This method may be implemented by targets that want to run passes immediately before register allocat...
static std::string getLimitedCodeGenPipelineReason()
If hasLimitedCodeGenPipeline is true, this method returns a string with the name of the options that ...
AnalysisID addPass(AnalysisID PassID)
Utilities for targets to add passes to the pass manager.
void addPassesToHandleExceptions()
Add passes to lower exception handling for the code generator.
void addStripDebugPass()
Add a pass to remove debug info from the MIR.
bool isPassSubstitutedOrOverridden(AnalysisID ID) const
Return true if the pass has been substituted by the target or overridden on the command line.
bool addCoreISelPasses()
Add the actual instruction selection passes.
virtual void addISelPrepare()
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
static bool willCompleteCodeGenPipeline()
Returns true if none of the -stop-before and -stop-after options is set.
void addMachinePrePasses(bool AllowDebugify=true)
Add standard passes before a pass that's about to be added.
virtual bool addGCPasses()
addGCPasses - Add late codegen passes that analyze code for garbage collection.
virtual bool addIRTranslator()
This method should install an IR translator pass, which converts from LLVM code to machine instructio...
void addVerifyPass(const std::string &Banner)
Add a pass to perform basic verification of the machine function if verification is enabled.
virtual FunctionPass * createTargetRegisterAllocator(bool Optimized)
createTargetRegisterAllocator - Create the register allocator pass for this target at the current opt...
virtual bool addPostFastRegAllocRewrite()
addPostFastRegAllocRewrite - Add passes to the optimized register allocation pipeline after fast regi...
IdentifyingPassPtr getPassSubstitution(AnalysisID StandardID) const
Return the pass substituted for StandardID by the target.
bool addISelPasses()
High level function that adds all passes necessary to go from llvm IR representation to the MI repres...
virtual void addPostRewrite()
Add passes to be run immediately after virtual registers are rewritten to physical registers.
bool isOSBinFormatMachO() const
Tests whether the environment is MachO.
Definition: Triple.h:743
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
static raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
Definition: WithColor.cpp:85
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ ValueOptional
Definition: CommandLine.h:130
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:711
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FunctionPass * createFastRegisterAllocator()
FastRegisterAllocation Pass - This pass register allocates as fast as possible.
char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
char & GCMachineCodeAnalysisID
GCMachineCodeAnalysis - Target-independent pass to mark safe points in machine code.
char & FEntryInserterID
This pass inserts FEntry calls.
FunctionPass * createUnreachableBlockEliminationPass()
createUnreachableBlockEliminationPass - The LLVM code generator does not work well with unreachable b...
FunctionPass * createSjLjEHPreparePass(const TargetMachine *TM)
createSjLjEHPreparePass - This pass adapts exception handling code to use the GCC-style builtin setjm...
char & GCLoweringID
GCLowering Pass - Used by gc.root to perform its default lowering operations.
void registerCodeGenCallback(PassInstrumentationCallbacks &PIC, TargetMachine &)
char & InitUndefID
Definition: InitUndef.cpp:98
char & RegisterCoalescerID
RegisterCoalescer - This pass merges live ranges to eliminate copies.
ModulePass * createGlobalMergeFuncPass()
This pass performs merging similar functions globally.
FunctionPass * createGreedyRegisterAllocator()
Greedy register allocation pass - This pass implements a global register allocator for optimized buil...
MachineFunctionPass * createBasicBlockPathCloningPass()
FunctionPass * createConstantHoistingPass()
FunctionPass * createSafeStackPass()
This pass splits the stack into a safe stack and an unsafe stack to protect against stack-based overf...
Definition: SafeStack.cpp:974
char & MachineSinkingID
MachineSinking - This pass performs sinking on machine instructions.
@ SjLj
setjmp/longjmp based exceptions
@ ZOS
z/OS MVS Exception Handling.
@ None
No exception support.
@ AIX
AIX Exception Handling.
@ DwarfCFI
DWARF-like instruction based exceptions.
@ WinEH
Windows Exception Handling.
@ Wasm
WebAssembly Exception Handling.
FunctionPass * createSelectOptimizePass()
This pass converts conditional moves to conditional jumps when profitable.
FunctionPass * createWasmEHPass()
createWasmEHPass - This pass adapts exception handling code to use WebAssembly's exception handling s...
char & FixupStatepointCallerSavedID
The pass fixups statepoint machine instruction to replace usage of caller saved registers with stack ...
MachineFunctionPass * createBasicBlockSectionsPass()
createBasicBlockSections Pass - This pass assigns sections to machine basic blocks and is enabled wit...
FunctionPass * createPostInlineEntryExitInstrumenterPass()
MachineFunctionPass * createPrologEpilogInserterPass()
MachineFunctionPass * createGCEmptyBasicBlocksPass()
createGCEmptyBasicblocksPass - Empty basic blocks (basic blocks without real code) appear as the resu...
FunctionPass * createCallBrPass()
ModulePass * createStripDebugMachineModulePass(bool OnlyDebugified)
Creates MIR Strip Debug pass.
char & TailDuplicateLegacyID
TailDuplicate - Duplicate blocks with unconditional branches into tails of their predecessors.
char & ExpandPostRAPseudosID
ExpandPostRAPseudos - This pass expands pseudo instructions after register allocation.
char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
FunctionPass * createScalarizeMaskedMemIntrinLegacyPass()
ModulePass * createLowerEmuTLSPass()
LowerEmuTLS - This pass generates __emutls_[vt].xyz variables for all TLS variables for the emulated ...
char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
char & RemoveLoadsIntoFakeUsesID
RemoveLoadsIntoFakeUses pass.
FunctionPass * createStackProtectorPass()
createStackProtectorPass - This pass adds stack protectors to functions.
Pass * createLoopTermFoldPass()
char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
char & PeepholeOptimizerLegacyID
PeepholeOptimizer - This pass performs peephole optimizations - like extension and comparison elimina...
char & LiveDebugValuesID
LiveDebugValues pass.
char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
FunctionPass * createExpandLargeFpConvertPass()
char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
ImmutablePass * createBasicBlockSectionsProfileReaderWrapperPass(const MemoryBuffer *Buf)
char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
cl::opt< bool > EnableFSDiscriminator
char & ShadowStackGCLoweringID
ShadowStackGCLowering - Implements the custom lowering mechanism used by the shadow stack GC.
MachineFunctionPass * createStackFrameLayoutAnalysisPass()
StackFramePrinter pass - This pass prints out the machine function's stack frame to the given stream ...
FunctionPass * createMIRAddFSDiscriminatorsPass(sampleprof::FSDiscriminatorPass P)
Add Flow Sensitive Discriminators.
char & MachineSanitizerBinaryMetadataID
char & ImplicitNullChecksID
ImplicitNullChecks - This pass folds null pointer checks into nearby memory operations.
ModulePass * createPreISelIntrinsicLoweringPass()
This pass lowers the @llvm.load.relative and @llvm.objc.
void initializeAAResultsWrapperPassPass(PassRegistry &)
char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
Definition: ShrinkWrap.cpp:287
char & MachineLateInstrsCleanupID
MachineLateInstrsCleanup - This pass removes redundant identical instructions after register allocati...
ImmutablePass * createScopedNoAliasAAWrapperPass()
FunctionPass * createExpandMemCmpLegacyPass()
ModulePass * createLowerGlobalDtorsLegacyPass()
FunctionPass * createLowerInvokePass()
Definition: LowerInvoke.cpp:85
FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
char & XRayInstrumentationID
This pass inserts the XRay instrumentation sleds if they are supported by the target platform.
char & OptimizePHIsLegacyID
OptimizePHIs - This pass optimizes machine instruction PHIs to take advantage of opportunities create...
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:167
char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
char & FuncletLayoutID
This pass lays out funclets contiguously.
FunctionPass * createCodeGenPrepareLegacyPass()
createCodeGenPrepareLegacyPass - Transform the code to expose more pattern matching during instructio...
char & RemoveRedundantDebugValuesID
RemoveRedundantDebugValues pass.
FunctionPass * createBasicAAWrapperPass()
char & DetectDeadLanesID
This pass adds dead/undef flags after analyzing subregister lanes.
char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
FunctionPass * createDwarfEHPass(CodeGenOptLevel OptLevel)
createDwarfEHPass - This pass mulches exception handling code into a form adapted to code generation.
FunctionPass * createRegAllocScoringPass()
When learning an eviction policy, extract score(reward) information, otherwise this does nothing.
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
ModulePass * createMachineOutlinerPass(bool RunOnAllFunctions=true)
This pass performs outlining on machine instructions directly before printing assembly.
const void * AnalysisID
Definition: Pass.h:50
char & StackSlotColoringID
StackSlotColoring - This pass performs stack slot coloring.
FunctionPass * createExpandLargeDivRemPass()
Pass * createMergeICmpsLegacyPass()
Definition: MergeICmps.cpp:913
char & ProcessImplicitDefsID
ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
ModulePass * createCheckDebugMachineModulePass()
Creates MIR Check Debug pass.
ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
ImmutablePass * createTypeBasedAAWrapperPass()
FunctionPass * createMIRProfileLoaderPass(std::string File, std::string RemappingFile, sampleprof::FSDiscriminatorPass P, IntrusiveRefCntPtr< vfs::FileSystem > FS)
Read Flow Sensitive Profile.
FunctionPass * createCFIFixup()
Creates CFI Fixup pass.
FunctionPass * createVerifierPass(bool FatalErrors=true)
Definition: Verifier.cpp:7719
void initializeBasicAAWrapperPassPass(PassRegistry &)
MachineFunctionPass * createMachineFunctionPrinterPass(raw_ostream &OS, const std::string &Banner="")
MachineFunctionPrinter pass - This pass prints out the machine function to the given stream as a debu...
char & MachineCSELegacyID
MachineCSE - This pass performs global CSE on machine instructions.
Definition: MachineCSE.cpp:164
Pass * createLoopStrengthReducePass()
char & LiveVariablesID
LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...
char & EarlyTailDuplicateLegacyID
Duplicate blocks with unconditional branches into tails of their predecessors.
FunctionPass * createExpandReductionsPass()
This pass expands the reduction intrinsics into sequences of shuffles.
MachineFunctionPass * createMachineFunctionSplitterPass()
createMachineFunctionSplitterPass - This pass splits machine functions using profile information.
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
Definition: Threading.h:87
MachineFunctionPass * createResetMachineFunctionPass(bool EmitFallbackDiag, bool AbortOnFailedISel)
This pass resets a MachineFunction when it has the FailedISel property as if it was just created.
char & StackColoringLegacyID
StackSlotColoring - This pass performs stack coloring and merging.
char & VirtRegRewriterID
VirtRegRewriter pass.
Definition: VirtRegMap.cpp:250
FunctionPass * createReplaceWithVeclibLegacyPass()
char & FinalizeISelID
This pass expands pseudo-instructions, reserves registers and adjusts machine frame information.
FunctionPass * createRegUsageInfoPropPass()
Return a MachineFunction pass that identifies call sites and propagates register usage information of...
FunctionPass * createPartiallyInlineLibCallsPass()
char & UnreachableMachineBlockElimID
UnreachableMachineBlockElimination - This pass removes unreachable machine basic blocks.
char & MachineBlockPlacementID
MachineBlockPlacement - This pass places basic blocks based on branch probabilities.
char & TwoAddressInstructionPassID
TwoAddressInstruction - This pass reduces two-address instructions to use two operands.
Pass * createCanonicalizeFreezeInLoopsPass()
char & LocalStackSlotAllocationID
LocalStackSlotAllocation - This pass assigns local frame indices to stack slots relative to one anoth...
char & BranchFolderPassID
BranchFolding - This pass performs machine code CFG based optimizations to delete branches to branche...
char & PHIEliminationID
PHIElimination - This pass eliminates machine instruction PHI nodes by inserting copy instructions.
Pass * createObjCARCContractPass()
ModulePass * createDebugifyMachineModulePass()
Creates MIR Debugify pass.
FunctionPass * createPrintFunctionPass(raw_ostream &OS, const std::string &Banner="")
Create and return a pass that prints functions to the specified raw_ostream as they are processed.
char & RenameIndependentSubregsID
This pass detects subregister lanes in a virtual register that are used independently of other lanes ...
char & MachineLICMID
This pass performs loop invariant code motion on machine instructions.
char & MachineBlockPlacementStatsID
MachineBlockPlacementStats - This pass collects statistics about the basic block placement using bran...
char & LiveIntervalsID
LiveIntervals - This analysis keeps track of the live ranges of virtual and physical registers.
char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
void initializeCodeGen(PassRegistry &)
Initialize all passes linked into the CodeGen library.
Definition: CodeGen.cpp:20
FunctionPass * createMachineVerifierPass(const std::string &Banner)
createMachineVerifierPass - This pass verifies cenerated machine code instructions for correctness.
FunctionPass * createWinEHPass(bool DemoteCatchSwitchPHIOnly=false)
createWinEHPass - Prepares personality functions used by MSVC on Windows, in addition to the Itanium ...
CGPassBuilderOption getCGPassBuilderOption()
InsertedPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID)
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
void registerShouldRunOptionalPassCallback(CallableT C)
A utility class that uses RAII to save and restore the value of a variable.
The llvm::once_flag structure.
Definition: Threading.h:68