LLVM 24.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"
29#include "llvm/CodeGen/Passes.h"
34#include "llvm/IR/Verifier.h"
36#include "llvm/MC/MCAsmInfo.h"
38#include "llvm/Pass.h"
42#include "llvm/Support/Debug.h"
54#include <cassert>
55#include <optional>
56#include <string>
57
58using namespace llvm;
59
60static cl::opt<bool>
61 EnableIPRA("enable-ipra", cl::init(false), cl::Hidden,
62 cl::desc("Enable interprocedural register allocation "
63 "to reduce load/store at procedure calls."));
65 cl::desc("Disable Post Regalloc Scheduler"));
66static cl::opt<bool> DisableBranchFold("disable-branch-fold", cl::Hidden,
67 cl::desc("Disable branch folding"));
68static cl::opt<bool> DisableTailDuplicate("disable-tail-duplicate", cl::Hidden,
69 cl::desc("Disable tail duplication"));
70static cl::opt<bool> DisableEarlyTailDup("disable-early-taildup", cl::Hidden,
71 cl::desc("Disable pre-register allocation tail duplication"));
72static cl::opt<bool> DisableBlockPlacement("disable-block-placement",
73 cl::Hidden, cl::desc("Disable probability-driven block placement"));
74static cl::opt<bool> EnableBlockPlacementStats("enable-block-placement-stats",
75 cl::Hidden, cl::desc("Collect probability-driven block placement stats"));
76static cl::opt<bool> DisableSSC("disable-ssc", cl::Hidden,
77 cl::desc("Disable Stack Slot Coloring"));
78static cl::opt<bool> DisableMachineDCE("disable-machine-dce", cl::Hidden,
79 cl::desc("Disable Machine Dead Code Elimination"));
81 cl::desc("Disable Early If-conversion"));
82static cl::opt<bool> DisableMachineLICM("disable-machine-licm", cl::Hidden,
83 cl::desc("Disable Machine LICM"));
84static cl::opt<bool> DisableMachineCSE("disable-machine-cse", cl::Hidden,
85 cl::desc("Disable Machine Common Subexpression Elimination"));
86static cl::opt<bool> DisablePostRAMachineLICM("disable-postra-machine-licm",
88 cl::desc("Disable Machine LICM"));
89static cl::opt<bool> DisableMachineSink("disable-machine-sink", cl::Hidden,
90 cl::desc("Disable Machine Sinking"));
91static cl::opt<bool> DisablePostRAMachineSink("disable-postra-machine-sink",
93 cl::desc("Disable PostRA Machine Sinking"));
94static cl::opt<bool> DisableLSR("disable-lsr", cl::Hidden,
95 cl::desc("Disable Loop Strength Reduction Pass"));
96static cl::opt<bool> DisableConstantHoisting("disable-constant-hoisting",
97 cl::Hidden, cl::desc("Disable ConstantHoisting"));
98static cl::opt<bool> DisableCGP("disable-cgp", cl::Hidden,
99 cl::desc("Disable Codegen Prepare"));
100
101static cl::opt<bool>
102 TriggerCrash("codegen-pipeline-trigger-crash", cl::init(false), cl::Hidden,
103 cl::desc("Trigger crash in codegen pipeline"));
104
105namespace {
106class TriggerCrashFunctionLegacyPass : public FunctionPass {
107public:
108 static char ID;
109 TriggerCrashFunctionLegacyPass() : FunctionPass(ID) {}
110 bool runOnFunction(Function &F) override {
111 abort();
112 return false;
113 }
114 StringRef getPassName() const override { return "TriggerCrashFunctionPass"; }
115};
116} // namespace
117
118char TriggerCrashFunctionLegacyPass::ID = 0;
119
120static cl::opt<bool> DisableCopyProp("disable-copyprop", cl::Hidden,
121 cl::desc("Disable Copy Propagation pass"));
122static cl::opt<bool> DisablePartialLibcallInlining("disable-partial-libcall-inlining",
123 cl::Hidden, cl::desc("Disable Partial Libcall Inlining"));
125 "disable-atexit-based-global-dtor-lowering", cl::Hidden,
126 cl::desc("For MachO, disable atexit()-based global destructor lowering"));
128 "enable-implicit-null-checks",
129 cl::desc("Fold null checks into faulting memory operations"),
130 cl::init(false), cl::Hidden);
131static cl::opt<bool>
132 PrintISelInput("print-isel-input", cl::Hidden,
133 cl::desc("Print LLVM IR input to isel pass"));
135 PrintRegUsage("print-regusage", cl::Hidden,
136 cl::desc("Print register usage details collected for IPRA"));
138 VerifyMachineCode("verify-machineinstrs", cl::Hidden,
139 cl::desc("Verify generated machine code"));
141 DebugifyAndStripAll("debugify-and-strip-all-safe", cl::Hidden,
142 cl::desc("Debugify MIR before and Strip debug after "
143 "each pass except those known to be unsafe "
144 "when debug info is present"));
146 "debugify-check-and-strip-all-safe", cl::Hidden,
147 cl::desc(
148 "Debugify MIR before, by checking and stripping the debug info after, "
149 "each pass except those known to be unsafe when debug info is "
150 "present"));
151// Enable or disable the MachineOutliner.
153 "enable-machine-outliner", cl::desc("Enable the machine outliner"),
157 "Run on all functions guaranteed to be beneficial"),
158 clEnumValN(RunOutliner::OptimisticPGO, "optimistic-pgo",
159 "Outline cold code only. If a code block does not have "
160 "profile data, optimistically assume it is cold."),
161 clEnumValN(RunOutliner::ConservativePGO, "conservative-pgo",
162 "Outline cold code only. If a code block does not have "
163 "profile, data, conservatively assume it is hot."),
164 clEnumValN(RunOutliner::NeverOutline, "never", "Disable all outlining"),
165 // Sentinel value for unspecified option.
168 "enable-global-merge-func", cl::Hidden,
169 cl::desc("Enable global merge functions that are based on hash function"));
170// Disable the pass to fix unwind information. Whether the pass is included in
171// the pipeline is controlled via the target options, this option serves as
172// manual override.
173static cl::opt<bool> DisableCFIFixup("disable-cfi-fixup", cl::Hidden,
174 cl::desc("Disable the CFI fixup pass"));
175// Enable or disable FastISel. Both options are needed, because
176// FastISel is enabled by default with -fast, and we wish to be
177// able to enable or disable fast-isel independently from -O0.
180 cl::desc("Enable the \"fast\" instruction selector"));
181
183 "global-isel", cl::Hidden,
184 cl::desc("Enable the \"global\" instruction selector"));
185
186// FIXME: remove this after switching to NPM or GlobalISel, whichever gets there
187// first...
188static cl::opt<bool>
189 PrintAfterISel("print-after-isel", cl::init(false), cl::Hidden,
190 cl::desc("Print machine instrs after ISel"));
191
193 "global-isel-abort", cl::Hidden,
194 cl::desc("Enable abort calls when \"global\" instruction selection "
195 "fails to lower/select an instruction"),
197 clEnumValN(GlobalISelAbortMode::Disable, "0", "Disable the abort"),
198 clEnumValN(GlobalISelAbortMode::Enable, "1", "Enable the abort"),
200 "Disable the abort but emit a diagnostic on failure")));
201
202// Disable MIRProfileLoader before RegAlloc. This is for for debugging and
203// tuning purpose.
205 "disable-ra-fsprofile-loader", cl::init(false), cl::Hidden,
206 cl::desc("Disable MIRProfileLoader before RegAlloc"));
207// Disable MIRProfileLoader before BloackPlacement. This is for for debugging
208// and tuning purpose.
210 "disable-layout-fsprofile-loader", cl::init(false), cl::Hidden,
211 cl::desc("Disable MIRProfileLoader before BlockPlacement"));
212// Specify FSProfile file name.
214 FSProfileFile("fs-profile-file", cl::init(""), cl::value_desc("filename"),
215 cl::desc("Flow Sensitive profile file name."), cl::Hidden);
216// Specify Remapping file for FSProfile.
218 "fs-remapping-file", cl::init(""), cl::value_desc("filename"),
219 cl::desc("Flow Sensitive profile remapping file name."), cl::Hidden);
220
221// Temporary option to allow experimenting with MachineScheduler as a post-RA
222// scheduler. Targets can "properly" enable this with
223// substitutePass(&PostRASchedulerID, &PostMachineSchedulerID).
224// Targets can return true in targetSchedulesPostRAScheduling() and
225// insert a PostRA scheduling pass wherever it wants.
227 "misched-postra", cl::Hidden,
228 cl::desc(
229 "Run MachineScheduler post regalloc (independent of preRA sched)"));
230
232 "disable-replace-with-vec-lib", cl::Hidden,
233 cl::desc("Disable replace with vector math call pass"));
234
235/// Option names for limiting the codegen pipeline.
236/// Those are used in error reporting and we didn't want
237/// to duplicate their names all over the place.
238static const char StartAfterOptName[] = "start-after";
239static const char StartBeforeOptName[] = "start-before";
240static const char StopAfterOptName[] = "stop-after";
241static const char StopBeforeOptName[] = "stop-before";
242
245 cl::desc("Resume compilation after a specific pass"),
246 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
247
250 cl::desc("Resume compilation before a specific pass"),
251 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
252
255 cl::desc("Stop compilation after a specific pass"),
256 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
257
260 cl::desc("Stop compilation before a specific pass"),
261 cl::value_desc("pass-name"), cl::init(""), cl::Hidden);
262
263/// Enable the machine function splitter pass.
265 "enable-split-machine-functions", cl::Hidden,
266 cl::desc("Split out cold blocks from machine functions based on profile "
267 "information."));
268
269/// Disable the expand reductions pass for testing.
271 "disable-expand-reductions", cl::init(false), cl::Hidden,
272 cl::desc("Disable the expand reduction intrinsics pass from running"));
273
274/// Disable the select optimization pass.
276 "disable-select-optimize", cl::init(true), cl::Hidden,
277 cl::desc("Disable the select-optimization pass from running"));
278
279/// Enable garbage-collecting empty basic blocks.
281 "enable-gc-empty-basic-blocks", cl::init(false), cl::Hidden,
282 cl::desc("Enable garbage-collecting empty basic blocks"));
283
284static cl::opt<bool>
285 SplitStaticData("split-static-data", cl::Hidden, cl::init(false),
286 cl::desc("Split static data sections into hot and cold "
287 "sections using profile information"));
288
289/// Enable matching and inference when using propeller.
291 "basic-block-section-match-infer",
292 cl::desc(
293 "Enable matching and inference when generating basic block sections"),
294 cl::init(false));
295
296/// Allow standard passes to be disabled by command line options. This supports
297/// simple binary flags that either suppress the pass or do nothing.
298/// i.e. -disable-mypass=false has no effect.
299/// These should be converted to boolOrDefault in order to use applyOverride.
301 bool Override) {
302 if (Override)
303 return IdentifyingPassPtr();
304 return PassID;
305}
306
307/// Allow standard passes to be disabled by the command line, regardless of who
308/// is adding the pass.
309///
310/// StandardID is the pass identified in the standard pass pipeline and provided
311/// to addPass(). It may be a target-specific ID in the case that the target
312/// directly adds its own pass, but in that case we harmlessly fall through.
313///
314/// TargetID is the pass that the target has configured to override StandardID.
315///
316/// StandardID may be a pseudo ID. In that case TargetID is the name of the real
317/// pass to run. This allows multiple options to control a single pass depending
318/// on where in the pipeline that pass is added.
320 IdentifyingPassPtr TargetID) {
321 if (StandardID == &PostRASchedulerID)
322 return applyDisable(TargetID, DisablePostRASched);
323
324 if (StandardID == &BranchFolderPassID)
325 return applyDisable(TargetID, DisableBranchFold);
326
327 if (StandardID == &TailDuplicateLegacyID)
328 return applyDisable(TargetID, DisableTailDuplicate);
329
330 if (StandardID == &EarlyTailDuplicateLegacyID)
331 return applyDisable(TargetID, DisableEarlyTailDup);
332
333 if (StandardID == &MachineBlockPlacementID)
334 return applyDisable(TargetID, DisableBlockPlacement);
335
336 if (StandardID == &StackSlotColoringID)
337 return applyDisable(TargetID, DisableSSC);
338
339 if (StandardID == &DeadMachineInstructionElimID)
340 return applyDisable(TargetID, DisableMachineDCE);
341
342 if (StandardID == &EarlyIfConverterLegacyID)
343 return applyDisable(TargetID, DisableEarlyIfConversion);
344
345 if (StandardID == &EarlyMachineLICMID)
346 return applyDisable(TargetID, DisableMachineLICM);
347
348 if (StandardID == &MachineCSELegacyID)
349 return applyDisable(TargetID, DisableMachineCSE);
350
351 if (StandardID == &MachineLICMID)
352 return applyDisable(TargetID, DisablePostRAMachineLICM);
353
354 if (StandardID == &MachineSinkingLegacyID)
355 return applyDisable(TargetID, DisableMachineSink);
356
357 if (StandardID == &PostRAMachineSinkingID)
358 return applyDisable(TargetID, DisablePostRAMachineSink);
359
360 if (StandardID == &MachineCopyPropagationID)
361 return applyDisable(TargetID, DisableCopyProp);
362
363 return TargetID;
364}
365
366// Find the FSProfile file name. The internal option takes the precedence
367// before getting from TargetMachine.
368static std::string getFSProfileFile(const TargetMachine *TM) {
369 if (!FSProfileFile.empty())
370 return FSProfileFile.getValue();
371 const std::optional<PGOOptions> &PGOOpt = TM->getPGOOption();
372 if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse)
373 return std::string();
374 return PGOOpt->ProfileFile;
375}
376
377// Find the Profile remapping file name. The internal option takes the
378// precedence before getting from TargetMachine.
379static std::string getFSRemappingFile(const TargetMachine *TM) {
380 if (!FSRemappingFile.empty())
381 return FSRemappingFile.getValue();
382 const std::optional<PGOOptions> &PGOOpt = TM->getPGOOption();
383 if (PGOOpt == std::nullopt || PGOOpt->Action != PGOOptions::SampleUse)
384 return std::string();
385 return PGOOpt->ProfileRemappingFile;
386}
387
388//===---------------------------------------------------------------------===//
389/// TargetPassConfig
390//===---------------------------------------------------------------------===//
391
392INITIALIZE_PASS(TargetPassConfig, "targetpassconfig",
393 "Target Pass Configuration", false, false)
394char TargetPassConfig::ID = 0;
395
396namespace {
397
401
404
406 assert(InsertedPassID.isValid() && "Illegal Pass ID!");
407 if (InsertedPassID.isInstance())
408 return InsertedPassID.getInstance();
409 Pass *NP = Pass::createPass(InsertedPassID.getID());
410 assert(NP && "Pass ID not registered");
411 return NP;
412 }
413};
414
415} // end anonymous namespace
416
417namespace llvm {
418
420public:
421 // List of passes explicitly substituted by this target. Normally this is
422 // empty, but it is a convenient way to suppress or replace specific passes
423 // that are part of a standard pass pipeline without overridding the entire
424 // pipeline. This mechanism allows target options to inherit a standard pass's
425 // user interface. For example, a target may disable a standard pass by
426 // default by substituting a pass ID of zero, and the user may still enable
427 // that standard pass with an explicit command line option.
429
430 /// Store the pairs of <AnalysisID, AnalysisID> of which the second pass
431 /// is inserted after each instance of the first one.
433};
434
435} // end namespace llvm
436
437// Out of line virtual method.
441
443 if (PassName.empty())
444 return nullptr;
445
447 const PassInfo *PI = PR.getPassInfo(PassName);
448 if (!PI)
450 Twine("\" pass is not registered."));
451 return PI;
452}
453
455 const PassInfo *PI = getPassInfo(PassName);
456 return PI ? PI->getTypeInfo() : nullptr;
457}
458
459static std::pair<StringRef, unsigned>
461 StringRef Name, InstanceNumStr;
462 std::tie(Name, InstanceNumStr) = PassName.split(',');
463
464 unsigned InstanceNum = 0;
465 if (!InstanceNumStr.empty() && InstanceNumStr.getAsInteger(10, InstanceNum))
466 reportFatalUsageError("invalid pass instance specifier " + PassName);
467
468 return std::make_pair(Name, InstanceNum);
469}
470
471void TargetPassConfig::setStartStopPasses() {
472 StringRef StartBeforeName;
473 std::tie(StartBeforeName, StartBeforeInstanceNum) =
475
476 StringRef StartAfterName;
477 std::tie(StartAfterName, StartAfterInstanceNum) =
479
480 StringRef StopBeforeName;
481 std::tie(StopBeforeName, StopBeforeInstanceNum)
483
484 StringRef StopAfterName;
485 std::tie(StopAfterName, StopAfterInstanceNum)
487
488 StartBefore = getPassIDFromName(StartBeforeName);
489 StartAfter = getPassIDFromName(StartAfterName);
490 StopBefore = getPassIDFromName(StopBeforeName);
491 StopAfter = getPassIDFromName(StopAfterName);
492 if (StartBefore && StartAfter)
493 reportFatalUsageError(Twine(StartBeforeOptName) + Twine(" and ") +
494 Twine(StartAfterOptName) + Twine(" specified!"));
495 if (StopBefore && StopAfter)
496 reportFatalUsageError(Twine(StopBeforeOptName) + Twine(" and ") +
497 Twine(StopAfterOptName) + Twine(" specified!"));
498 Started = (StartAfter == nullptr) && (StartBefore == nullptr);
499}
500
541
569
572 auto [StartBefore, StartBeforeInstanceNum] =
574 auto [StartAfter, StartAfterInstanceNum] =
576 auto [StopBefore, StopBeforeInstanceNum] =
578 auto [StopAfter, StopAfterInstanceNum] =
580
581 if (!StartBefore.empty() && !StartAfter.empty())
583 Twine(StartBeforeOptName) + " and " + StartAfterOptName + " specified!",
584 std::make_error_code(std::errc::invalid_argument));
585 if (!StopBefore.empty() && !StopAfter.empty())
587 Twine(StopBeforeOptName) + " and " + StopAfterOptName + " specified!",
588 std::make_error_code(std::errc::invalid_argument));
589
590 StartStopInfo Result;
591 Result.StartPass = StartBefore.empty() ? StartAfter : StartBefore;
592 Result.StopPass = StopBefore.empty() ? StopAfter : StopBefore;
593 Result.StartInstanceNum =
594 StartBefore.empty() ? StartAfterInstanceNum : StartBeforeInstanceNum;
595 Result.StopInstanceNum =
596 StopBefore.empty() ? StopAfterInstanceNum : StopBeforeInstanceNum;
597 Result.StartAfter = !StartAfter.empty();
598 Result.StopAfter = !StopAfter.empty();
599 Result.StartInstanceNum += Result.StartInstanceNum == 0;
600 Result.StopInstanceNum += Result.StopInstanceNum == 0;
601 return Result;
602}
603
604// Out of line constructor provides default values for pass options and
605// registers all common codegen passes.
607 : ImmutablePass(ID), PM(&PM), TM(&TM) {
608 Impl = new PassConfigImpl();
609
611 // Register all target independent codegen passes to activate their PassIDs,
612 // including this pass itself.
614
616
617 // Also register alias analysis passes required by codegen passes.
620
621 if (EnableIPRA.getNumOccurrences()) {
622 TM.Options.EnableIPRA = EnableIPRA;
623 } else {
624 // If not explicitly specified, use target default.
625 TM.Options.EnableIPRA |= TM.useIPRA();
626 }
627
628 if (TM.Options.EnableIPRA)
630
631 if (EnableGlobalISelAbort.getNumOccurrences())
632 TM.Options.GlobalISelAbort = EnableGlobalISelAbort;
633
634 setStartStopPasses();
635}
636
638 return TM->getOptLevel();
639}
640
641/// Insert InsertedPassID pass after TargetPassID.
643 IdentifyingPassPtr InsertedPassID) {
644 assert(((!InsertedPassID.isInstance() &&
645 TargetPassID != InsertedPassID.getID()) ||
646 (InsertedPassID.isInstance() &&
647 TargetPassID != InsertedPassID.getInstance()->getPassID())) &&
648 "Insert a pass after itself!");
649 Impl->InsertedPasses.emplace_back(TargetPassID, InsertedPassID);
650}
651
652/// createPassConfig - Create a pass configuration object to be used by
653/// addPassToEmitX methods for generating a pipeline of CodeGen passes.
654///
655/// Targets may override this to extend TargetPassConfig.
660
662 : ImmutablePass(ID) {
663 reportFatalUsageError("trying to construct TargetPassConfig without a target "
664 "machine. Scheduling a CodeGen pass without a target "
665 "triple set?");
666}
667
671
676
679 return std::string();
680 std::string Res;
681 static cl::opt<std::string> *PassNames[] = {&StartAfterOpt, &StartBeforeOpt,
683 static const char *OptNames[] = {StartAfterOptName, StartBeforeOptName,
685 bool IsFirst = true;
686 for (int Idx = 0; Idx < 4; ++Idx)
687 if (!PassNames[Idx]->empty()) {
688 if (!IsFirst)
689 Res += " and ";
690 IsFirst = false;
691 Res += OptNames[Idx];
692 }
693 return Res;
694}
695
696// Helper to verify the analysis is really immutable.
697void TargetPassConfig::setOpt(bool &Opt, bool Val) {
698 assert(!Initialized && "PassConfig is immutable");
699 Opt = Val;
700}
701
703 IdentifyingPassPtr TargetID) {
704 Impl->TargetPasses[StandardID] = TargetID;
705}
706
709 I = Impl->TargetPasses.find(ID);
710 if (I == Impl->TargetPasses.end())
711 return ID;
712 return I->second;
713}
714
717 IdentifyingPassPtr FinalPtr = overridePass(ID, TargetID);
718 return !FinalPtr.isValid() || FinalPtr.isInstance() ||
719 FinalPtr.getID() != ID;
720}
721
722/// Add a pass to the PassManager if that pass is supposed to be run. If the
723/// Started/Stopped flags indicate either that the compilation should start at
724/// a later pass or that it should stop after an earlier pass, then do not add
725/// the pass. Finally, compare the current pass against the StartAfter
726/// and StopAfter options and change the Started/Stopped flags accordingly.
728 assert(!Initialized && "PassConfig is immutable");
729
730 // Cache the Pass ID here in case the pass manager finds this pass is
731 // redundant with ones already scheduled / available, and deletes it.
732 // Fundamentally, once we add the pass to the manager, we no longer own it
733 // and shouldn't reference it.
734 AnalysisID PassID = P->getPassID();
735
736 if (StartBefore == PassID && StartBeforeCount++ == StartBeforeInstanceNum)
737 Started = true;
738 if (StopBefore == PassID && StopBeforeCount++ == StopBeforeInstanceNum)
739 Stopped = true;
740 if (Started && !Stopped) {
741 if (AddingMachinePasses) {
742 // Construct banner message before PM->add() as that may delete the pass.
743 std::string Banner =
744 std::string("After ") + std::string(P->getPassName());
746 PM->add(P);
747 addMachinePostPasses(Banner);
748 } else {
749 PM->add(P);
750 }
751
752 // Add the passes after the pass P if there is any.
753 for (const auto &IP : Impl->InsertedPasses)
754 if (IP.TargetPassID == PassID)
755 addPass(IP.getInsertedPass());
756 } else {
757 delete P;
758 }
759
760 if (StopAfter == PassID && StopAfterCount++ == StopAfterInstanceNum)
761 Stopped = true;
762
763 if (StartAfter == PassID && StartAfterCount++ == StartAfterInstanceNum)
764 Started = true;
765 if (Stopped && !Started)
766 reportFatalUsageError("Cannot stop compilation after pass that is not run");
767}
768
769/// Add a CodeGen pass at this point in the pipeline after checking for target
770/// and command line overrides.
771///
772/// addPass cannot return a pointer to the pass instance because is internal the
773/// PassManager and the instance we create here may already be freed.
775 IdentifyingPassPtr TargetID = getPassSubstitution(PassID);
776 IdentifyingPassPtr FinalPtr = overridePass(PassID, TargetID);
777 if (!FinalPtr.isValid())
778 return nullptr;
779
780 Pass *P;
781 if (FinalPtr.isInstance())
782 P = FinalPtr.getInstance();
783 else {
784 P = Pass::createPass(FinalPtr.getID());
785 if (!P)
786 llvm_unreachable("Pass ID not registered");
787 }
788 AnalysisID FinalID = P->getPassID();
789 addPass(P); // Ends the lifetime of P.
790
791 return FinalID;
792}
793
794void TargetPassConfig::printAndVerify(const std::string &Banner) {
795 addPrintPass(Banner);
796 addVerifyPass(Banner);
797}
798
799void TargetPassConfig::addPrintPass(const std::string &Banner) {
800 if (PrintAfterISel)
801 PM->add(createMachineFunctionPrinterPass(dbgs(), Banner));
802}
803
804void TargetPassConfig::addVerifyPass(const std::string &Banner) {
806#ifdef EXPENSIVE_CHECKS
808 Verify = TM->isMachineVerifierClean();
809#endif
810 if (Verify)
811 PM->add(createMachineVerifierPass(Banner));
812}
813
817
819 PM->add(createStripDebugMachineModuleLegacyPass(/*OnlyDebugified=*/true));
820}
821
825
827 if (AllowDebugify && DebugifyIsSafe &&
831}
832
833void TargetPassConfig::addMachinePostPasses(const std::string &Banner) {
834 if (DebugifyIsSafe) {
840 }
841 addVerifyPass(Banner);
842}
843
844/// Add common target configurable passes that perform LLVM IR to IR transforms
845/// following machine independent optimization.
847 // Before running any passes, run the verifier to determine if the input
848 // coming from the front-end and/or optimizer is valid.
849 if (!DisableVerify)
851
853 // Basic AliasAnalysis support.
854 // Add TypeBasedAliasAnalysis before BasicAliasAnalysis so that
855 // BasicAliasAnalysis wins if they disagree. This is intended to help
856 // support "obvious" type-punning idioms.
860
861 // Run loop strength reduction before anything else.
862 if (!DisableLSR) {
867 }
868 }
869
870 // Run GC lowering passes for builtin collectors
871 // TODO: add a pass insertion point here
874
875 // For MachO, lower @llvm.global_dtors into @llvm.global_ctors with
876 // __cxa_atexit() calls to avoid emitting the deprecated __mod_term_func.
877 if (TM->getTargetTriple().isOSBinFormatMachO() &&
880
881 // Make sure that no unreachable blocks are instruction selected.
883
884 // Prepare expensive constants for SelectionDAG.
887
890
893
894 // Instrument function entry after all inlining.
896
897 // Add scalarization of target's unsupported masked memory intrinsics pass.
898 // the unsupported intrinsic will be replaced with a chain of basic blocks,
899 // that stores/loads element one-by-one if the appropriate mask bit is set.
901
902 // Expand reduction intrinsics into shuffle sequences if the target wants to.
903 // Allow disabling it for testing purposes.
906
907 // Convert conditional moves to conditional jumps when profitable.
910
913
914 if (TM->getTargetTriple().isOSWindows())
916}
917
918/// Turn exception handling constructs into something the code generators can
919/// handle.
921 const MCAsmInfo &MCAI = TM->getMCAsmInfo();
922 switch (MCAI.getExceptionHandlingType()) {
924 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
925 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
926 // catch info can get misplaced when a selector ends up more than one block
927 // removed from the parent invoke(s). This could happen when a landing
928 // pad is shared by multiple invokes and is also a target of a normal
929 // edge from elsewhere.
931 [[fallthrough]];
937 break;
939 // We support using both GCC-style and MSVC-style exceptions on Windows, so
940 // add both preparation passes. Each pass will only actually run if it
941 // recognizes the personality function.
944 break;
946 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
947 // on catchpads and cleanuppads because it does not outline them into
948 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
949 // should remove PHIs there. WinEHPrepare derives this from the Wasm
950 // personality, so no explicit flag is needed here.
952 break;
956 // Emscripten EH is lowered earlier by WebAssemblyLowerEmscriptenEHSjLj, so
957 // by this point it needs no generic EH preparation, like the None case.
959
960 // The lower invoke pass may create unreachable code. Remove it.
962 break;
963 }
964}
965
966/// Add pass to prepare the LLVM IR for code generation. This should be done
967/// before exception handling preparation passes.
972
973/// Add common passes that perform LLVM IR to IR transforms in preparation for
974/// instruction selection.
976 addPreISel();
977
978 // Force codegen to run according to the callgraph.
981
983
984 // Add both the safe stack and the stack protection passes: each of them will
985 // only protect functions that have corresponding attributes.
988
989 if (PrintISelInput)
991 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"));
992
993 // All passes which modify the LLVM IR are now complete; run the verifier
994 // to ensure that the IR is valid.
995 if (!DisableVerify)
997}
998
1000 // Enable FastISel with -fast-isel, but allow that to be overridden.
1002
1003 // Determine an instruction selector.
1004 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
1005 SelectorType Selector;
1006
1008 Selector = SelectorType::FastISel;
1010 (TM->Options.EnableGlobalISel &&
1012 Selector = SelectorType::GlobalISel;
1013 else if (TM->getOptLevel() == CodeGenOptLevel::None &&
1014 TM->getO0WantsFastISel())
1015 Selector = SelectorType::FastISel;
1016 else
1017 Selector = SelectorType::SelectionDAG;
1018
1019 // Set consistently TM->Options.EnableFastISel and EnableGlobalISel.
1020 if (Selector == SelectorType::FastISel) {
1021 TM->setFastISel(true);
1022 TM->setGlobalISel(false);
1023 } else if (Selector == SelectorType::GlobalISel) {
1024 TM->setFastISel(false);
1025 TM->setGlobalISel(true);
1026 }
1027
1028 // FIXME: Injecting into the DAGISel pipeline seems to cause issues with
1029 // analyses needing to be re-run. This can result in being unable to
1030 // schedule passes (particularly with 'Function Alias Analysis
1031 // Results'). It's not entirely clear why but AFAICT this seems to be
1032 // due to one FunctionPassManager not being able to use analyses from a
1033 // previous one. As we're injecting a ModulePass we break the usual
1034 // pass manager into two. GlobalISel with the fallback path disabled
1035 // and -run-pass seem to be unaffected. The majority of GlobalISel
1036 // testing uses -run-pass so this probably isn't too bad.
1037 SaveAndRestore SavedDebugifyIsSafe(DebugifyIsSafe);
1038 if (Selector != SelectorType::GlobalISel || !isGlobalISelAbortEnabled())
1039 DebugifyIsSafe = false;
1040
1041 // Add instruction selector passes for global isel if enabled.
1042 if (Selector == SelectorType::GlobalISel) {
1043 SaveAndRestore SavedAddingMachinePasses(AddingMachinePasses, true);
1044 if (addIRTranslator())
1045 return true;
1046
1048
1050 return true;
1051
1052 // Before running the register bank selector, ask the target if it
1053 // wants to run some passes.
1055
1056 if (addRegBankSelect())
1057 return true;
1058
1060
1062 return true;
1063 }
1064
1065 // Pass to reset the MachineFunction if the ISel failed. Outside of the above
1066 // if so that the verifier is not added to it.
1067 if (Selector == SelectorType::GlobalISel)
1070
1071 // Run the SDAG InstSelector, providing a fallback path when we do not want to
1072 // abort on not-yet-supported input.
1073 if (Selector != SelectorType::GlobalISel || !isGlobalISelAbortEnabled())
1074 if (addInstSelector())
1075 return true;
1076
1077 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
1078 // FinalizeISel.
1080
1081 // Print the instruction selected machine code...
1082 printAndVerify("After Instruction Selection");
1083
1084 return false;
1085}
1086
1088 if (TM->useEmulatedTLS())
1090
1091 PM->add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
1092 // ObjCARCContract operates on ObjC intrinsics and must run before
1093 // PreISelIntrinsicLowering.
1098 addIRPasses();
1099
1100 if (TriggerCrash)
1101 addPass(new TriggerCrashFunctionLegacyPass());
1102
1106
1107 return addCoreISelPasses();
1108}
1109
1110/// -regalloc=... command line option.
1111static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
1115 cl::desc("Register allocator to use"));
1116
1117/// Add the complete set of target-independent postISel code generator passes.
1118///
1119/// This can be read as the standard order of major LLVM CodeGen stages. Stages
1120/// with nontrivial configuration or multiple passes are broken out below in
1121/// add%Stage routines.
1122///
1123/// Any TargetPassConfig::addXX routine may be overriden by the Target. The
1124/// addPre/Post methods with empty header implementations allow injecting
1125/// target-specific fixups just before or after major stages. Additionally,
1126/// targets have the flexibility to change pass order within a stage by
1127/// overriding default implementation of add%Stage routines below. Each
1128/// technique has maintainability tradeoffs because alternate pass orders are
1129/// not well supported. addPre/Post works better if the target pass is easily
1130/// tied to a common pass. But if it has subtle dependencies on multiple passes,
1131/// the target should override the stage instead.
1132///
1133/// TODO: We could use a single addPre/Post(ID) hook to allow pass injection
1134/// before/after any target-independent pass. But it's currently overkill.
1136 AddingMachinePasses = true;
1137
1138 // Add passes that optimize machine instructions in SSA form.
1141 } else {
1142 // If the target requests it, assign local variables to stack slots relative
1143 // to one another and simplify frame index references where possible.
1145 }
1146
1147 if (TM->Options.EnableIPRA)
1149
1150 // Run pre-ra passes.
1152
1153 // Debugifying the register allocator passes seems to provoke some
1154 // non-determinism that affects CodeGen and there doesn't seem to be a point
1155 // where it becomes safe again so stop debugifying here.
1156 DebugifyIsSafe = false;
1157
1158 // Add a FSDiscriminator pass right before RA, so that we could get
1159 // more precise SampleFDO profile for RA.
1163 const std::string ProfileFile = getFSProfileFile(TM);
1164 if (!ProfileFile.empty() && !DisableRAFSProfileLoader)
1167 nullptr));
1168 }
1169
1170 // Run register allocation and passes that are tightly coupled with it,
1171 // including phi elimination and scheduling.
1172 if (getOptimizeRegAlloc())
1174 else
1176
1177 // Run post-ra passes.
1179
1181
1183
1184 // Insert prolog/epilog code. Eliminate abstract frame index references...
1188 }
1189
1190 // Prolog/Epilog inserter needs a TargetMachine to instantiate. But only
1191 // do so if it hasn't been disabled, substituted, or overridden.
1194
1195 /// Add passes that optimize machine instructions after register allocation.
1198
1199 // Expand pseudo instructions before second scheduling pass.
1201
1202 // Run pre-sched2 passes.
1203 addPreSched2();
1204
1207
1208 // Second pass scheduler.
1209 // Let Target optionally insert this pass by itself at some other
1210 // point.
1212 !TM->targetSchedulesPostRAScheduling()) {
1213 if (MISchedPostRA)
1215 else
1217 }
1218
1219 // GC
1220 addGCPasses();
1221
1222 // Basic block placement.
1225
1226 // Insert before XRay Instrumentation.
1228
1231
1233
1234 if (TM->Options.EnableIPRA)
1235 // Collect register usage information and produce a register mask of
1236 // clobbered registers, to be used to optimize call sites.
1238
1239 // FIXME: Some backends are incompatible with running the verifier after
1240 // addPreEmitPass. Maybe only pass "false" here for those targets?
1242
1247
1248 if (TM->Options.EnableMachineOutliner &&
1252 TM->supportsDefaultOutlining())
1254 }
1255
1258
1262
1263 if (TM->Options.EnableMachineFunctionSplitter ||
1265 TM->Options.EnableStaticDataPartitioning) {
1266 const std::string ProfileFile = getFSProfileFile(TM);
1267 if (!ProfileFile.empty()) {
1270 ProfileFile, getFSRemappingFile(TM),
1272 } else {
1273 // Sample profile is given, but FSDiscriminator is not
1274 // enabled, this may result in performance regression.
1276 << "Using AutoFDO without FSDiscriminator for MFS may regress "
1277 "performance.\n";
1278 }
1279 }
1280 }
1281
1282 // Machine function splitter uses the basic block sections feature.
1283 // When used along with `-basic-block-sections=`, the basic-block-sections
1284 // feature takes precedence. This means functions eligible for
1285 // basic-block-sections optimizations (`=all`, or `=list=` with function
1286 // included in the list profile) will get that optimization instead.
1287 if (TM->Options.EnableMachineFunctionSplitter ||
1290
1291 if (SplitStaticData || TM->Options.EnableStaticDataPartitioning) {
1292 // The static data splitter pass is a machine function pass. and
1293 // static data annotator pass is a module-wide pass. See the file comment
1294 // in StaticDataAnnotator.cpp for the motivation.
1297 }
1298 // We run the BasicBlockSections pass if either we need BB sections or BB
1299 // address map (or both).
1300 if (TM->getBBSectionsType() != llvm::BasicBlockSection::None ||
1301 TM->Options.BBAddrMap) {
1304 if (TM->getBBSectionsType() == llvm::BasicBlockSection::List) {
1306 TM->getBBSectionsFuncListBuf()));
1309 else {
1312 }
1313 }
1315 }
1316
1318
1319 if (!DisableCFIFixup && TM->Options.EnableCFIFixup)
1321
1323
1324 // Add passes that directly emit MI after all other MI passes.
1326
1327 AddingMachinePasses = false;
1328}
1329
1330/// Add passes that optimize machine instructions in SSA form.
1332 // Pre-ra tail duplication.
1334
1335 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1336 // instructions dead.
1338
1339 // This pass merges large allocas. StackSlotColoring is a different pass
1340 // which merges spill slots.
1342
1343 // If the target requests it, assign local variables to stack slots relative
1344 // to one another and simplify frame index references where possible.
1346
1347 // With optimization, dead code should already be eliminated. However
1348 // there is one known exception: lowered code for arguments that are only
1349 // used by tail calls, where the tail calls reuse the incoming stack
1350 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1352
1353 // Allow targets to insert passes that improve instruction level parallelism,
1354 // like if-conversion. Such passes will typically need dominator trees and
1355 // loop info, just like LICM and CSE below.
1356 addILPOpts();
1357
1360
1362
1364 // Clean-up the dead code that may have been generated by peephole
1365 // rewriting.
1367}
1368
1369//===---------------------------------------------------------------------===//
1370/// Register Allocation Pass Configuration
1371//===---------------------------------------------------------------------===//
1372
1373/// A dummy default pass factory indicates whether the register allocator is
1374/// overridden on the command line.
1376
1377static RegisterRegAlloc
1379 "pick register allocator based on -O option",
1381
1386
1388 // An explicit -regalloc choice implies its pipeline: only the fast
1389 // allocator uses the unoptimized one.
1394 return Ctor !=
1397}
1398
1399/// Instantiate the default register allocator pass for this target for either
1400/// the optimized or unoptimized allocation path. This will be added to the pass
1401/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1402/// in the optimized case.
1403///
1404/// A target that uses the standard regalloc pass order for fast or optimized
1405/// allocation may still override this for per-target regalloc
1406/// selection. But -regalloc=... always takes precedence.
1408 if (Optimized)
1410 else
1412}
1413
1414/// Find and instantiate the register allocation pass requested by this target
1415/// at the current optimization level. Different register allocators are
1416/// defined as separate passes because they may require different analysis.
1417///
1418/// This helper ensures that the regalloc= option is always available,
1419/// even for targets that override the default allocator.
1420///
1421/// FIXME: When MachinePassRegistry register pass IDs instead of function ptrs,
1422/// this can be folded into addPass.
1424 // getOptimizeRegAlloc, called before the pipeline branches, has initialized
1425 // the global default.
1427 if (Ctor != useDefaultRegisterAllocator)
1428 return Ctor();
1429
1430 // With no -regalloc= override, ask the target for a regalloc pass.
1431 return createTargetRegisterAllocator(Optimized);
1432}
1433
1438
1443 "Must use fast (default) register allocator for unoptimized regalloc.");
1444
1446
1447 // Allow targets to change the register assignments after
1448 // fast register allocation.
1450 return true;
1451}
1452
1454 // Add the selected register allocation pass.
1456
1457 // Allow targets to change the register assignments before rewriting.
1458 addPreRewrite();
1459
1460 // Finally rewrite virtual registers.
1462
1463 // Regalloc scoring for ML-driven eviction - noop except when learning a new
1464 // eviction policy.
1466 return true;
1467}
1468
1469/// Return true if the default global register allocator is in use and
1470/// has not be overriden on the command line with '-regalloc=...'
1472 return RegAlloc.getNumOccurrences() == 0;
1473}
1474
1475/// Add the minimum set of target-independent passes that are required for
1476/// register allocation. No coalescing or scheduling.
1483
1484/// Add standard target-independent passes that are tightly coupled with
1485/// optimized register allocation, including coalescing, machine instruction
1486/// scheduling, and register allocation itself.
1489
1491
1493
1494 // LiveVariables currently requires pure SSA form.
1495 //
1496 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1497 // LiveVariables can be removed completely, and LiveIntervals can be directly
1498 // computed. (We still either need to regenerate kill flags after regalloc, or
1499 // preferably fix the scavenger to not depend on them).
1500 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1501 // When LiveVariables is removed this has to be removed/moved either.
1502 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1503 // after it with -stop-before/-stop-after.
1506
1507 // Edge splitting is smarter with machine loop info.
1510
1511 // LiveIntervals is computed unconditionally before TwoAddressInstruction so
1512 // that pass can rely on it instead of LiveVariables. This is a step toward
1513 // removing LiveVariables entirely.
1514 // FIXME: Eventually, we want to run LiveIntervals before PHI elimination.
1516
1519
1520 // The machine scheduler may accidentally create disconnected components
1521 // when moving subregister definitions around, avoid this by splitting them to
1522 // separate vregs before. Splitting can also improve reg. allocation quality.
1524
1525 // PreRA instruction scheduling.
1527
1529 // Perform stack slot coloring and post-ra machine LICM.
1531
1532 // Allow targets to expand pseudo instructions depending on the choice of
1533 // registers before MachineCopyPropagation.
1535
1536 // Copy propagate to forward register uses and try to eliminate COPYs that
1537 // were not coalesced.
1539
1540 // Run post-ra machine LICM to hoist reloads / remats.
1541 //
1542 // FIXME: can this move into MachineLateOptimization?
1544 }
1545}
1546
1547//===---------------------------------------------------------------------===//
1548/// Post RegAlloc Pass Configuration
1549//===---------------------------------------------------------------------===//
1550
1551/// Add passes that optimize machine instructions after register allocation.
1553 // Cleanup of redundant immediate/address loads.
1555
1556 // Branch folding must be run after regalloc and prolog/epilog insertion.
1558
1559 // Tail duplication.
1560 // Note that duplicating tail just increases code size and degrades
1561 // performance for targets that require Structured Control Flow.
1562 // In addition it can also make CFG irreducible. Thus we disable it.
1563 if (!TM->requiresStructuredCFG())
1565
1566 // Copy propagation.
1568}
1569
1570/// Add standard GC passes.
1573 return true;
1574}
1575
1576/// Add standard basic block placement passes.
1581 const std::string ProfileFile = getFSProfileFile(TM);
1582 if (!ProfileFile.empty() && !DisableLayoutFSProfileLoader)
1585 nullptr));
1586 }
1588 // Run a separate pass to collect block placement statistics.
1591 }
1592}
1593
1594//===---------------------------------------------------------------------===//
1595/// GlobalISel Configuration
1596//===---------------------------------------------------------------------===//
1598 return TM->Options.GlobalISelAbort == GlobalISelAbortMode::Enable;
1599}
1600
1604
1605std::unique_ptr<CSEConfigBase> TargetPassConfig::getCSEConfig() const {
1606 return std::make_unique<CSEConfigBase>();
1607}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This is the interface for LLVM's primary stateless and local alias analysis.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
This file defines the DenseMap class.
static bool runOnFunction(Function &F, bool PostInlining)
This file contains an interface for creating legacy passes to print out IR in various granularities.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
#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:56
cl::opt< bool > PrintRegUsage
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
Register Allocation Pass Configuration.
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< 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::OptimisticPGO, "optimistic-pgo", "Outline cold code only. If a code block does not have " "profile data, optimistically assume it is cold."), clEnumValN(RunOutliner::ConservativePGO, "conservative-pgo", "Outline cold code only. If a code block does not have " "profile, data, conservatively assume it is hot."), clEnumValN(RunOutliner::NeverOutline, "never", "Disable all outlining"), clEnumValN(RunOutliner::AlwaysOutline, "", "")))
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"))
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)
cl::opt< bool > PrintRegUsage("print-regusage", cl::Hidden, cl::desc("Print register usage details collected for IPRA"))
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 > 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 > SplitStaticData("split-static-data", cl::Hidden, cl::init(false), cl::desc("Split static data sections into hot and cold " "sections using profile information"))
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 > 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 > BasicBlockSectionMatchInfer("basic-block-section-match-infer", cl::desc("Enable matching and inference when generating basic block sections"), cl::init(false))
Enable matching and inference when using propeller.
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 cl::opt< bool > TriggerCrash("codegen-pipeline-trigger-crash", cl::init(false), cl::Hidden, cl::desc("Trigger crash in codegen pipeline"))
static IdentifyingPassPtr applyDisable(IdentifyingPassPtr PassID, bool Override)
Allow standard passes to be disabled by command line options.
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"))
#define SET_OPTION_IF_PRESENT(Option)
static cl::opt< bool > EnableGCEmptyBlocks("enable-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< 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 > DisableCopyProp("disable-copyprop", cl::Hidden, cl::desc("Disable Copy Propagation pass"))
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[]
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT, true > const_iterator
Definition DenseMap.h:684
This pass is required by interprocedural register allocation.
Tagged union holding either a T or a Error.
Definition Error.h:485
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition FastISel.h:67
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
A type-erased reference to the IR unit a pass or analysis is running on, together with the kind of IR...
Definition IRUnitRef.h:60
Discriminated union of Pass ID types.
AnalysisID getID() const
ImmutablePass(char &pid)
Definition Pass.h:287
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:67
ExceptionHandling getExceptionHandlingType() const
Definition MCAsmInfo.h:656
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:29
const void * getTypeInfo() const
getTypeInfo - Return the id object for the pass... TODO : Rename
Definition PassInfo.h:62
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
LLVM_ABI 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:99
static Pass * createPass(AnalysisID ID)
Definition Pass.cpp:222
AnalysisID getPassID() const
getPassID - Return the PassID number that corresponds to this pass.
Definition Pass.h:122
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...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
Definition StringRef.h:490
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
Primary interface to the complete machine description for the target machine.
const std::optional< PGOOptions > & getPGOOption() const
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 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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
static LLVM_ABI raw_ostream & warning()
Convenience method for printing "warning: " to stderr.
Definition WithColor.cpp:86
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI ModulePass * createLowerGlobalDtorsLegacyPass()
LLVM_ABI FunctionPass * createFastRegisterAllocator()
FastRegisterAllocation Pass - This pass register allocates as fast as possible.
LLVM_ABI char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
LLVM_ABI FunctionPass * createWinEHPass()
createWinEHPass - Prepares personality functions used by MSVC on Windows, in addition to the Itanium ...
LLVM_ABI char & GCMachineCodeAnalysisID
GCMachineCodeAnalysis - Target-independent pass to mark safe points in machine code.
LLVM_ABI bool shouldEmitBBHash()
Returns whether -emit-bb-hash is set.
LLVM_ABI char & FEntryInserterID
This pass inserts FEntry calls.
LLVM_ABI char & GCLoweringID
GCLowering Pass - Used by gc.root to perform its default lowering operations.
LLVM_ABI void initializeBasicAAWrapperPassPass(PassRegistry &)
LLVM_ABI void registerCodeGenCallback(PassInstrumentationCallbacks &PIC, TargetMachine &)
LLVM_ABI char & InitUndefID
LLVM_ABI char & RegisterCoalescerID
RegisterCoalescer - This pass merges live ranges to eliminate copies.
LLVM_ABI FunctionPass * createGreedyRegisterAllocator()
Greedy register allocation pass - This pass implements a global register allocator for optimized buil...
LLVM_ABI FunctionPass * createConstantHoistingPass()
LLVM_ABI FunctionPass * createSafeStackPass()
This pass splits the stack into a safe stack and an unsafe stack to protect against stack-based overf...
LLVM_ABI ModulePass * createStaticDataAnnotatorLegacyPass()
createStaticDataAnnotatorPASS - This is a module pass that reads from StaticDataProfileInfoWrapperPas...
LLVM_ABI cl::opt< bool > EnableFSDiscriminator
LLVM_ABI FunctionPass * createSelectOptimizePass()
This pass converts conditional moves to conditional jumps when profitable.
LLVM_ABI char & FixupStatepointCallerSavedID
The pass fixups statepoint machine instruction to replace usage of caller saved registers with stack ...
LLVM_ABI MachineFunctionPass * createBasicBlockSectionsPass()
createBasicBlockSections Pass - This pass assigns sections to machine basic blocks and is enabled wit...
LLVM_ABI FunctionPass * createPostInlineEntryExitInstrumenterPass()
LLVM_ABI MachineFunctionPass * createPrologEpilogInserterPass()
LLVM_ABI char & TailDuplicateLegacyID
TailDuplicate - Duplicate blocks with unconditional branches into tails of their predecessors.
LLVM_ABI char & ExpandPostRAPseudosID
ExpandPostRAPseudos - This pass expands pseudo instructions after register allocation.
LLVM_ABI ModulePass * createStripDebugMachineModuleLegacyPass(bool OnlyDebugified)
Creates MIR Strip Debug pass.
LLVM_ABI char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
LLVM_ABI MachineFunctionPass * createResetMachineFunctionLegacyPass(bool EmitFallbackDiag, bool AbortOnFailedISel)
This pass resets a MachineFunction when it has the FailedISel property as if it was just created.
LLVM_ABI FunctionPass * createScalarizeMaskedMemIntrinLegacyPass()
LLVM_ABI char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
LLVM_ABI char & RemoveLoadsIntoFakeUsesID
RemoveLoadsIntoFakeUses pass.
LLVM_ABI MachineFunctionPass * createStackFrameLayoutAnalysisPass()
StackFramePrinter pass - This pass prints out the machine function's stack frame to the given stream ...
LLVM_ABI ModulePass * createGlobalMergeFuncPass()
This pass performs merging similar functions globally.
LLVM_ABI char & MachineSanitizerBinaryMetadataID
LLVM_ABI FunctionPass * createStackProtectorPass()
createStackProtectorPass - This pass adds stack protectors to functions.
LLVM_ABI Pass * createLoopTermFoldPass()
LLVM_ABI char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
LLVM_ABI char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
LLVM_ABI char & PeepholeOptimizerLegacyID
PeepholeOptimizer - This pass performs peephole optimizations - like extension and comparison elimina...
LLVM_ABI char & LiveDebugValuesID
LiveDebugValues pass.
LLVM_ABI char & PrologEpilogCodeInserterID
PrologEpilogCodeInserter - This pass inserts prolog and epilog code, and eliminates abstract frame re...
LLVM_ABI FunctionPass * createExpandIRInstsPass(CodeGenOptLevel)
LLVM_ABI char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
LLVM_ABI MachineFunctionPass * createMachineFunctionSplitterPass()
createMachineFunctionSplitterPass - This pass splits machine functions using profile information.
LLVM_ABI FunctionPass * createMachineVerifierPass(const std::string &Banner)
createMachineVerifierPass - This pass verifies cenerated machine code instructions for correctness.
LLVM_ABI ImmutablePass * createBasicBlockSectionsProfileReaderWrapperPass(const MemoryBuffer *Buf)
LLVM_ABI char & MachineLoopInfoID
MachineLoopInfo - This pass is a loop analysis pass.
LLVM_ABI char & ShadowStackGCLoweringID
ShadowStackGCLowering - Implements the custom lowering mechanism used by the shadow stack GC.
LLVM_ABI char & ImplicitNullChecksID
ImplicitNullChecks - This pass folds null pointer checks into nearby memory operations.
LLVM_ABI FunctionPass * createMIRAddFSDiscriminatorsPass(sampleprof::FSDiscriminatorPass P)
Add Flow Sensitive Discriminators.
LLVM_ABI ModulePass * createPreISelIntrinsicLoweringPass()
This pass lowers the @llvm.load.relative and @llvm.objc.
LLVM_ABI char & ShrinkWrapID
ShrinkWrap pass. Look for the best place to insert save and restore.
LLVM_ABI char & MachineLateInstrsCleanupID
MachineLateInstrsCleanup - This pass removes redundant identical instructions after register allocati...
LLVM_ABI char & UnreachableMachineBlockElimID
UnreachableMachineBlockElimination - This pass removes unreachable machine basic blocks.
LLVM_ABI FunctionPass * createLowerInvokePass()
LLVM_ABI FunctionPass * createRegUsageInfoCollector()
This pass is executed POST-RA to collect which physical registers are preserved by given machine func...
LLVM_ABI ImmutablePass * createScopedNoAliasAAWrapperPass()
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
LLVM_ABI char & XRayInstrumentationID
This pass inserts the XRay instrumentation sleds if they are supported by the target platform.
LLVM_ABI char & OptimizePHIsLegacyID
OptimizePHIs - This pass optimizes machine instruction PHIs to take advantage of opportunities create...
LLVM_ABI char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
LLVM_ABI char & FuncletLayoutID
This pass lays out funclets contiguously.
LLVM_ABI FunctionPass * createCodeGenPrepareLegacyPass()
createCodeGenPrepareLegacyPass - Transform the code to expose more pattern matching during instructio...
LLVM_ABI 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...
LLVM_ABI char & RemoveRedundantDebugValuesID
RemoveRedundantDebugValues pass.
LLVM_ABI FunctionPass * createBasicAAWrapperPass()
LLVM_ABI char & DetectDeadLanesID
This pass adds dead/undef flags after analyzing subregister lanes.
LLVM_ABI char & PostRAMachineSinkingID
This pass perform post-ra machine sink for COPY instructions.
LLVM_ABI FunctionPass * createDwarfEHPass(CodeGenOptLevel OptLevel)
createDwarfEHPass - This pass mulches exception handling code into a form adapted to code generation.
LLVM_ABI FunctionPass * createRegAllocScoringPass()
When learning an eviction policy, extract score(reward) information, otherwise this does nothing.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:227
LLVM_ABI char & StackSlotColoringID
StackSlotColoring - This pass performs stack slot coloring.
LLVM_ABI ModulePass * createMachineOutlinerPass(RunOutliner RunOutlinerMode)
This pass performs outlining on machine instructions directly before printing assembly.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
LLVM_ABI ModulePass * createLowerEmuTLSPass()
LowerEmuTLS - This pass generates __emutls_[vt].xyz variables for all TLS variables for the emulated ...
LLVM_ABI char & ProcessImplicitDefsID
ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
LLVM_ABI ImmutablePass * createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA)
Create an analysis pass wrapper around a TTI object.
LLVM_ABI MachineFunctionPass * createInsertCodePrefetchPass()
createInsertCodePrefetchPass - This pass enables inserting code prefetch hints based on the basic blo...
static cl::opt< bool > TriggerCrash("opt-pipeline-trigger-crash", cl::init(false), cl::Hidden, cl::desc("Trigger crash in optimization pipeline"))
LLVM_ABI FunctionPass * createMIRProfileLoaderPass(std::string File, std::string RemappingFile, sampleprof::FSDiscriminatorPass P, IntrusiveRefCntPtr< vfs::FileSystem > FS)
Read Flow Sensitive Profile.
LLVM_ABI FunctionPass * createVerifierPass(bool FatalErrors=true)
LLVM_ABI char & MachineCSELegacyID
MachineCSE - This pass performs global CSE on machine instructions.
LLVM_ABI ImmutablePass * createTypeBasedAAWrapperPass()
LLVM_ABI Pass * createLoopStrengthReducePass()
LLVM_ABI MachineFunctionPass * createMachineBlockHashInfoPass()
createMachineBlockHashInfoPass - This pass computes basic block hashes.
LLVM_ABI char & LiveVariablesID
LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...
LLVM_ABI char & EarlyTailDuplicateLegacyID
Duplicate blocks with unconditional branches into tails of their predecessors.
LLVM_ABI void initializeAAResultsWrapperPassPass(PassRegistry &)
LLVM_ABI FunctionPass * createExpandReductionsPass()
This pass expands the reduction intrinsics into sequences of shuffles.
LLVM_ABI MachineFunctionPass * createStaticDataSplitterLegacyPass()
createStaticDataSplitterPass - This is a machine-function pass that categorizes static data hotness u...
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
Definition Threading.h:86
LLVM_ABI FunctionPass * createSjLjEHPreparePass(const TargetMachine *TM)
createSjLjEHPreparePass - This pass adapts exception handling code to use the GCC-style builtin setjm...
LLVM_ABI MachineFunctionPass * createBasicBlockPathCloningPass()
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:58
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:64
@ Emscripten
Emscripten JavaScript-based exception handling.
Definition CodeGen.h:62
@ None
No exception support.
Definition CodeGen.h:56
@ Default
Not specified; resolve to the target's default model.
Definition CodeGen.h:55
@ AIX
AIX Exception Handling.
Definition CodeGen.h:63
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:57
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:60
@ Wasm
WebAssembly Exception Handling.
Definition CodeGen.h:61
LLVM_ABI char & StackColoringLegacyID
StackSlotColoring - This pass performs stack coloring and merging.
LLVM_ABI char & VirtRegRewriterID
VirtRegRewriter pass.
LLVM_ABI FunctionPass * createReplaceWithVeclibLegacyPass()
LLVM_ABI FunctionPass * createInlineAsmPreparePass()
LLVM_ABI char & FinalizeISelID
This pass expands pseudo-instructions, reserves registers and adjusts machine frame information.
LLVM_ABI char & MachineSinkingLegacyID
MachineSinking - This pass performs sinking on machine instructions.
LLVM_ABI FunctionPass * createRegUsageInfoPropPass()
Return a MachineFunction pass that identifies call sites and propagates register usage information of...
LLVM_ABI FunctionPass * createPartiallyInlineLibCallsPass()
LLVM_ABI void initializeLibcallLoweringInfoWrapperPass(PassRegistry &)
LLVM_ABI char & MachineBlockPlacementID
MachineBlockPlacement - This pass places basic blocks based on branch probabilities.
LLVM_ABI char & TwoAddressInstructionPassID
TwoAddressInstruction - This pass reduces two-address instructions to use two operands.
LLVM_ABI MachineFunctionPass * createBasicBlockMatchingAndInferencePass()
createBasicBlockMatchingAndInferencePass - This pass enables matching and inference when using propel...
LLVM_ABI ModulePass * createCheckDebugMachineModuleLegacyPass()
Creates MIR Check Debug pass.
LLVM_ABI Pass * createCanonicalizeFreezeInLoopsPass()
LLVM_ABI char & LocalStackSlotAllocationID
LocalStackSlotAllocation - This pass assigns local frame indices to stack slots relative to one anoth...
LLVM_ABI char & BranchFolderPassID
BranchFolding - This pass performs machine code CFG based optimizations to delete branches to branche...
LLVM_ABI char & PHIEliminationID
PHIElimination - This pass eliminates machine instruction PHI nodes by inserting copy instructions.
LLVM_ABI Pass * createObjCARCContractPass()
LLVM_ABI ModulePass * createDebugifyMachineModulePass()
Creates MIR Debugify pass.
LLVM_ABI 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.
LLVM_ABI ModulePass * createWindowsSecureHotPatchingPass()
Creates Windows Secure Hot Patch pass.
LLVM_ABI FunctionPass * createCFIFixupLegacy()
Creates CFI Fixup pass.
LLVM_ABI char & RenameIndependentSubregsID
This pass detects subregister lanes in a virtual register that are used independently of other lanes ...
LLVM_ABI char & MachineLICMID
This pass performs loop invariant code motion on machine instructions.
LLVM_ABI char & MachineBlockPlacementStatsID
MachineBlockPlacementStats - This pass collects statistics about the basic block placement using bran...
LLVM_ABI MachineFunctionPass * createGCEmptyBasicBlocksLegacyPass()
createGCEmptyBasicblocksPass - Empty basic blocks (basic blocks without real code) appear as the resu...
LLVM_ABI char & LiveIntervalsID
LiveIntervals - This analysis keeps track of the live ranges of virtual and physical registers.
LLVM_ABI char & MachineCopyPropagationID
MachineCopyPropagation - This pass performs copy propagation on machine instructions.
LLVM_ABI char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
const void * AnalysisID
Definition Pass.h:51
LLVM_ABI void initializeCodeGen(PassRegistry &)
Initialize all passes linked into the CodeGen library.
Definition CodeGen.cpp:20
LLVM_ABI FunctionPass * createUnreachableBlockEliminationPass()
createUnreachableBlockEliminationPass - The LLVM code generator does not work well with unreachable b...
LLVM_ABI CGPassBuilderOption getCGPassBuilderOption()
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
InsertedPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID)
A utility class that uses RAII to save and restore the value of a variable.
The llvm::once_flag structure.
Definition Threading.h:67