LLVM 23.0.0git
CodeGenPassBuilder.h
Go to the documentation of this file.
1//===- Construction of codegen pass pipelines ------------------*- C++ -*--===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9///
10/// Interfaces for producing common pass manager configurations.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_PASSES_CODEGENPASSBUILDER_H
15#define LLVM_PASSES_CODEGENPASSBUILDER_H
16
18#include "llvm/ADT/StringRef.h"
64#include "llvm/CodeGen/PEI.h"
101#include "llvm/IR/PassManager.h"
102#include "llvm/IR/Verifier.h"
104#include "llvm/MC/MCAsmInfo.h"
106#include "llvm/Support/CodeGen.h"
107#include "llvm/Support/Debug.h"
108#include "llvm/Support/Error.h"
124#include <cassert>
125#include <utility>
126
127namespace llvm {
128
129// FIXME: Dummy target independent passes definitions that have not yet been
130// ported to new pass manager. Once they do, remove these.
131#define DUMMY_FUNCTION_PASS(NAME, PASS_NAME) \
132 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
133 template <typename... Ts> PASS_NAME(Ts &&...) {} \
134 PreservedAnalyses run(Function &, FunctionAnalysisManager &) { \
135 return PreservedAnalyses::all(); \
136 } \
137 };
138#define DUMMY_MACHINE_MODULE_PASS(NAME, PASS_NAME) \
139 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
140 template <typename... Ts> PASS_NAME(Ts &&...) {} \
141 PreservedAnalyses run(Module &, ModuleAnalysisManager &) { \
142 return PreservedAnalyses::all(); \
143 } \
144 };
145#define DUMMY_MACHINE_FUNCTION_PASS(NAME, PASS_NAME) \
146 struct PASS_NAME : public PassInfoMixin<PASS_NAME> { \
147 template <typename... Ts> PASS_NAME(Ts &&...) {} \
148 PreservedAnalyses run(MachineFunction &, \
149 MachineFunctionAnalysisManager &) { \
150 return PreservedAnalyses::all(); \
151 } \
152 };
153#include "llvm/Passes/MachinePassRegistry.def"
154
155class PassManagerWrapper {
156private:
157 PassManagerWrapper(ModulePassManager &ModulePM) : MPM(ModulePM) {};
158
162
163 template <typename DerivedT, typename TargetMachineT>
164 friend class CodeGenPassBuilder;
165};
166
167/// This class provides access to building LLVM's passes.
168///
169/// Its members provide the baseline state available to passes during their
170/// construction. The \c MachinePassRegistry.def file specifies how to construct
171/// all of the built-in passes, and those may reference these members during
172/// construction.
173template <typename DerivedT, typename TargetMachineT> class CodeGenPassBuilder {
174public:
175 explicit CodeGenPassBuilder(TargetMachineT &TM,
176 const CGPassBuilderOption &Opts,
178 : TM(TM), Opt(Opts), PIC(PIC) {
179 // Target could set CGPassBuilderOption::MISchedPostRA to true to achieve
180 // substitutePass(&PostRASchedulerID, &PostMachineSchedulerID)
181
182 // Target should override TM.Options.EnableIPRA in their target-specific
183 // LLVMTM ctor. See TargetMachine::setGlobalISel for example.
184 if (Opt.EnableIPRA) {
185 TM.Options.EnableIPRA = *Opt.EnableIPRA;
186 } else {
187 // If not explicitly specified, use target default.
188 TM.Options.EnableIPRA |= TM.useIPRA();
189 }
190
191 if (Opt.EnableGlobalISelAbort)
192 TM.Options.GlobalISelAbort = *Opt.EnableGlobalISelAbort;
193
194 if (!Opt.OptimizeRegAlloc)
195 Opt.OptimizeRegAlloc = getOptLevel() != CodeGenOptLevel::None;
196 }
197
199 raw_pwrite_stream *DwoOut,
200 CodeGenFileType FileType) const;
201
205
206protected:
207 template <typename PassT>
208 using is_module_pass_t = decltype(std::declval<PassT &>().run(
209 std::declval<Module &>(), std::declval<ModuleAnalysisManager &>()));
210
211 template <typename PassT>
212 using is_function_pass_t = decltype(std::declval<PassT &>().run(
213 std::declval<Function &>(), std::declval<FunctionAnalysisManager &>()));
214
215 template <typename PassT>
216 using is_machine_function_pass_t = decltype(std::declval<PassT &>().run(
217 std::declval<MachineFunction &>(),
218 std::declval<MachineFunctionAnalysisManager &>()));
219
220 template <typename PassT>
222 bool Force = false,
223 StringRef Name = PassT::name()) const {
225 "Only function passes are supported.");
226 if (!Force && !runBeforeAdding(Name))
227 return;
228 PMW.FPM.addPass(std::forward<PassT>(Pass));
229 }
230
231 template <typename PassT>
232 void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force = false,
233 StringRef Name = PassT::name()) const {
235 "Only module passes are suported.");
236 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
237 "You cannot insert a module pass without first flushing the current "
238 "function pipelines to the module pipeline.");
239 if (!Force && !runBeforeAdding(Name))
240 return;
241 PMW.MPM.addPass(std::forward<PassT>(Pass));
242 }
243
244 template <typename PassT>
246 bool Force = false,
247 StringRef Name = PassT::name()) const {
249 "Only machine function passes are supported.");
250
251 if (!Force && !runBeforeAdding(Name))
252 return;
253 PMW.MFPM.addPass(std::forward<PassT>(Pass));
254 for (auto &C : AfterCallbacks)
255 C(Name, PMW.MFPM);
256 }
257
259 bool FreeMachineFunctions = false) const {
260 if (PMW.FPM.isEmpty() && PMW.MFPM.isEmpty())
261 return;
262 if (!PMW.MFPM.isEmpty()) {
263 PMW.FPM.addPass(
264 createFunctionToMachineFunctionPassAdaptor(std::move(PMW.MFPM)));
265 PMW.MFPM = MachineFunctionPassManager();
266 }
267 if (FreeMachineFunctions)
269 if (AddInCGSCCOrder) {
271 createCGSCCToFunctionPassAdaptor(std::move(PMW.FPM))));
272 } else {
273 PMW.MPM.addPass(createModuleToFunctionPassAdaptor(std::move(PMW.FPM)));
274 }
275 PMW.FPM = FunctionPassManager();
276 }
277
279 assert(!AddInCGSCCOrder);
280 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
281 "Requiring CGSCC ordering requires flushing the current function "
282 "pipelines to the MPM.");
283 AddInCGSCCOrder = true;
284 }
285
287 assert(AddInCGSCCOrder);
288 assert(PMW.FPM.isEmpty() && PMW.MFPM.isEmpty() &&
289 "Stopping CGSCC ordering requires flushing the current function "
290 "pipelines to the MPM.");
291 AddInCGSCCOrder = false;
292 }
293
294 TargetMachineT &TM;
297
298 template <typename TMC> TMC &getTM() const { return static_cast<TMC &>(TM); }
299 CodeGenOptLevel getOptLevel() const { return TM.getOptLevel(); }
300
301 /// Check whether or not GlobalISel should abort on error.
302 /// When this is disabled, GlobalISel will fall back on SDISel instead of
303 /// erroring out.
305 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::Enable;
306 }
307
308 /// Check whether or not a diagnostic should be emitted when GlobalISel
309 /// uses the fallback path. In other words, it will emit a diagnostic
310 /// when GlobalISel failed and isGlobalISelAbortEnabled is false.
312 return TM.Options.GlobalISelAbort == GlobalISelAbortMode::DisableWithDiag;
313 }
314
315 /// addInstSelector - This method should install an instruction selector pass,
316 /// which converts from LLVM code to machine instructions.
318 return make_error<StringError>("addInstSelector is not overridden",
320 }
321
322 /// Target can override this to add GlobalMergePass before all IR passes.
324
325 /// Add passes that optimize instruction level parallelism for out-of-order
326 /// targets. These passes are run while the machine code is still in SSA
327 /// form, so they can use MachineTraceMetrics to control their heuristics.
328 ///
329 /// All passes added here should preserve the MachineDominatorTree,
330 /// MachineLoopInfo, and MachineTraceMetrics analyses.
331 void addILPOpts(PassManagerWrapper &PMW) const {}
332
333 /// This method may be implemented by targets that want to run passes
334 /// immediately before register allocation.
336
337 /// addPreRewrite - Add passes to the optimized register allocation pipeline
338 /// after register allocation is complete, but before virtual registers are
339 /// rewritten to physical registers.
340 ///
341 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
342 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
343 /// When these passes run, VirtRegMap contains legal physreg assignments for
344 /// all virtual registers.
345 ///
346 /// Note if the target overloads addRegAssignAndRewriteOptimized, this may not
347 /// be honored. This is also not generally used for the fast variant,
348 /// where the allocation and rewriting are done in one pass.
350
351 /// Add passes to be run immediately after virtual registers are rewritten
352 /// to physical registers.
354
355 /// This method may be implemented by targets that want to run passes after
356 /// register allocation pass pipeline but before prolog-epilog insertion.
358
359 /// This method may be implemented by targets that want to run passes after
360 /// prolog-epilog insertion and before the second instruction scheduling pass.
362
363 /// This pass may be implemented by targets that want to run passes
364 /// immediately before machine code is emitted.
366
367 /// Targets may add passes immediately before machine code is emitted in this
368 /// callback. This is called even later than `addPreEmitPass`.
369 // FIXME: Rename `addPreEmitPass` to something more sensible given its actual
370 // position and remove the `2` suffix here as this callback is what
371 // `addPreEmitPass` *should* be but in reality isn't.
373
374 /// {{@ For GlobalISel
375 ///
376
377 /// addPreISel - This method should add any "last minute" LLVM->LLVM
378 /// passes (which are run just before instruction selector).
380 llvm_unreachable("addPreISel is not overridden");
381 }
382
383 /// This method should install an IR translator pass, which converts from
384 /// LLVM code to machine instructions with possibly generic opcodes.
386 return make_error<StringError>("addIRTranslator is not overridden",
388 }
389
390 /// This method may be implemented by targets that want to run passes
391 /// immediately before legalization.
393
394 /// This method should install a legalize pass, which converts the instruction
395 /// sequence into one that can be selected by the target.
397 return make_error<StringError>("addLegalizeMachineIR is not overridden",
399 }
400
401 /// This method may be implemented by targets that want to run passes
402 /// immediately before the register bank selection.
404
405 /// This method should install a register bank selector pass, which
406 /// assigns register banks to virtual registers without a register
407 /// class or register banks.
409 return make_error<StringError>("addRegBankSelect is not overridden",
411 }
412
413 /// This method may be implemented by targets that want to run passes
414 /// immediately before the (global) instruction selection.
416
417 /// This method should install a (global) instruction selector pass, which
418 /// converts possibly generic instructions to fully target-specific
419 /// instructions, thereby constraining all generic virtual registers to
420 /// register classes.
423 "addGlobalInstructionSelect is not overridden",
425 }
426 /// @}}
427
428 /// High level function that adds all passes necessary to go from llvm IR
429 /// representation to the MI representation.
430 /// Adds IR based lowering and target specific optimization passes and finally
431 /// the core instruction selection passes.
433
434 /// Add the actual instruction selection passes. This does not include
435 /// preparation passes on IR.
437
438 /// Add the complete, standard set of LLVM CodeGen passes.
439 /// Fully developed targets will not generally override this.
441
442 /// Add passes to lower exception handling for the code generator.
444
445 /// Add common target configurable passes that perform LLVM IR to IR
446 /// transforms following machine independent optimization.
448
449 /// Add pass to prepare the LLVM IR for code generation. This should be done
450 /// before exception handling preparation passes.
452
453 /// Add common passes that perform LLVM IR to IR transforms in preparation for
454 /// instruction selection.
456
457 /// Methods with trivial inline returns are convenient points in the common
458 /// codegen pass pipeline where targets may insert passes. Methods with
459 /// out-of-line standard implementations are major CodeGen stages called by
460 /// addMachinePasses. Some targets may override major stages when inserting
461 /// passes is insufficient, but maintaining overriden stages is more work.
462 ///
463
464 /// addMachineSSAOptimization - Add standard passes that optimize machine
465 /// instructions in SSA form.
467
468 /// addFastRegAlloc - Add the minimum set of target-independent passes that
469 /// are required for fast register allocation.
471
472 /// addOptimizedRegAlloc - Add passes related to register allocation.
473 /// CodeGenTargetMachineImpl provides standard regalloc passes for most
474 /// targets.
476
477 /// Add passes that optimize machine instructions after register allocation.
479
480 /// addGCPasses - Add late codegen passes that analyze code for garbage
481 /// collection. This should return true if GC info should be printed after
482 /// these passes.
483 void addGCPasses(PassManagerWrapper &PMW) const {}
484
485 /// Add standard basic block placement passes.
487
489
491 std::function<Expected<std::unique_ptr<MCStreamer>>(MCContext &)>;
493 llvm_unreachable("addAsmPrinter is not overridden");
494 }
495
496 /// Utilities for targets to add passes to the pass manager.
497 ///
498
499 /// createTargetRegisterAllocator - Create the register allocator pass for
500 /// this target at the current optimization level.
502 bool Optimized) const;
503
504 /// addMachinePasses helper to create the target-selected or overriden
505 /// regalloc pass.
506 void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized) const;
507
508 /// Add core register alloator passes which do the actual register assignment
509 /// and rewriting. \returns true if any passes were added.
512
513 /// Allow the target to disable a specific pass by default.
514 /// Backend can declare unwanted passes in constructor.
515 template <typename... PassTs> void disablePass() {
516 BeforeCallbacks.emplace_back(
517 [](StringRef Name) { return ((Name != PassTs::name()) && ...); });
518 }
519
520 /// Insert InsertedPass pass after TargetPass pass.
521 /// Only machine function passes are supported.
522 template <typename TargetPassT, typename InsertedPassT>
523 void insertPass(InsertedPassT &&Pass) const {
524 AfterCallbacks.emplace_back(
525 [&](StringRef Name, MachineFunctionPassManager &MFPM) mutable {
526 if (Name == TargetPassT::name() &&
527 runBeforeAdding(InsertedPassT::name())) {
528 MFPM.addPass(std::forward<InsertedPassT>(Pass));
529 }
530 });
531 }
532
533private:
534 DerivedT &derived() { return static_cast<DerivedT &>(*this); }
535 const DerivedT &derived() const {
536 return static_cast<const DerivedT &>(*this);
537 }
538
539 bool runBeforeAdding(StringRef Name) const {
540 bool ShouldAdd = true;
541 for (auto &C : BeforeCallbacks)
542 ShouldAdd &= C(Name);
543 return ShouldAdd;
544 }
545
546 void setStartStopPasses(const TargetPassConfig::StartStopInfo &Info) const;
547
548 Error verifyStartStop(const TargetPassConfig::StartStopInfo &Info) const;
549
550 mutable SmallVector<llvm::unique_function<bool(StringRef)>, 4>
551 BeforeCallbacks;
552 mutable SmallVector<
553 llvm::unique_function<void(StringRef, MachineFunctionPassManager &)>, 4>
554 AfterCallbacks;
555
556 /// Helper variable for `-start-before/-start-after/-stop-before/-stop-after`
557 mutable bool Started = true;
558 mutable bool Stopped = true;
559 mutable bool AddInCGSCCOrder = false;
560};
561
562template <typename Derived, typename TargetMachineT>
565 CodeGenFileType FileType) const {
566 auto StartStopInfo = TargetPassConfig::getStartStopInfo(*PIC);
567 if (!StartStopInfo)
568 return StartStopInfo.takeError();
569 setStartStopPasses(*StartStopInfo);
570
572 bool PrintMIR = !PrintAsm && FileType != CodeGenFileType::Null;
573
574 PassManagerWrapper PMW(MPM);
575
577 /*Force=*/true);
579 /*Force=*/true);
581 /*Force=*/true);
583 /*Force=*/true);
585 PMW,
586 /*Force=*/true);
587 addISelPasses(PMW);
588 flushFPMsToMPM(PMW);
589
590 if (PrintMIR)
591 addModulePass(PrintMIRPreparePass(Out), PMW, /*Force=*/true);
592
593 if (auto Err = addCoreISelPasses(PMW))
594 return std::move(Err);
595
596 if (auto Err = derived().addMachinePasses(PMW))
597 return std::move(Err);
598
599 if (!Opt.DisableVerify)
601
602 if (PrintAsm) {
603 derived().addAsmPrinter(
604 PMW, [this, &Out, DwoOut, FileType](MCContext &Ctx) {
605 return this->TM.createMCStreamer(Out, DwoOut, FileType, Ctx);
606 });
607 }
608
609 if (PrintMIR)
610 addMachineFunctionPass(PrintMIRPass(Out), PMW, /*Force=*/true);
611
612 flushFPMsToMPM(PMW, /*FreeMachineFunctions=*/true);
613
614 return verifyStartStop(*StartStopInfo);
615}
616
617template <typename Derived, typename TargetMachineT>
618void CodeGenPassBuilder<Derived, TargetMachineT>::setStartStopPasses(
619 const TargetPassConfig::StartStopInfo &Info) const {
620 if (!Info.StartPass.empty()) {
621 Started = false;
622 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StartAfter,
623 Count = 0u](StringRef ClassName) mutable {
624 if (Count == Info.StartInstanceNum) {
625 if (AfterFlag) {
626 AfterFlag = false;
627 Started = true;
628 }
629 return Started;
630 }
631
632 auto PassName = PIC->getPassNameForClassName(ClassName);
633 if (Info.StartPass == PassName && ++Count == Info.StartInstanceNum)
634 Started = !Info.StartAfter;
635
636 return Started;
637 });
638 }
639
640 if (!Info.StopPass.empty()) {
641 Stopped = false;
642 BeforeCallbacks.emplace_back([this, &Info, AfterFlag = Info.StopAfter,
643 Count = 0u](StringRef ClassName) mutable {
644 if (Count == Info.StopInstanceNum) {
645 if (AfterFlag) {
646 AfterFlag = false;
647 Stopped = true;
648 }
649 return !Stopped;
650 }
651
652 auto PassName = PIC->getPassNameForClassName(ClassName);
653 if (Info.StopPass == PassName && ++Count == Info.StopInstanceNum)
654 Stopped = !Info.StopAfter;
655 return !Stopped;
656 });
657 }
658}
659
660template <typename Derived, typename TargetMachineT>
661Error CodeGenPassBuilder<Derived, TargetMachineT>::verifyStartStop(
662 const TargetPassConfig::StartStopInfo &Info) const {
663 if (Started && Stopped)
664 return Error::success();
665
666 if (!Started)
668 "Can't find start pass \"" + Info.StartPass + "\".",
669 std::make_error_code(std::errc::invalid_argument));
670 if (!Stopped)
672 "Can't find stop pass \"" + Info.StopPass + "\".",
673 std::make_error_code(std::errc::invalid_argument));
674 return Error::success();
675}
676
677template <typename Derived, typename TargetMachineT>
679 PassManagerWrapper &PMW) const {
680 derived().addGlobalMergePass(PMW);
681 if (TM.useEmulatedTLS())
683
686
687 derived().addIRPasses(PMW);
688 derived().addCodeGenPrepare(PMW);
690 derived().addISelPrepare(PMW);
691}
692
693/// Add common target configurable passes that perform LLVM IR to IR transforms
694/// following machine independent optimization.
695template <typename Derived, typename TargetMachineT>
697 PassManagerWrapper &PMW) const {
698 // Before running any passes, run the verifier to determine if the input
699 // coming from the front-end and/or optimizer is valid.
700 if (!Opt.DisableVerify)
701 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
702
703 // Run loop strength reduction before anything else.
704 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableLSR) {
705 // These passes do not use MSSA.
706 LoopPassManager LPM;
707 LPM.addPass(CanonicalizeFreezeInLoopsPass());
708 LPM.addPass(LoopStrengthReducePass());
709 if (Opt.EnableLoopTermFold)
710 LPM.addPass(LoopTermFoldPass());
712 /*UseMemorySSA=*/false),
713 PMW);
714 }
715
717 // The MergeICmpsPass tries to create memcmp calls by grouping sequences of
718 // loads and compares. ExpandMemCmpPass then tries to expand those calls
719 // into optimally-sized loads and compares. The transforms are enabled by a
720 // target lowering hook.
721 if (!Opt.DisableMergeICmps)
724 }
725
726 // Run GC lowering passes for builtin collectors
727 // TODO: add a pass insertion point here
729 // Explicitly check to see if we should add ShadowStackGCLowering to avoid
730 // splitting the function pipeline if we do not have to.
731 if (runBeforeAdding(ShadowStackGCLoweringPass::name())) {
732 flushFPMsToMPM(PMW);
734 }
735
736 // Make sure that no unreachable blocks are instruction selected.
738
739 // Prepare expensive constants for SelectionDAG.
740 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableConstantHoisting)
742
743 // Replace calls to LLVM intrinsics (e.g., exp, log) operating on vector
744 // operands with calls to the corresponding functions in a vector library.
747
749 !Opt.DisablePartialLibcallInlining)
751
752 // Instrument function entry and exit, e.g. with calls to mcount().
753 addFunctionPass(EntryExitInstrumenterPass(/*PostInlining=*/true), PMW);
754
755 // Add scalarization of target's unsupported masked memory intrinsics pass.
756 // the unsupported intrinsic will be replaced with a chain of basic blocks,
757 // that stores/loads element one-by-one if the appropriate mask bit is set.
759
760 // Expand reduction intrinsics into shuffle sequences if the target wants to.
761 if (!Opt.DisableExpandReductions)
763
764 // Convert conditional moves to conditional jumps when profitable.
765 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
767
768 if (Opt.EnableGlobalMergeFunc) {
769 flushFPMsToMPM(PMW);
771 }
772}
773
774/// Turn exception handling constructs into something the code generators can
775/// handle.
776template <typename Derived, typename TargetMachineT>
778 PassManagerWrapper &PMW) const {
779 const MCAsmInfo *MCAI = TM.getMCAsmInfo();
780 assert(MCAI && "No MCAsmInfo");
781 switch (MCAI->getExceptionHandlingType()) {
783 // SjLj piggy-backs on dwarf for this bit. The cleanups done apply to both
784 // Dwarf EH prepare needs to be run after SjLj prepare. Otherwise,
785 // catch info can get misplaced when a selector ends up more than one block
786 // removed from the parent invoke(s). This could happen when a landing
787 // pad is shared by multiple invokes and is also a target of a normal
788 // edge from elsewhere.
790 [[fallthrough]];
796 break;
798 // We support using both GCC-style and MSVC-style exceptions on Windows, so
799 // add both preparation passes. Each pass will only actually run if it
800 // recognizes the personality function.
803 break;
805 // Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
806 // on catchpads and cleanuppads because it does not outline them into
807 // funclets. Catchswitch blocks are not lowered in SelectionDAG, so we
808 // should remove PHIs there.
809 addFunctionPass(WinEHPreparePass(/*DemoteCatchSwitchPHIOnly=*/false), PMW);
811 break;
814
815 // The lower invoke pass may create unreachable code. Remove it.
817 break;
818 }
819}
820
821/// Add pass to prepare the LLVM IR for code generation. This should be done
822/// before exception handling preparation passes.
823template <typename Derived, typename TargetMachineT>
825 PassManagerWrapper &PMW) const {
826 if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
828 // TODO: Default ctor'd RewriteSymbolPass is no-op.
829 // addPass(RewriteSymbolPass());
830}
831
832/// Add common passes that perform LLVM IR to IR transforms in preparation for
833/// instruction selection.
834template <typename Derived, typename TargetMachineT>
836 PassManagerWrapper &PMW) const {
837 derived().addPreISel(PMW);
838
839 if (Opt.RequiresCodeGenSCCOrder && !AddInCGSCCOrder)
841
844
846 // Add both the safe stack and the stack protection passes: each of them will
847 // only protect functions that have corresponding attributes.
850
851 if (Opt.PrintISelInput)
853 dbgs(), "\n\n*** Final LLVM Code input to ISel ***\n"),
854 PMW);
855
856 // All passes which modify the LLVM IR are now complete; run the verifier
857 // to ensure that the IR is valid.
858 if (!Opt.DisableVerify)
859 addFunctionPass(VerifierPass(), PMW, /*Force=*/true);
860}
861
862template <typename Derived, typename TargetMachineT>
864 PassManagerWrapper &PMW) const {
865 // Enable FastISel with -fast-isel, but allow that to be overridden.
866 TM.setO0WantsFastISel(Opt.EnableFastISelOption.value_or(true));
867
868 // Determine an instruction selector.
869 enum class SelectorType { SelectionDAG, FastISel, GlobalISel };
870 SelectorType Selector;
871
872 if (Opt.EnableFastISelOption && *Opt.EnableFastISelOption == true)
873 Selector = SelectorType::FastISel;
874 else if ((Opt.EnableGlobalISelOption &&
875 *Opt.EnableGlobalISelOption == true) ||
876 (TM.Options.EnableGlobalISel &&
877 (!Opt.EnableGlobalISelOption ||
878 *Opt.EnableGlobalISelOption == false)))
879 Selector = SelectorType::GlobalISel;
880 else if (TM.getOptLevel() == CodeGenOptLevel::None && TM.getO0WantsFastISel())
881 Selector = SelectorType::FastISel;
882 else
883 Selector = SelectorType::SelectionDAG;
884
885 // Set consistently TM.Options.EnableFastISel and EnableGlobalISel.
886 if (Selector == SelectorType::FastISel) {
887 TM.setFastISel(true);
888 TM.setGlobalISel(false);
889 } else if (Selector == SelectorType::GlobalISel) {
890 TM.setFastISel(false);
891 TM.setGlobalISel(true);
892 }
893
894 // Add instruction selector passes.
895 if (Selector == SelectorType::GlobalISel) {
896 if (auto Err = derived().addIRTranslator(PMW))
897 return std::move(Err);
898
899 derived().addPreLegalizeMachineIR(PMW);
900
901 if (auto Err = derived().addLegalizeMachineIR(PMW))
902 return std::move(Err);
903
904 // Before running the register bank selector, ask the target if it
905 // wants to run some passes.
906 derived().addPreRegBankSelect(PMW);
907
908 if (auto Err = derived().addRegBankSelect(PMW))
909 return std::move(Err);
910
911 derived().addPreGlobalInstructionSelect(PMW);
912
913 if (auto Err = derived().addGlobalInstructionSelect(PMW))
914 return std::move(Err);
915
916 // Pass to reset the MachineFunction if the ISel failed.
918 ResetMachineFunctionPass(reportDiagnosticWhenGlobalISelFallback(),
920 PMW);
921
922 // Provide a fallback path when we do not want to abort on
923 // not-yet-supported input.
925 if (auto Err = derived().addInstSelector(PMW))
926 return std::move(Err);
927
928 } else if (auto Err = derived().addInstSelector(PMW))
929 return std::move(Err);
930
931 // Expand pseudo-instructions emitted by ISel. Don't run the verifier before
932 // FinalizeISel.
934
935 // // Print the instruction selected machine code...
936 // printAndVerify("After Instruction Selection");
937
938 return Error::success();
939}
940
941/// Add the complete set of target-independent postISel code generator passes.
942///
943/// This can be read as the standard order of major LLVM CodeGen stages. Stages
944/// with nontrivial configuration or multiple passes are broken out below in
945/// add%Stage routines.
946///
947/// Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be
948/// overriden by the Target. The addPre/Post methods with empty header
949/// implementations allow injecting target-specific fixups just before or after
950/// major stages. Additionally, targets have the flexibility to change pass
951/// order within a stage by overriding default implementation of add%Stage
952/// routines below. Each technique has maintainability tradeoffs because
953/// alternate pass orders are not well supported. addPre/Post works better if
954/// the target pass is easily tied to a common pass. But if it has subtle
955/// dependencies on multiple passes, the target should override the stage
956/// instead.
957template <typename Derived, typename TargetMachineT>
959 PassManagerWrapper &PMW) const {
960 // Add passes that optimize machine instructions in SSA form.
962 derived().addMachineSSAOptimization(PMW);
963 } else {
964 // If the target requests it, assign local variables to stack slots relative
965 // to one another and simplify frame index references where possible.
967 }
968
969 if (TM.Options.EnableIPRA) {
970 flushFPMsToMPM(PMW);
972 PMW, /*Force=*/true);
974 }
975 // Run pre-ra passes.
976 derived().addPreRegAlloc(PMW);
977
978 // Run register allocation and passes that are tightly coupled with it,
979 // including phi elimination and scheduling.
980 if (*Opt.OptimizeRegAlloc) {
981 derived().addOptimizedRegAlloc(PMW);
982 } else {
983 if (auto Err = derived().addFastRegAlloc(PMW))
984 return Err;
985 }
986
987 // Run post-ra passes.
988 derived().addPostRegAlloc(PMW);
989
992
993 // Insert prolog/epilog code. Eliminate abstract frame index references...
997 }
998
1000
1001 /// Add passes that optimize machine instructions after register allocation.
1003 derived().addMachineLateOptimization(PMW);
1004
1005 // Expand pseudo instructions before second scheduling pass.
1007
1008 // Run pre-sched2 passes.
1009 derived().addPreSched2(PMW);
1010
1011 if (Opt.EnableImplicitNullChecks)
1012 addMachineFunctionPass(ImplicitNullChecksPass(), PMW);
1013
1014 // Second pass scheduler.
1015 // Let Target optionally insert this pass by itself at some other
1016 // point.
1018 !TM.targetSchedulesPostRAScheduling()) {
1019 if (Opt.MISchedPostRA)
1021 else
1023 }
1024
1025 // GC
1026 derived().addGCPasses(PMW);
1027
1028 // Basic block placement.
1030 derived().addBlockPlacement(PMW);
1031
1032 // Insert before XRay Instrumentation.
1034
1037
1038 derived().addPreEmitPass(PMW);
1039
1040 if (TM.Options.EnableIPRA) {
1041 // Collect register usage information and produce a register mask of
1042 // clobbered registers, to be used to optimize call sites.
1044 // If -print-regusage is specified, print the collected register usage info.
1045 if (Opt.PrintRegUsage) {
1046 flushFPMsToMPM(PMW);
1048 }
1049 }
1050
1051 addMachineFunctionPass(FuncletLayoutPass(), PMW);
1052
1054 addMachineFunctionPass(StackMapLivenessPass(), PMW);
1057 getTM<TargetMachine>().Options.ShouldEmitDebugEntryValues()),
1058 PMW);
1060
1061 if (TM.Options.EnableMachineOutliner &&
1063 Opt.EnableMachineOutliner != RunOutliner::NeverOutline) {
1064 if (Opt.EnableMachineOutliner != RunOutliner::TargetDefault ||
1065 TM.Options.SupportsDefaultOutlining) {
1066 flushFPMsToMPM(PMW);
1067 addModulePass(MachineOutlinerPass(Opt.EnableMachineOutliner), PMW);
1068 }
1069 }
1070
1071 derived().addPostBBSections(PMW);
1072
1074
1075 // Add passes that directly emit MI after all other MI passes.
1076 derived().addPreEmitPass2(PMW);
1077
1078 return Error::success();
1079}
1080
1081/// Add passes that optimize machine instructions in SSA form.
1082template <typename Derived, typename TargetMachineT>
1084 PassManagerWrapper &PMW) const {
1085 // Pre-ra tail duplication.
1087
1088 // Optimize PHIs before DCE: removing dead PHI cycles may make more
1089 // instructions dead.
1091
1092 // This pass merges large allocas. StackSlotColoring is a different pass
1093 // which merges spill slots.
1095
1096 // If the target requests it, assign local variables to stack slots relative
1097 // to one another and simplify frame index references where possible.
1099
1100 // With optimization, dead code should already be eliminated. However
1101 // there is one known exception: lowered code for arguments that are only
1102 // used by tail calls, where the tail calls reuse the incoming stack
1103 // arguments directly (see t11 in test/CodeGen/X86/sibcall.ll).
1105
1106 // Allow targets to insert passes that improve instruction level parallelism,
1107 // like if-conversion. Such passes will typically need dominator trees and
1108 // loop info, just like LICM and CSE below.
1109 derived().addILPOpts(PMW);
1110
1113
1114 addMachineFunctionPass(MachineSinkingPass(Opt.EnableSinkAndFold), PMW);
1115
1117 // Clean-up the dead code that may have been generated by peephole
1118 // rewriting.
1120}
1121
1122//===---------------------------------------------------------------------===//
1123/// Register Allocation Pass Configuration
1124//===---------------------------------------------------------------------===//
1125
1126/// Instantiate the default register allocator pass for this target for either
1127/// the optimized or unoptimized allocation path. This will be added to the pass
1128/// manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc
1129/// in the optimized case.
1130///
1131/// A target that uses the standard regalloc pass order for fast or optimized
1132/// allocation may still override this for per-target regalloc
1133/// selection. But -regalloc-npm=... always takes precedence.
1134/// If a target does not want to allow users to set -regalloc-npm=... at all,
1135/// check if Opt.RegAlloc == RegAllocType::Unset.
1136template <typename Derived, typename TargetMachineT>
1138 PassManagerWrapper &PMW, bool Optimized) const {
1139 if (Optimized)
1141 else
1143}
1144
1145/// Find and instantiate the register allocation pass requested by this target
1146/// at the current optimization level. Different register allocators are
1147/// defined as separate passes because they may require different analysis.
1148///
1149/// This helper ensures that the -regalloc-npm= option is always available,
1150/// even for targets that override the default allocator.
1151template <typename Derived, typename TargetMachineT>
1153 PassManagerWrapper &PMW, bool Optimized) const {
1154 // Use the specified -regalloc-npm={basic|greedy|fast|pbqp}
1155 if (Opt.RegAlloc > RegAllocType::Default) {
1156 switch (Opt.RegAlloc) {
1157 case RegAllocType::Fast:
1159 break;
1162 break;
1163 default:
1164 reportFatalUsageError("register allocator not supported yet");
1165 }
1166 return;
1167 }
1168 // -regalloc=default or unspecified, so pick based on the optimization level
1169 // or ask the target for the regalloc pass.
1170 derived().addTargetRegisterAllocator(PMW, Optimized);
1171}
1172
1173template <typename Derived, typename TargetMachineT>
1175 PassManagerWrapper &PMW) const {
1176 // TODO: Ensure allocator is default or fast.
1177 addRegAllocPass(PMW, false);
1178 return Error::success();
1179}
1180
1181template <typename Derived, typename TargetMachineT>
1183 PassManagerWrapper &PMW) const {
1184 // Add the selected register allocation pass.
1185 addRegAllocPass(PMW, true);
1186
1187 // Allow targets to change the register assignments before rewriting.
1188 derived().addPreRewrite(PMW);
1189
1190 // Finally rewrite virtual registers.
1192 // Perform stack slot coloring and post-ra machine LICM.
1193 //
1194 // FIXME: Re-enable coloring with register when it's capable of adding
1195 // kill markers.
1197
1198 return Error::success();
1199}
1200
1201/// Add the minimum set of target-independent passes that are required for
1202/// register allocation. No coalescing or scheduling.
1203template <typename Derived, typename TargetMachineT>
1210
1211/// Add standard target-independent passes that are tightly coupled with
1212/// optimized register allocation, including coalescing, machine instruction
1213/// scheduling, and register allocation itself.
1214template <typename Derived, typename TargetMachineT>
1216 PassManagerWrapper &PMW) const {
1218
1220
1222
1223 // LiveVariables currently requires pure SSA form.
1224 //
1225 // FIXME: Once TwoAddressInstruction pass no longer uses kill flags,
1226 // LiveVariables can be removed completely, and LiveIntervals can be directly
1227 // computed. (We still either need to regenerate kill flags after regalloc, or
1228 // preferably fix the scavenger to not depend on them).
1229 // FIXME: UnreachableMachineBlockElim is a dependant pass of LiveVariables.
1230 // When LiveVariables is removed this has to be removed/moved either.
1231 // Explicit addition of UnreachableMachineBlockElim allows stopping before or
1232 // after it with -stop-before/-stop-after.
1236
1237 // Edge splitting is smarter with machine loop info.
1241
1242 // Eventually, we want to run LiveIntervals before PHI elimination.
1243 if (Opt.EarlyLiveIntervals)
1246
1249
1250 // The machine scheduler may accidentally create disconnected components
1251 // when moving subregister definitions around, avoid this by splitting them to
1252 // separate vregs before. Splitting can also improve reg. allocation quality.
1254
1255 // PreRA instruction scheduling.
1257
1258 if (auto E = derived().addRegAssignmentOptimized(PMW)) {
1259 // addRegAssignmentOptimized did not add a reg alloc pass, so do nothing.
1260 return;
1261 }
1262
1264
1265 // Allow targets to expand pseudo instructions depending on the choice of
1266 // registers before MachineCopyPropagation.
1267 derived().addPostRewrite(PMW);
1268
1269 // Copy propagate to forward register uses and try to eliminate COPYs that
1270 // were not coalesced.
1272
1273 // Run post-ra machine LICM to hoist reloads / remats.
1274 //
1275 // FIXME: can this move into MachineLateOptimization?
1277}
1278
1279//===---------------------------------------------------------------------===//
1280/// Post RegAlloc Pass Configuration
1281//===---------------------------------------------------------------------===//
1282
1283/// Add passes that optimize machine instructions after register allocation.
1284template <typename Derived, typename TargetMachineT>
1286 PassManagerWrapper &PMW) const {
1287 // Cleanup of redundant (identical) address/immediate loads.
1289
1290 // Branch folding must be run after regalloc and prolog/epilog insertion.
1291 addMachineFunctionPass(BranchFolderPass(Opt.EnableTailMerge), PMW);
1292
1293 // Tail duplication.
1294 // Note that duplicating tail just increases code size and degrades
1295 // performance for targets that require Structured Control Flow.
1296 // In addition it can also make CFG irreducible. Thus we disable it.
1297 if (!TM.requiresStructuredCFG())
1299
1300 // Copy propagation.
1302}
1303
1304/// Add standard basic block placement passes.
1305template <typename Derived, typename TargetMachineT>
1307 PassManagerWrapper &PMW) const {
1309 // Run a separate pass to collect block placement statistics.
1310 if (Opt.EnableBlockPlacementStats)
1312}
1313
1314} // namespace llvm
1315
1316#endif // LLVM_PASSES_CODEGENPASSBUILDER_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This is the interface for LLVM's primary stateless and local alias analysis.
This header provides classes for managing passes over SCCs of the call graph.
Defines an IR pass for CodeGen Prepare.
Analysis that tracks defined/used subregister lanes across COPY instructions and instructions that ge...
This file defines passes to print out IR in various granularities.
This header defines various interfaces for pass management in LLVM.
This file contains the declaration of the InterleavedAccessPass class, its corresponding pass name is...
static LVOptions Options
Definition LVOptions.cpp:25
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
if(PassOpts->AAPipeline)
PassInstrumentationCallbacks PIC
This pass is required to take advantage of the interprocedural register allocation infrastructure.
This is the interface for a metadata-based scoped no-alias analysis.
This file contains the declaration of the SelectOptimizePass class, its corresponding pass name is se...
This file defines the SmallVector class.
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.
static const char PassName[]
A pass that canonicalizes freeze instructions in a loop.
void addPostRegAlloc(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes after register allocation pass pipe...
void addGlobalMergePass(PassManagerWrapper &PMW) const
Target can override this to add GlobalMergePass before all IR passes.
void addModulePass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const
decltype(std::declval< PassT & >().run( std::declval< Function & >(), std::declval< FunctionAnalysisManager & >())) is_function_pass_t
void flushFPMsToMPM(PassManagerWrapper &PMW, bool FreeMachineFunctions=false) const
void addPreGlobalInstructionSelect(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before the (global) ins...
Error addRegAssignmentFast(PassManagerWrapper &PMW) const
Add core register alloator passes which do the actual register assignment and rewriting.
void requireCGSCCOrder(PassManagerWrapper &PMW) const
void addISelPrepare(PassManagerWrapper &PMW) const
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
void addTargetRegisterAllocator(PassManagerWrapper &PMW, bool Optimized) const
Utilities for targets to add passes to the pass manager.
bool isGlobalISelAbortEnabled() const
Check whether or not GlobalISel should abort on error.
Error addMachinePasses(PassManagerWrapper &PMW) const
Add the complete, standard set of LLVM CodeGen passes.
Error addRegAssignmentOptimized(PassManagerWrapper &PMWM) const
void insertPass(InsertedPassT &&Pass) const
Insert InsertedPass pass after TargetPass pass.
void addPreRewrite(PassManagerWrapper &PMW) const
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is...
Error addFastRegAlloc(PassManagerWrapper &PMW) const
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
Error buildPipeline(ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType) const
void addPreISel(PassManagerWrapper &PMW) const
{{@ For GlobalISel
Error addCoreISelPasses(PassManagerWrapper &PMW) const
Add the actual instruction selection passes.
void stopAddingInCGSCCOrder(PassManagerWrapper &PMW) const
std::function< Expected< std::unique_ptr< MCStreamer > >(MCContext &)> CreateMCStreamer
void addPreLegalizeMachineIR(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before legalization.
void addCodeGenPrepare(PassManagerWrapper &PMW) const
Add pass to prepare the LLVM IR for code generation.
void addPreEmitPass(PassManagerWrapper &PMW) const
This pass may be implemented by targets that want to run passes immediately before machine code is em...
void addMachineSSAOptimization(PassManagerWrapper &PMW) const
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
void addIRPasses(PassManagerWrapper &PMW) const
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
decltype(std::declval< PassT & >().run( std::declval< MachineFunction & >(), std::declval< MachineFunctionAnalysisManager & >())) is_machine_function_pass_t
void addMachineLateOptimization(PassManagerWrapper &PMW) const
Add passes that optimize machine instructions after register allocation.
Error addLegalizeMachineIR(PassManagerWrapper &PMW) const
This method should install a legalize pass, which converts the instruction sequence into one that can...
CodeGenPassBuilder(TargetMachineT &TM, const CGPassBuilderOption &Opts, PassInstrumentationCallbacks *PIC)
void addPreEmitPass2(PassManagerWrapper &PMW) const
Targets may add passes immediately before machine code is emitted in this callback.
void addOptimizedRegAlloc(PassManagerWrapper &PMW) const
addOptimizedRegAlloc - Add passes related to register allocation.
Error addIRTranslator(PassManagerWrapper &PMW) const
This method should install an IR translator pass, which converts from LLVM code to machine instructio...
void addGCPasses(PassManagerWrapper &PMW) const
addGCPasses - Add late codegen passes that analyze code for garbage collection.
void addRegAllocPass(PassManagerWrapper &PMW, bool Optimized) const
addMachinePasses helper to create the target-selected or overriden regalloc pass.
Error addRegBankSelect(PassManagerWrapper &PMW) const
This method should install a register bank selector pass, which assigns register banks to virtual reg...
void addMachineFunctionPass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const
void addISelPasses(PassManagerWrapper &PMW) const
High level function that adds all passes necessary to go from llvm IR representation to the MI repres...
void disablePass()
Allow the target to disable a specific pass by default.
Error addInstSelector(PassManagerWrapper &PMW) const
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
void addPreRegAlloc(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before register allocat...
void addPassesToHandleExceptions(PassManagerWrapper &PMW) const
Add passes to lower exception handling for the code generator.
void addBlockPlacement(PassManagerWrapper &PMW) const
Add standard basic block placement passes.
void addPreRegBankSelect(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes immediately before the register ban...
void addPreSched2(PassManagerWrapper &PMW) const
This method may be implemented by targets that want to run passes after prolog-epilog insertion and b...
Error addGlobalInstructionSelect(PassManagerWrapper &PMWM) const
This method should install a (global) instruction selector pass, which converts possibly generic inst...
void addFunctionPass(PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const
void addILPOpts(PassManagerWrapper &PMW) const
Add passes that optimize instruction level parallelism for out-of-order targets.
decltype(std::declval< PassT & >().run( std::declval< Module & >(), std::declval< ModuleAnalysisManager & >())) is_module_pass_t
void addPostBBSections(PassManagerWrapper &PMW) const
void addPostRewrite(PassManagerWrapper &PMW) const
Add passes to be run immediately after virtual registers are rewritten to physical registers.
void addAsmPrinter(PassManagerWrapper &PMW, CreateMCStreamer) const
PassInstrumentationCallbacks * getPassInstrumentationCallbacks() const
bool reportDiagnosticWhenGlobalISelFallback() const
Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition FastISel.h:66
LowerIntrinsics - This pass rewrites calls to the llvm.gcread or llvm.gcwrite intrinsics,...
Definition GCMetadata.h:229
Performs Loop Strength Reduce Pass.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:64
ExceptionHandling getExceptionHandlingType() const
Definition MCAsmInfo.h:637
Context object for machine code objects.
Definition MCContext.h:83
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
LLVM_ABI StringRef getPassNameForClassName(StringRef ClassName)
Get the pass name for a given pass class name. Empty if no match found.
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
bool isEmpty() const
Returns if the pass manager contains any passes.
Pass interface - Implemented by all 'passes'.
Definition Pass.h:99
Pass (for the new pass manager) for printing a Function as LLVM's text IR assembly.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
static Expected< StartStopInfo > getStartStopInfo(PassInstrumentationCallbacks &PIC)
Returns pass name in -stop-before or -stop-after NOTE: New pass manager migration only.
static bool willCompleteCodeGenPipeline()
Returns true if none of the -stop-before and -stop-after options is set.
Create a verifier pass.
Definition Verifier.h:134
An abstract base class for streams implementations that also support a pwrite operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
@ SjLj
setjmp/longjmp based exceptions
Definition CodeGen.h:56
@ ZOS
z/OS MVS Exception Handling.
Definition CodeGen.h:61
@ None
No exception support.
Definition CodeGen.h:54
@ AIX
AIX Exception Handling.
Definition CodeGen.h:60
@ DwarfCFI
DWARF-like instruction based exceptions.
Definition CodeGen.h:55
@ WinEH
Windows Exception Handling.
Definition CodeGen.h:58
@ Wasm
WebAssembly Exception Handling.
Definition CodeGen.h:59
PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & > LoopPassManager
The Loop pass manager.
ModuleToPostOrderCGSCCPassAdaptor createModuleToPostOrderCGSCCPassAdaptor(CGSCCPassT &&Pass)
A function to deduce a function pass type and wrap it in the templated adaptor.
FunctionToLoopPassAdaptor createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:111
FunctionToMachineFunctionPassAdaptor createFunctionToMachineFunctionPassAdaptor(MachineFunctionPassT &&Pass)
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
PassManager< MachineFunction > MachineFunctionPassManager
Convenience typedef for a pass manager over functions.
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
Global function merging pass for new pass manager.
A utility pass template to force an analysis result to be available.