LLVM 23.0.0git
MachineFunction.h
Go to the documentation of this file.
1//===- llvm/CodeGen/MachineFunction.h ---------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Collect native machine code for a function. This class contains a list of
10// MachineBasicBlock instances that make up the current compiled function.
11//
12// This class also contains pointers to various classes which hold
13// target-specific information about the generated code.
14//
15//===----------------------------------------------------------------------===//
16
17#ifndef LLVM_CODEGEN_MACHINEFUNCTION_H
18#define LLVM_CODEGEN_MACHINEFUNCTION_H
19
20#include "llvm/ADT/ArrayRef.h"
21#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/ilist.h"
25#include "llvm/ADT/iterator.h"
37#include <bitset>
38#include <cassert>
39#include <cstdint>
40#include <memory>
41#include <utility>
42#include <variant>
43#include <vector>
44
45namespace llvm {
46
47class BasicBlock;
48class BlockAddress;
49class DataLayout;
50class DebugLoc;
51struct DenormalMode;
52class DIExpression;
53class DILocalVariable;
54class DILocation;
55class Function;
57class GlobalValue;
58class TargetMachine;
61class MachineFunction;
64class MCContext;
65class MCInstrDesc;
66class MCSymbol;
67class MCSection;
68class Pass;
70class raw_ostream;
71class SlotIndexes;
72class StringRef;
75struct WasmEHFuncInfo;
76struct WinEHFuncInfo;
77
81
85
86 template <class Iterator>
87 void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator) {
88 assert(this == &OldList && "never transfer MBBs between functions");
89 }
90};
91
92// The hotness of static data tracked by a MachineFunction and not represented
93// as a global object in the module IR / MIR. Typical examples are
94// MachineJumpTableInfo and MachineConstantPool.
100
101/// MachineFunctionInfo - This class can be derived from and used by targets to
102/// hold private target-specific information for each MachineFunction. Objects
103/// of type are accessed/created with MF::getInfo and destroyed when the
104/// MachineFunction is destroyed.
107
108 /// Factory function: default behavior is to call new using the
109 /// supplied allocator.
110 ///
111 /// This function can be overridden in a derive class.
112 template <typename FuncInfoTy, typename SubtargetTy = TargetSubtargetInfo>
113 static FuncInfoTy *create(BumpPtrAllocator &Allocator, const Function &F,
114 const SubtargetTy *STI) {
115 return new (Allocator.Allocate<FuncInfoTy>()) FuncInfoTy(F, STI);
116 }
117
118 template <typename Ty>
119 static Ty *create(BumpPtrAllocator &Allocator, const Ty &MFI) {
120 return new (Allocator.Allocate<Ty>()) Ty(MFI);
121 }
122
123 /// Make a functionally equivalent copy of this MachineFunctionInfo in \p MF.
124 /// This requires remapping MachineBasicBlock references from the original
125 /// parent to values in the new function. Targets may assume that virtual
126 /// register and frame index values are preserved in the new function.
127 virtual MachineFunctionInfo *
130 const {
131 return nullptr;
132 }
133};
134
135/// Properties which a MachineFunction may have at a given point in time.
136/// Each of these has checking code in the MachineVerifier, and passes can
137/// require that a property be set.
139 // Possible TODO: Allow targets to extend this (perhaps by allowing the
140 // constructor to specify the size of the bit vector)
141 // Possible TODO: Allow requiring the negative (e.g. VRegsAllocated could be
142 // stated as the negative of "has vregs"
143
144public:
145 // The properties are stated in "positive" form; i.e. a pass could require
146 // that the property hold, but not that it does not hold.
147
148 // Property descriptions:
149 // IsSSA: True when the machine function is in SSA form and virtual registers
150 // have a single def.
151 // NoPHIs: The machine function does not contain any PHI instruction.
152 // TracksLiveness: True when tracking register liveness accurately.
153 // While this property is set, register liveness information in basic block
154 // live-in lists and machine instruction operands (e.g. implicit defs) is
155 // accurate, kill flags are conservatively accurate (kill flag correctly
156 // indicates the last use of a register, an operand without kill flag may or
157 // may not be the last use of a register). This means it can be used to
158 // change the code in ways that affect the values in registers, for example
159 // by the register scavenger.
160 // When this property is cleared at a very late time, liveness is no longer
161 // reliable.
162 // NoVRegs: The machine function does not use any virtual registers.
163 // Legalized: In GlobalISel: the MachineLegalizer ran and all pre-isel generic
164 // instructions have been legalized; i.e., all instructions are now one of:
165 // - generic and always legal (e.g., COPY)
166 // - target-specific
167 // - legal pre-isel generic instructions.
168 // RegBankSelected: In GlobalISel: the RegBankSelect pass ran and all generic
169 // virtual registers have been assigned to a register bank.
170 // Selected: In GlobalISel: the InstructionSelect pass ran and all pre-isel
171 // generic instructions have been eliminated; i.e., all instructions are now
172 // target-specific or non-pre-isel generic instructions (e.g., COPY).
173 // Since only pre-isel generic instructions can have generic virtual register
174 // operands, this also means that all generic virtual registers have been
175 // constrained to virtual registers (assigned to register classes) and that
176 // all sizes attached to them have been eliminated.
177 // TiedOpsRewritten: The twoaddressinstruction pass will set this flag, it
178 // means that tied-def have been rewritten to meet the RegConstraint.
179 // FailsVerification: Means that the function is not expected to pass machine
180 // verification. This can be set by passes that introduce known problems that
181 // have not been fixed yet.
182 // TracksDebugUserValues: Without this property enabled, debug instructions
183 // such as DBG_VALUE are allowed to reference virtual registers even if those
184 // registers do not have a definition. With the property enabled virtual
185 // registers must only be used if they have a definition. This property
186 // allows earlier passes in the pipeline to skip updates of `DBG_VALUE`
187 // instructions to save compile time.
203
204 bool hasProperty(Property P) const {
205 return Properties[static_cast<unsigned>(P)];
206 }
207
209 Properties.set(static_cast<unsigned>(P));
210 return *this;
211 }
212
214 Properties.reset(static_cast<unsigned>(P));
215 return *this;
216 }
217
218 // Per property has/set/reset accessors.
219#define PPACCESSORS(X) \
220 bool has##X() const { return hasProperty(Property::X); } \
221 MachineFunctionProperties &set##X(void) { return set(Property::X); } \
222 MachineFunctionProperties &reset##X(void) { return reset(Property::X); }
223
236
237 /// Reset all the properties.
239 Properties.reset();
240 return *this;
241 }
242
243 /// Reset all properties and re-establish baseline invariants.
245 reset();
246 setIsSSA();
247 setTracksLiveness();
248 return *this;
249 }
250
252 Properties |= MFP.Properties;
253 return *this;
254 }
255
257 Properties &= ~MFP.Properties;
258 return *this;
259 }
260
261 // Returns true if all properties set in V (i.e. required by a pass) are set
262 // in this.
264 return (Properties | ~V.Properties).all();
265 }
266
267 /// Print the MachineFunctionProperties in human-readable form.
268 LLVM_ABI void print(raw_ostream &OS) const;
269
270private:
271 std::bitset<static_cast<unsigned>(Property::LastProperty) + 1> Properties;
272};
273
275 /// Filter or finally function. Null indicates a catch-all.
277
278 /// Address of block to recover at. Null for a finally handler.
280};
281
282/// This structure is used to retain landing pad info for the current function.
284 MachineBasicBlock *LandingPadBlock; // Landing pad block.
285 SmallVector<MCSymbol *, 1> BeginLabels; // Labels prior to invoke.
286 SmallVector<MCSymbol *, 1> EndLabels; // Labels after invoke.
287 SmallVector<SEHHandler, 1> SEHHandlers; // SEH handlers active at this lpad.
288 MCSymbol *LandingPadLabel = nullptr; // Label at beginning of landing pad.
289 std::vector<int> TypeIds; // List of type ids (filters negative).
290
293};
294
296 Function &F;
297 const TargetMachine &Target;
298 const TargetSubtargetInfo &STI;
299 MCContext &Ctx;
300
301 // RegInfo - Information about each register in use in the function.
302 MachineRegisterInfo *RegInfo;
303
304 // Used to keep track of target-specific per-machine-function information for
305 // the target implementation.
306 MachineFunctionInfo *MFInfo;
307
308 // Keep track of objects allocated on the stack.
309 MachineFrameInfo *FrameInfo;
310
311 // Keep track of constants which are spilled to memory
312 MachineConstantPool *ConstantPool;
313
314 // Keep track of jump tables for switch instructions
315 MachineJumpTableInfo *JumpTableInfo;
316
317 // Keep track of the function section.
318 MCSection *Section = nullptr;
319
320 // Catchpad unwind destination info for wasm EH.
321 // Keeps track of Wasm exception handling related data. This will be null for
322 // functions that aren't using a wasm EH personality.
323 WasmEHFuncInfo *WasmEHInfo = nullptr;
324
325 // Keeps track of Windows exception handling related data. This will be null
326 // for functions that aren't using a funclet-based EH personality.
327 WinEHFuncInfo *WinEHInfo = nullptr;
328
329 // Function-level unique numbering for MachineBasicBlocks. When a
330 // MachineBasicBlock is inserted into a MachineFunction is it automatically
331 // numbered and this vector keeps track of the mapping from ID's to MBB's.
332 std::vector<MachineBasicBlock*> MBBNumbering;
333
334 // Analysis number epoch, currently never changed as we don't renumber the
335 // block numbers used for analyses.
336 unsigned AnalysisNumberingEpoch = 0;
337
338 // Next MBB analysis number.
339 unsigned NextAnalysisNumber = 0;
340
341 // Pool-allocate MachineFunction-lifetime and IR objects.
342 BumpPtrAllocator Allocator;
343
344 // Allocation management for instructions in function.
345 Recycler<MachineInstr> InstructionRecycler;
346
347 // Allocation management for operand arrays on instructions.
348 ArrayRecycler<MachineOperand> OperandRecycler;
349
350 // Allocation management for basic blocks in function.
351 Recycler<MachineBasicBlock> BasicBlockRecycler;
352
353 // List of machine basic blocks in function
354 using BasicBlockListType = ilist<MachineBasicBlock>;
355 BasicBlockListType BasicBlocks;
356
357 /// FunctionNumber - This provides a unique ID for each function emitted in
358 /// this translation unit.
359 ///
360 unsigned FunctionNumber;
361
362 /// Alignment - The alignment of the function.
363 Align Alignment;
364
365 /// ExposesReturnsTwice - True if the function calls setjmp or related
366 /// functions with attribute "returns twice", but doesn't have
367 /// the attribute itself.
368 /// This is used to limit optimizations which cannot reason
369 /// about the control flow of such functions.
370 bool ExposesReturnsTwice = false;
371
372 /// True if the function includes any inline assembly.
373 bool HasInlineAsm = false;
374
375 /// True if any WinCFI instruction have been emitted in this function.
376 bool HasWinCFI = false;
377
378 /// Current high-level properties of the IR of the function (e.g. is in SSA
379 /// form or whether registers have been allocated)
380 MachineFunctionProperties Properties;
381
382 // Allocation management for pseudo source values.
383 std::unique_ptr<PseudoSourceValueManager> PSVManager;
384
385 /// List of moves done by a function's prolog. Used to construct frame maps
386 /// by debug and exception handling consumers.
387 std::vector<MCCFIInstruction> FrameInstructions;
388
389 /// List of basic blocks immediately following calls to _setjmp. Used to
390 /// construct a table of valid longjmp targets for Windows Control Flow Guard.
391 std::vector<MCSymbol *> LongjmpTargets;
392
393 /// List of basic blocks that are the targets for Windows EH Continuation
394 /// Guard.
395 std::vector<MCSymbol *> EHContTargets;
396
397 /// \name Exception Handling
398 /// \{
399
400 /// List of LandingPadInfo describing the landing pad information.
401 std::vector<LandingPadInfo> LandingPads;
402
403 /// Map a landing pad's EH symbol to the call site indexes.
405
406 /// Map a landing pad to its index.
408
409 /// Map of invoke call site index values to associated begin EH_LABEL.
411
412 /// CodeView label annotations.
413 std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations;
414
415 bool CallsEHReturn = false;
416 bool CallsUnwindInit = false;
417 bool HasEHContTarget = false;
418 bool HasEHScopes = false;
419 bool HasEHFunclets = false;
420 bool HasFakeUses = false;
421 bool IsOutlined = false;
422
423 /// BBID to assign to the next basic block of this function.
424 unsigned NextBBID = 0;
425
426 /// Section Type for basic blocks, only relevant with basic block sections.
428
429 /// Prefetch targets in this function. This includes targets that are mapped
430 /// to a basic block and dangling targets.
432
433 /// List of C++ TypeInfo used.
434 std::vector<const GlobalValue *> TypeInfos;
435
436 /// List of typeids encoding filters used.
437 std::vector<unsigned> FilterIds;
438
439 /// List of the indices in FilterIds corresponding to filter terminators.
440 std::vector<unsigned> FilterEnds;
441
442 EHPersonality PersonalityTypeCache = EHPersonality::Unknown;
443
444 /// \}
445
446 /// Clear all the members of this MachineFunction, but the ones used to
447 /// initialize again the MachineFunction. More specifically, this deallocates
448 /// all the dynamically allocated objects and get rids of all the XXXInfo data
449 /// structure, but keeps unchanged the references to Fn, Target, and
450 /// FunctionNumber.
451 void clear();
452 /// Allocate and initialize the different members.
453 /// In particular, the XXXInfo data structure.
454 /// \pre Fn, Target, and FunctionNumber are properly set.
455 void init();
456
457public:
458 /// Description of the location of a variable whose Address is valid and
459 /// unchanging during function execution. The Address may be:
460 /// * A stack index, which can be negative for fixed stack objects.
461 /// * A MCRegister, whose entry value contains the address of the variable.
463 std::variant<int, MCRegister> Address;
464
465 public:
469
471 int Slot, const DILocation *Loc)
472 : Address(Slot), Var(Var), Expr(Expr), Loc(Loc) {}
473
475 MCRegister EntryValReg, const DILocation *Loc)
476 : Address(EntryValReg), Var(Var), Expr(Expr), Loc(Loc) {}
477
478 /// Return true if this variable is in a stack slot.
479 bool inStackSlot() const { return std::holds_alternative<int>(Address); }
480
481 /// Return true if this variable is in the entry value of a register.
482 bool inEntryValueRegister() const {
483 return std::holds_alternative<MCRegister>(Address);
484 }
485
486 /// Returns the stack slot of this variable, assuming `inStackSlot()` is
487 /// true.
488 int getStackSlot() const { return std::get<int>(Address); }
489
490 /// Returns the MCRegister of this variable, assuming
491 /// `inEntryValueRegister()` is true.
493 return std::get<MCRegister>(Address);
494 }
495
496 /// Updates the stack slot of this variable, assuming `inStackSlot()` is
497 /// true.
498 void updateStackSlot(int NewSlot) {
500 Address = NewSlot;
501 }
502 };
503
505 virtual void anchor();
506
507 public:
508 virtual ~Delegate() = default;
509 /// Callback after an insertion. This should not modify the MI directly.
511 /// Callback before a removal. This should not modify the MI directly.
512 virtual void MF_HandleRemoval(MachineInstr &MI) = 0;
513 /// Callback before changing MCInstrDesc. This should not modify the MI
514 /// directly.
515 virtual void MF_HandleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID) {
516 }
517 };
518
519 /// Structure used to represent pair of argument number after call lowering
520 /// and register used to transfer that argument.
521 /// For now we support only cases when argument is transferred through one
522 /// register.
523 struct ArgRegPair {
526 ArgRegPair(Register R, unsigned Arg) : Reg(R), ArgNo(Arg) {
527 assert(Arg < (1 << 16) && "Arg out of range");
528 }
529 };
530
532 /// Vector of call argument and its forwarding register.
534 /// Callee type ids.
536
537 /// 'call_target' metadata for the DISubprogram. It is the declaration
538 /// or definition of the target function and might be indirect.
539 MDNode *CallTarget = nullptr;
540
541 CallSiteInfo() = default;
542
543 /// Extracts the numeric type id from the CallBase's callee_type Metadata,
544 /// and sets CalleeTypeIds. This is used as type id for the indirect call in
545 /// the call graph section.
546 /// Extracts the MDNode from the CallBase's call_target Metadata to be used
547 /// during the construction of the debug info call site entries.
548 LLVM_ABI CallSiteInfo(const CallBase &CB);
549 };
550
553 unsigned TargetFlags;
554 };
555
557
558private:
559 Delegate *TheDelegate = nullptr;
560 GISelChangeObserver *Observer = nullptr;
561
562 /// Map a call instruction to call site arguments forwarding info.
563 CallSiteInfoMap CallSitesInfo;
564
565 /// A helper function that returns call site info for a give call
566 /// instruction if debug entry value support is enabled.
567 CallSiteInfoMap::iterator getCallSiteInfo(const MachineInstr *MI);
568
570 /// Mapping of call instruction to the global value and target flags that it
571 /// calls, if applicable.
572 CalledGlobalsMap CalledGlobalsInfo;
573
574 // Callbacks for insertion and removal.
575 void handleInsertion(MachineInstr &MI);
576 void handleRemoval(MachineInstr &MI);
577 friend struct ilist_traits<MachineInstr>;
578
579public:
580 // Need to be accessed from MachineInstr::setDesc.
581 void handleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID);
582
585
586 /// A count of how many instructions in the function have had numbers
587 /// assigned to them. Used for debug value tracking, to determine the
588 /// next instruction number.
590
591 /// Set value of DebugInstrNumberingCount field. Avoid using this unless
592 /// you're deserializing this data.
593 void setDebugInstrNumberingCount(unsigned Num);
594
595 /// Pair of instruction number and operand number.
596 using DebugInstrOperandPair = std::pair<unsigned, unsigned>;
597
598 /// Replacement definition for a debug instruction reference. Made up of a
599 /// source instruction / operand pair, destination pair, and a qualifying
600 /// subregister indicating what bits in the operand make up the substitution.
601 // For example, a debug user
602 /// of %1:
603 /// %0:gr32 = someinst, debug-instr-number 1
604 /// %1:gr16 = %0.some_16_bit_subreg, debug-instr-number 2
605 /// Would receive the substitution {{2, 0}, {1, 0}, $subreg}, where $subreg is
606 /// the subregister number for some_16_bit_subreg.
608 public:
609 DebugInstrOperandPair Src; ///< Source instruction / operand pair.
610 DebugInstrOperandPair Dest; ///< Replacement instruction / operand pair.
611 unsigned Subreg; ///< Qualifier for which part of Dest is read.
612
616
617 /// Order only by source instruction / operand pair: there should never
618 /// be duplicate entries for the same source in any collection.
619 bool operator<(const DebugSubstitution &Other) const {
620 return Src < Other.Src;
621 }
622 };
623
624 /// Debug value substitutions: a collection of DebugSubstitution objects,
625 /// recording changes in where a value is defined. For example, when one
626 /// instruction is substituted for another. Keeping a record allows recovery
627 /// of variable locations after compilation finishes.
629
630 /// Location of a PHI instruction that is also a debug-info variable value,
631 /// for the duration of register allocation. Loaded by the PHI-elimination
632 /// pass, and emitted as DBG_PHI instructions during VirtRegRewriter, with
633 /// maintenance applied by intermediate passes that edit registers (such as
634 /// coalescing and the allocator passes).
636 public:
637 MachineBasicBlock *MBB; ///< Block where this PHI was originally located.
638 Register Reg; ///< VReg where the control-flow-merge happens.
639 unsigned SubReg; ///< Optional subreg qualifier within Reg.
642 };
643
644 /// Map of debug instruction numbers to the position of their PHI instructions
645 /// during register allocation. See DebugPHIRegallocPos.
647
648 /// Flag for whether this function contains DBG_VALUEs (false) or
649 /// DBG_INSTR_REF (true).
650 bool UseDebugInstrRef = false;
651
652 /// Create a substitution between one <instr,operand> value to a different,
653 /// new value.
655 unsigned SubReg = 0);
656
657 /// Create substitutions for any tracked values in \p Old, to point at
658 /// \p New. Needed when we re-create an instruction during optimization,
659 /// which has the same signature (i.e., def operands in the same place) but
660 /// a modified instruction type, flags, or otherwise. An example: X86 moves
661 /// are sometimes transformed into equivalent LEAs.
662 /// If the two instructions are not the same opcode, limit which operands to
663 /// examine for substitutions to the first N operands by setting
664 /// \p MaxOperand.
666 unsigned MaxOperand = UINT_MAX);
667
668 /// Find the underlying defining instruction / operand for a COPY instruction
669 /// while in SSA form. Copies do not actually define values -- they move them
670 /// between registers. Labelling a COPY-like instruction with an instruction
671 /// number is to be avoided as it makes value numbers non-unique later in
672 /// compilation. This method follows the definition chain for any sequence of
673 /// COPY-like instructions to find whatever non-COPY-like instruction defines
674 /// the copied value; or for parameters, creates a DBG_PHI on entry.
675 /// May insert instructions into the entry block!
676 /// \p MI The copy-like instruction to salvage.
677 /// \p DbgPHICache A container to cache already-solved COPYs.
678 /// \returns An instruction/operand pair identifying the defining value.
682
684
685 /// Finalise any partially emitted debug instructions. These are DBG_INSTR_REF
686 /// instructions where we only knew the vreg of the value they use, not the
687 /// instruction that defines that vreg. Once isel finishes, we should have
688 /// enough information for every DBG_INSTR_REF to point at an instruction
689 /// (or DBG_PHI).
691
692 /// Determine whether, in the current machine configuration, we should use
693 /// instruction referencing or not.
694 bool shouldUseDebugInstrRef() const;
695
696 /// Returns true if the function's variable locations are tracked with
697 /// instruction referencing.
698 bool useDebugInstrRef() const;
699
700 /// Set whether this function will use instruction referencing or not.
701 void setUseDebugInstrRef(bool UseInstrRef);
702
703 /// A reserved operand number representing the instructions memory operand,
704 /// for instructions that have a stack spill fused into them.
705 const static unsigned int DebugOperandMemNumber;
706
707 MachineFunction(Function &F, const TargetMachine &Target,
708 const TargetSubtargetInfo &STI, MCContext &Ctx,
709 unsigned FunctionNum);
713
714 /// Reset the instance as if it was just created.
715 void reset() {
716 clear();
717 init();
718 }
719
720 /// Reset the currently registered delegate - otherwise assert.
721 void resetDelegate(Delegate *delegate) {
722 assert(TheDelegate == delegate &&
723 "Only the current delegate can perform reset!");
724 TheDelegate = nullptr;
725 }
726
727 /// Set the delegate. resetDelegate must be called before attempting
728 /// to set.
729 void setDelegate(Delegate *delegate) {
730 assert(delegate && !TheDelegate &&
731 "Attempted to set delegate to null, or to change it without "
732 "first resetting it!");
733
734 TheDelegate = delegate;
735 }
736
737 void setObserver(GISelChangeObserver *O) { Observer = O; }
738
739 GISelChangeObserver *getObserver() const { return Observer; }
740
741 MCContext &getContext() const { return Ctx; }
742
743 /// Returns the Section this function belongs to.
744 MCSection *getSection() const { return Section; }
745
746 /// Indicates the Section this function belongs to.
747 void setSection(MCSection *S) { Section = S; }
748
749 PseudoSourceValueManager &getPSVManager() const { return *PSVManager; }
750
751 /// Return the DataLayout attached to the Module associated to this MF.
752 const DataLayout &getDataLayout() const;
753
754 /// Return the LLVM function that this machine code represents
755 Function &getFunction() { return F; }
756
757 /// Return the LLVM function that this machine code represents
758 const Function &getFunction() const { return F; }
759
760 /// getName - Return the name of the corresponding LLVM function.
761 StringRef getName() const;
762
763 /// getFunctionNumber - Return a unique ID for the current function.
764 unsigned getFunctionNumber() const { return FunctionNumber; }
765
766 /// Returns true if this function has basic block sections enabled.
767 bool hasBBSections() const {
768 return (BBSectionsType == BasicBlockSection::All ||
769 BBSectionsType == BasicBlockSection::List ||
770 BBSectionsType == BasicBlockSection::Preset);
771 }
772
773 void setBBSectionsType(BasicBlockSection V) { BBSectionsType = V; }
774
775 void
777 PrefetchTargets = V;
778 }
779
782 return PrefetchTargets;
783 }
784
785 /// Assign IsBeginSection IsEndSection fields for basic blocks in this
786 /// function.
787 void assignBeginEndSections();
788
789 /// getTarget - Return the target machine this machine code is compiled with
790 const TargetMachine &getTarget() const { return Target; }
791
792 /// getSubtarget - Return the subtarget for which this machine code is being
793 /// compiled.
794 const TargetSubtargetInfo &getSubtarget() const { return STI; }
795
796 /// getSubtarget - This method returns a pointer to the specified type of
797 /// TargetSubtargetInfo. In debug builds, it verifies that the object being
798 /// returned is of the correct type.
799 template<typename STC> const STC &getSubtarget() const {
800 return static_cast<const STC &>(STI);
801 }
802
803 /// getRegInfo - Return information about the registers currently in use.
804 MachineRegisterInfo &getRegInfo() { return *RegInfo; }
805 const MachineRegisterInfo &getRegInfo() const { return *RegInfo; }
806
807 /// getFrameInfo - Return the frame info object for the current function.
808 /// This object contains information about objects allocated on the stack
809 /// frame of the current function in an abstract way.
810 MachineFrameInfo &getFrameInfo() { return *FrameInfo; }
811 const MachineFrameInfo &getFrameInfo() const { return *FrameInfo; }
812
813 /// getJumpTableInfo - Return the jump table info object for the current
814 /// function. This object contains information about jump tables in the
815 /// current function. If the current function has no jump tables, this will
816 /// return null.
817 const MachineJumpTableInfo *getJumpTableInfo() const { return JumpTableInfo; }
818 MachineJumpTableInfo *getJumpTableInfo() { return JumpTableInfo; }
819
820 /// getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it
821 /// does already exist, allocate one.
822 MachineJumpTableInfo *getOrCreateJumpTableInfo(unsigned JTEntryKind);
823
824 /// getConstantPool - Return the constant pool object for the current
825 /// function.
826 MachineConstantPool *getConstantPool() { return ConstantPool; }
827 const MachineConstantPool *getConstantPool() const { return ConstantPool; }
828
829 /// getWasmEHFuncInfo - Return information about how the current function uses
830 /// Wasm exception handling. Returns null for functions that don't use wasm
831 /// exception handling.
832 const WasmEHFuncInfo *getWasmEHFuncInfo() const { return WasmEHInfo; }
833 WasmEHFuncInfo *getWasmEHFuncInfo() { return WasmEHInfo; }
834
835 /// getWinEHFuncInfo - Return information about how the current function uses
836 /// Windows exception handling. Returns null for functions that don't use
837 /// funclets for exception handling.
838 const WinEHFuncInfo *getWinEHFuncInfo() const { return WinEHInfo; }
839 WinEHFuncInfo *getWinEHFuncInfo() { return WinEHInfo; }
840
841 /// getAlignment - Return the alignment of the function.
842 Align getAlignment() const { return Alignment; }
843
844 /// setAlignment - Set the alignment of the function.
845 void setAlignment(Align A) { Alignment = A; }
846
847 /// ensureAlignment - Make sure the function is at least A bytes aligned.
849 if (Alignment < A)
850 Alignment = A;
851 }
852
853 /// Returns the preferred alignment which comes from the function attributes
854 /// (optsize, minsize, prefalign) and TargetLowering.
855 Align getPreferredAlignment() const;
856
857 /// exposesReturnsTwice - Returns true if the function calls setjmp or
858 /// any other similar functions with attribute "returns twice" without
859 /// having the attribute itself.
860 bool exposesReturnsTwice() const {
861 return ExposesReturnsTwice;
862 }
863
864 /// setCallsSetJmp - Set a flag that indicates if there's a call to
865 /// a "returns twice" function.
867 ExposesReturnsTwice = B;
868 }
869
870 /// Returns true if the function contains any inline assembly.
871 bool hasInlineAsm() const {
872 return HasInlineAsm;
873 }
874
875 /// Set a flag that indicates that the function contains inline assembly.
876 void setHasInlineAsm(bool B) {
877 HasInlineAsm = B;
878 }
879
880 bool hasWinCFI() const {
881 return HasWinCFI;
882 }
883 void setHasWinCFI(bool v) { HasWinCFI = v; }
884
885 /// True if this function needs frame moves for debug or exceptions.
886 bool needsFrameMoves() const;
887
888 /// Get the function properties
889 const MachineFunctionProperties &getProperties() const { return Properties; }
890 MachineFunctionProperties &getProperties() { return Properties; }
891
892 /// getInfo - Keep track of various per-function pieces of information for
893 /// backends that would like to do so.
894 ///
895 template<typename Ty>
896 Ty *getInfo() {
897 return static_cast<Ty*>(MFInfo);
898 }
899
900 template<typename Ty>
901 const Ty *getInfo() const {
902 return static_cast<const Ty *>(MFInfo);
903 }
904
905 template <typename Ty> Ty *cloneInfo(const Ty &Old) {
906 assert(!MFInfo);
907 MFInfo = Ty::template create<Ty>(Allocator, Old);
908 return static_cast<Ty *>(MFInfo);
909 }
910
911 /// Initialize the target specific MachineFunctionInfo
912 void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI);
913
915 const MachineFunction &OrigMF,
917 assert(!MFInfo && "new function already has MachineFunctionInfo");
918 if (!OrigMF.MFInfo)
919 return nullptr;
920 return OrigMF.MFInfo->clone(Allocator, *this, Src2DstMBB);
921 }
922
923 /// Returns the denormal handling type for the default rounding mode of the
924 /// function.
925 DenormalMode getDenormalMode(const fltSemantics &FPType) const;
926
927 /// getBlockNumbered - MachineBasicBlocks are automatically numbered when they
928 /// are inserted into the machine function. The block number for a machine
929 /// basic block can be found by using the MBB::getNumber method, this method
930 /// provides the inverse mapping.
932 assert(N < MBBNumbering.size() && "Illegal block number");
933 assert(MBBNumbering[N] && "Block was removed from the machine function!");
934 return MBBNumbering[N];
935 }
936
937 /// Should we be emitting segmented stack stuff for the function
938 bool shouldSplitStack() const;
939
940 /// getNumBlockIDs - Return the number of MBB ID's allocated.
941 unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); }
942
943 /// Return the numbering "epoch" of analysis block numbers.
945 return AnalysisNumberingEpoch;
946 }
947
948 unsigned assignAnalysisNumber() { return NextAnalysisNumber++; }
949
950 unsigned getMaxAnalysisBlockNumber() const { return NextAnalysisNumber; }
951
952 /// RenumberBlocks - This discards all of the MachineBasicBlock numbers and
953 /// recomputes them. This guarantees that the MBB numbers are sequential,
954 /// dense, and match the ordering of the blocks within the function. If a
955 /// specific MachineBasicBlock is specified, only that block and those after
956 /// it are renumbered.
957 void RenumberBlocks(MachineBasicBlock *MBBFrom = nullptr);
958
959 /// Return an estimate of the function's code size,
960 /// taking into account block and function alignment
962
963 /// print - Print out the MachineFunction in a format suitable for debugging
964 /// to the specified stream.
965 void print(raw_ostream &OS, const SlotIndexes* = nullptr) const;
966
967 /// viewCFG - This function is meant for use from the debugger. You can just
968 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
969 /// program, displaying the CFG of the current function with the code for each
970 /// basic block inside. This depends on there being a 'dot' and 'gv' program
971 /// in your path.
972 void viewCFG() const;
973
974 /// viewCFGOnly - This function is meant for use from the debugger. It works
975 /// just like viewCFG, but it does not include the contents of basic blocks
976 /// into the nodes, just the label. If you are only interested in the CFG
977 /// this can make the graph smaller.
978 ///
979 void viewCFGOnly() const;
980
981 /// dump - Print the current MachineFunction to cerr, useful for debugger use.
982 void dump() const;
983
984 /// Run the current MachineFunction through the machine code verifier, useful
985 /// for debugger use.
986 /// \returns true if no problems were found.
987 bool verify(Pass *p = nullptr, const char *Banner = nullptr,
988 raw_ostream *OS = nullptr, bool AbortOnError = true) const;
989
990 /// For New Pass Manager: Run the current MachineFunction through the machine
991 /// code verifier, useful for debugger use.
992 /// \returns true if no problems were found.
994 const char *Banner = nullptr, raw_ostream *OS = nullptr,
995 bool AbortOnError = true) const;
996
997 /// Run the current MachineFunction through the machine code verifier, useful
998 /// for debugger use.
999 /// TODO: Add the param for LiveStacks analysis.
1000 /// \returns true if no problems were found.
1001 bool verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
1002 const char *Banner = nullptr, raw_ostream *OS = nullptr,
1003 bool AbortOnError = true) const;
1004
1005 // Provide accessors for the MachineBasicBlock list...
1010
1011 /// Support for MachineBasicBlock::getNextNode().
1012 static BasicBlockListType MachineFunction::*
1014 return &MachineFunction::BasicBlocks;
1015 }
1016
1017 /// addLiveIn - Add the specified physical register as a live-in value and
1018 /// create a corresponding virtual register for it.
1020
1021 //===--------------------------------------------------------------------===//
1022 // BasicBlock accessor functions.
1023 //
1024 iterator begin() { return BasicBlocks.begin(); }
1025 const_iterator begin() const { return BasicBlocks.begin(); }
1026 iterator end () { return BasicBlocks.end(); }
1027 const_iterator end () const { return BasicBlocks.end(); }
1028
1029 reverse_iterator rbegin() { return BasicBlocks.rbegin(); }
1030 const_reverse_iterator rbegin() const { return BasicBlocks.rbegin(); }
1031 reverse_iterator rend () { return BasicBlocks.rend(); }
1032 const_reverse_iterator rend () const { return BasicBlocks.rend(); }
1033
1034 unsigned size() const { return (unsigned)BasicBlocks.size();}
1035 bool empty() const { return BasicBlocks.empty(); }
1036 const MachineBasicBlock &front() const { return BasicBlocks.front(); }
1037 MachineBasicBlock &front() { return BasicBlocks.front(); }
1038 const MachineBasicBlock & back() const { return BasicBlocks.back(); }
1039 MachineBasicBlock & back() { return BasicBlocks.back(); }
1040
1041 void push_back (MachineBasicBlock *MBB) { BasicBlocks.push_back (MBB); }
1042 void push_front(MachineBasicBlock *MBB) { BasicBlocks.push_front(MBB); }
1044 BasicBlocks.insert(MBBI, MBB);
1045 }
1046 void splice(iterator InsertPt, iterator MBBI) {
1047 BasicBlocks.splice(InsertPt, BasicBlocks, MBBI);
1048 }
1050 BasicBlocks.splice(InsertPt, BasicBlocks, MBB);
1051 }
1052 void splice(iterator InsertPt, iterator MBBI, iterator MBBE) {
1053 BasicBlocks.splice(InsertPt, BasicBlocks, MBBI, MBBE);
1054 }
1055
1056 void remove(iterator MBBI) { BasicBlocks.remove(MBBI); }
1057 void remove(MachineBasicBlock *MBBI) { BasicBlocks.remove(MBBI); }
1058 void erase(iterator MBBI) { BasicBlocks.erase(MBBI); }
1059 void erase(MachineBasicBlock *MBBI) { BasicBlocks.erase(MBBI); }
1060
1061 template <typename Comp>
1062 void sort(Comp comp) {
1063 BasicBlocks.sort(comp);
1064 }
1065
1066 /// Return the number of \p MachineInstrs in this \p MachineFunction.
1067 unsigned getInstructionCount() const {
1068 unsigned InstrCount = 0;
1069 for (const MachineBasicBlock &MBB : BasicBlocks)
1070 InstrCount += MBB.size();
1071 return InstrCount;
1072 }
1073
1074 //===--------------------------------------------------------------------===//
1075 // Internal functions used to automatically number MachineBasicBlocks
1076
1077 /// Adds the MBB to the internal numbering. Returns the unique number
1078 /// assigned to the MBB.
1080 MBBNumbering.push_back(MBB);
1081 return (unsigned)MBBNumbering.size()-1;
1082 }
1083
1084 /// removeFromMBBNumbering - Remove the specific machine basic block from our
1085 /// tracker, this is only really to be used by the MachineBasicBlock
1086 /// implementation.
1087 void removeFromMBBNumbering(unsigned N) {
1088 assert(N < MBBNumbering.size() && "Illegal basic block #");
1089 MBBNumbering[N] = nullptr;
1090 }
1091
1092 /// CreateMachineInstr - Allocate a new MachineInstr. Use this instead
1093 /// of `new MachineInstr'.
1094 MachineInstr *CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL,
1095 bool NoImplicit = false);
1096
1097 /// Create a new MachineInstr which is a copy of \p Orig, identical in all
1098 /// ways except the instruction has no parent, prev, or next. Bundling flags
1099 /// are reset.
1100 ///
1101 /// Note: Clones a single instruction, not whole instruction bundles.
1102 /// Does not perform target specific adjustments; consider using
1103 /// TargetInstrInfo::duplicate() instead.
1104 MachineInstr *CloneMachineInstr(const MachineInstr *Orig);
1105
1106 /// Clones instruction or the whole instruction bundle \p Orig and insert
1107 /// into \p MBB before \p InsertBefore.
1108 ///
1109 /// Note: Does not perform target specific adjustments; consider using
1110 /// TargetInstrInfo::duplicate() instead.
1111 MachineInstr &
1112 cloneMachineInstrBundle(MachineBasicBlock &MBB,
1113 MachineBasicBlock::iterator InsertBefore,
1114 const MachineInstr &Orig);
1115
1116 /// DeleteMachineInstr - Delete the given MachineInstr.
1117 void deleteMachineInstr(MachineInstr *MI);
1118
1119 /// CreateMachineBasicBlock - Allocate a new MachineBasicBlock. Use this
1120 /// instead of `new MachineBasicBlock'. Sets `MachineBasicBlock::BBID` if
1121 /// basic-block-sections is enabled for the function.
1123 CreateMachineBasicBlock(const BasicBlock *BB = nullptr,
1124 std::optional<UniqueBBID> BBID = std::nullopt);
1125
1126 /// DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
1127 void deleteMachineBasicBlock(MachineBasicBlock *MBB);
1128
1129 /// getMachineMemOperand - Allocate a new MachineMemOperand.
1130 /// MachineMemOperands are owned by the MachineFunction and need not be
1131 /// explicitly deallocated.
1134 Align base_alignment, const AAMDNodes &AAInfo = AAMDNodes(),
1135 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1137 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
1140 Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
1141 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1143 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
1146 Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
1147 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1149 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic) {
1151 BaseAlignment, AAInfo, Ranges, SSID, Ordering,
1152 FailureOrdering);
1153 }
1156 Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
1157 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1159 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic) {
1161 BaseAlignment, AAInfo, Ranges, SSID, Ordering,
1162 FailureOrdering);
1163 }
1164
1165 /// getMachineMemOperand - Allocate a new MachineMemOperand by copying
1166 /// an existing one, adjusting by an offset and using the given size.
1167 /// MachineMemOperands are owned by the MachineFunction and need not be
1168 /// explicitly deallocated.
1170 int64_t Offset, LLT Ty);
1172 int64_t Offset, LocationSize Size) {
1173 return getMachineMemOperand(
1174 MMO, Offset,
1175 !Size.hasValue() ? LLT()
1176 : Size.isScalable()
1177 ? LLT::scalable_vector(1, 8 * Size.getValue().getKnownMinValue())
1178 : LLT::scalar(8 * Size.getValue().getKnownMinValue()));
1179 }
1188
1189 /// getMachineMemOperand - Allocate a new MachineMemOperand by copying
1190 /// an existing one, replacing only the MachinePointerInfo and size.
1191 /// MachineMemOperands are owned by the MachineFunction and need not be
1192 /// explicitly deallocated.
1194 const MachinePointerInfo &PtrInfo,
1197 const MachinePointerInfo &PtrInfo,
1198 LLT Ty);
1209
1210 /// Allocate a new MachineMemOperand by copying an existing one,
1211 /// replacing only AliasAnalysis information. MachineMemOperands are owned
1212 /// by the MachineFunction and need not be explicitly deallocated.
1214 const AAMDNodes &AAInfo);
1215
1216 /// Allocate a new MachineMemOperand by copying an existing one,
1217 /// replacing the flags. MachineMemOperands are owned
1218 /// by the MachineFunction and need not be explicitly deallocated.
1221
1223
1224 /// Allocate an array of MachineOperands. This is only intended for use by
1225 /// internal MachineInstr functions.
1227 return OperandRecycler.allocate(Cap, Allocator);
1228 }
1229
1230 /// Dellocate an array of MachineOperands and recycle the memory. This is
1231 /// only intended for use by internal MachineInstr functions.
1232 /// Cap must be the same capacity that was used to allocate the array.
1234 OperandRecycler.deallocate(Cap, Array);
1235 }
1236
1237 /// Allocate and initialize a register mask with @p NumRegister bits.
1238 uint32_t *allocateRegMask();
1239
1240 ArrayRef<int> allocateShuffleMask(ArrayRef<int> Mask);
1241
1242 /// Allocate and construct an extra info structure for a `MachineInstr`.
1243 ///
1244 /// This is allocated on the function's allocator and so lives the life of
1245 /// the function.
1246 MachineInstr::ExtraInfo *createMIExtraInfo(
1247 ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol = nullptr,
1248 MCSymbol *PostInstrSymbol = nullptr, MDNode *HeapAllocMarker = nullptr,
1249 MDNode *PCSections = nullptr, uint32_t CFIType = 0,
1250 MDNode *MMRAs = nullptr, Value *DS = nullptr);
1251
1252 /// Allocate a string and populate it with the given external symbol name.
1253 const char *createExternalSymbolName(StringRef Name);
1254
1255 //===--------------------------------------------------------------------===//
1256 // Label Manipulation.
1257
1258 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
1259 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
1260 /// normal 'L' label is returned.
1261 MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
1262 bool isLinkerPrivate = false) const;
1263
1264 /// getPICBaseSymbol - Return a function-local symbol to represent the PIC
1265 /// base.
1266 MCSymbol *getPICBaseSymbol() const;
1267
1268 /// Returns a reference to a list of cfi instructions in the function's
1269 /// prologue. Used to construct frame maps for debug and exception handling
1270 /// comsumers.
1271 const std::vector<MCCFIInstruction> &getFrameInstructions() const {
1272 return FrameInstructions;
1273 }
1274
1275 [[nodiscard]] unsigned addFrameInst(const MCCFIInstruction &Inst);
1276
1277 /// Returns a reference to a list of symbols immediately following calls to
1278 /// _setjmp in the function. Used to construct the longjmp target table used
1279 /// by Windows Control Flow Guard.
1280 const std::vector<MCSymbol *> &getLongjmpTargets() const {
1281 return LongjmpTargets;
1282 }
1283
1284 /// Add the specified symbol to the list of valid longjmp targets for Windows
1285 /// Control Flow Guard.
1286 void addLongjmpTarget(MCSymbol *Target) { LongjmpTargets.push_back(Target); }
1287
1288 /// Returns a reference to a list of symbols that are targets for Windows
1289 /// EH Continuation Guard.
1290 const std::vector<MCSymbol *> &getEHContTargets() const {
1291 return EHContTargets;
1292 }
1293
1294 /// Add the specified symbol to the list of targets for Windows EH
1295 /// Continuation Guard.
1296 void addEHContTarget(MCSymbol *Target) { EHContTargets.push_back(Target); }
1297
1298 /// Tries to get the global and target flags for a call site, if the
1299 /// instruction is a call to a global.
1301 return CalledGlobalsInfo.lookup(MI);
1302 }
1303
1304 /// Notes the global and target flags for a call site.
1306 assert(MI && "MI must not be null");
1307 assert(MI->isCandidateForAdditionalCallInfo() &&
1308 "Cannot store called global info for this instruction");
1309 assert(Details.Callee && "Global must not be null");
1310 CalledGlobalsInfo.insert({MI, Details});
1311 }
1312
1313 /// Iterates over the full set of call sites and their associated globals.
1314 auto getCalledGlobals() const {
1315 return llvm::make_range(CalledGlobalsInfo.begin(), CalledGlobalsInfo.end());
1316 }
1317
1318 /// \name Exception Handling
1319 /// \{
1320
1321 bool callsEHReturn() const { return CallsEHReturn; }
1322 void setCallsEHReturn(bool b) { CallsEHReturn = b; }
1323
1324 bool callsUnwindInit() const { return CallsUnwindInit; }
1325 void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
1326
1327 bool hasEHContTarget() const { return HasEHContTarget; }
1328 void setHasEHContTarget(bool V) { HasEHContTarget = V; }
1329
1330 bool hasEHScopes() const { return HasEHScopes; }
1331 void setHasEHScopes(bool V) { HasEHScopes = V; }
1332
1333 bool hasEHFunclets() const { return HasEHFunclets; }
1334 void setHasEHFunclets(bool V) { HasEHFunclets = V; }
1335
1336 bool hasFakeUses() const { return HasFakeUses; }
1337 void setHasFakeUses(bool V) { HasFakeUses = V; }
1338
1339 bool isOutlined() const { return IsOutlined; }
1340 void setIsOutlined(bool V) { IsOutlined = V; }
1341
1342 /// Find or create an LandingPadInfo for the specified MachineBasicBlock.
1343 LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad);
1344
1345 /// Return a reference to the landing pad info for the current function.
1346 const std::vector<LandingPadInfo> &getLandingPads() const {
1347 return LandingPads;
1348 }
1349
1350 /// Provide the begin and end labels of an invoke style call and associate it
1351 /// with a try landing pad block.
1352 void addInvoke(MachineBasicBlock *LandingPad,
1353 MCSymbol *BeginLabel, MCSymbol *EndLabel);
1354
1355 /// Add a new panding pad, and extract the exception handling information from
1356 /// the landingpad instruction. Returns the label ID for the landing pad
1357 /// entry.
1358 MCSymbol *addLandingPad(MachineBasicBlock *LandingPad);
1359
1360 /// Return the type id for the specified typeinfo. This is function wide.
1361 unsigned getTypeIDFor(const GlobalValue *TI);
1362
1363 /// Return the id of the filter encoded by TyIds. This is function wide.
1364 int getFilterIDFor(ArrayRef<unsigned> TyIds);
1365
1366 /// Map the landing pad's EH symbol to the call site indexes.
1367 void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef<unsigned> Sites);
1368
1369 /// Return if there is any wasm exception handling.
1371 return !WasmLPadToIndexMap.empty();
1372 }
1373
1374 /// Map the landing pad to its index. Used for Wasm exception handling.
1375 void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index) {
1376 WasmLPadToIndexMap[LPad] = Index;
1377 }
1378
1379 /// Returns true if the landing pad has an associate index in wasm EH.
1381 return WasmLPadToIndexMap.count(LPad);
1382 }
1383
1384 /// Get the index in wasm EH for a given landing pad.
1385 unsigned getWasmLandingPadIndex(const MachineBasicBlock *LPad) const {
1387 return WasmLPadToIndexMap.lookup(LPad);
1388 }
1389
1391 return !LPadToCallSiteMap.empty();
1392 }
1393
1394 /// Get the call site indexes for a landing pad EH symbol.
1397 "missing call site number for landing pad!");
1398 return LPadToCallSiteMap[Sym];
1399 }
1400
1401 /// Return true if the landing pad Eh symbol has an associated call site.
1403 return !LPadToCallSiteMap[Sym].empty();
1404 }
1405
1406 bool hasAnyCallSiteLabel() const {
1407 return !CallSiteMap.empty();
1408 }
1409
1410 /// Map the begin label for a call site.
1411 void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site) {
1412 CallSiteMap[BeginLabel] = Site;
1413 }
1414
1415 /// Get the call site number for a begin label.
1416 unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const {
1417 assert(hasCallSiteBeginLabel(BeginLabel) &&
1418 "Missing call site number for EH_LABEL!");
1419 return CallSiteMap.lookup(BeginLabel);
1420 }
1421
1422 /// Return true if the begin label has a call site number associated with it.
1423 bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) const {
1424 return CallSiteMap.count(BeginLabel);
1425 }
1426
1427 /// Record annotations associated with a particular label.
1429 CodeViewAnnotations.push_back({Label, MD});
1430 }
1431
1433 return CodeViewAnnotations;
1434 }
1435
1436 /// Return a reference to the C++ typeinfo for the current function.
1437 const std::vector<const GlobalValue *> &getTypeInfos() const {
1438 return TypeInfos;
1439 }
1440
1441 /// Return a reference to the typeids encoding filters used in the current
1442 /// function.
1443 const std::vector<unsigned> &getFilterIds() const {
1444 return FilterIds;
1445 }
1446
1447 /// \}
1448
1449 /// Collect information used to emit debugging information of a variable in a
1450 /// stack slot.
1452 int Slot, const DILocation *Loc) {
1453 VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc);
1454 }
1455
1456 /// Collect information used to emit debugging information of a variable in
1457 /// the entry value of a register.
1459 MCRegister Reg, const DILocation *Loc) {
1460 VariableDbgInfos.emplace_back(Var, Expr, Reg, Loc);
1461 }
1462
1465 return VariableDbgInfos;
1466 }
1467
1468 /// Returns the collection of variables for which we have debug info and that
1469 /// have been assigned a stack slot.
1471 return make_filter_range(getVariableDbgInfo(), [](auto &VarInfo) {
1472 return VarInfo.inStackSlot();
1473 });
1474 }
1475
1476 /// Returns the collection of variables for which we have debug info and that
1477 /// have been assigned a stack slot.
1479 return make_filter_range(getVariableDbgInfo(), [](const auto &VarInfo) {
1480 return VarInfo.inStackSlot();
1481 });
1482 }
1483
1484 /// Returns the collection of variables for which we have debug info and that
1485 /// have been assigned an entry value register.
1487 return make_filter_range(getVariableDbgInfo(), [](const auto &VarInfo) {
1488 return VarInfo.inEntryValueRegister();
1489 });
1490 }
1491
1492 /// Start tracking the arguments passed to the call \p CallI.
1495 bool Inserted =
1496 CallSitesInfo.try_emplace(CallI, std::move(CallInfo)).second;
1497 (void)Inserted;
1498 assert(Inserted && "Call site info not unique");
1499 }
1500
1502 return CallSitesInfo;
1503 }
1504
1505 /// Following functions update call site info. They should be called before
1506 /// removing, replacing or copying call instruction.
1507
1508 /// Erase the call site info for \p MI. It is used to remove a call
1509 /// instruction from the instruction stream.
1510 void eraseAdditionalCallInfo(const MachineInstr *MI);
1511 /// Copy the call site info from \p Old to \ New. Its usage is when we are
1512 /// making a copy of the instruction that will be inserted at different point
1513 /// of the instruction stream.
1514 void copyAdditionalCallInfo(const MachineInstr *Old, const MachineInstr *New);
1515
1516 /// Move the call site info from \p Old to \New call site info. This function
1517 /// is used when we are replacing one call instruction with another one to
1518 /// the same callee.
1519 void moveAdditionalCallInfo(const MachineInstr *Old, const MachineInstr *New);
1520
1522 return ++DebugInstrNumberingCount;
1523 }
1524};
1525
1526//===--------------------------------------------------------------------===//
1527// GraphTraits specializations for function basic block graphs (CFGs)
1528//===--------------------------------------------------------------------===//
1529
1530// Provide specializations of GraphTraits to be able to treat a
1531// machine function as a graph of machine basic blocks... these are
1532// the same as the machine basic block iterators, except that the root
1533// node is implicitly the first node of the function.
1534//
1535template <> struct GraphTraits<MachineFunction*> :
1537 static NodeRef getEntryNode(MachineFunction *F) { return &F->front(); }
1538
1539 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
1541
1543 return nodes_iterator(F->begin());
1544 }
1545
1547 return nodes_iterator(F->end());
1548 }
1549
1550 static unsigned size (MachineFunction *F) { return F->size(); }
1551
1552 static unsigned getMaxNumber(MachineFunction *F) {
1553 return F->getMaxAnalysisBlockNumber();
1554 }
1556 return F->getAnalysisBlockNumberEpoch();
1557 }
1558};
1559template <> struct GraphTraits<const MachineFunction*> :
1561 static NodeRef getEntryNode(const MachineFunction *F) { return &F->front(); }
1562
1563 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
1565
1567 return nodes_iterator(F->begin());
1568 }
1569
1571 return nodes_iterator(F->end());
1572 }
1573
1574 static unsigned size (const MachineFunction *F) {
1575 return F->size();
1576 }
1577
1578 static unsigned getMaxNumber(const MachineFunction *F) {
1579 return F->getMaxAnalysisBlockNumber();
1580 }
1581 static unsigned getNumberEpoch(const MachineFunction *F) {
1582 return F->getAnalysisBlockNumberEpoch();
1583 }
1584};
1585
1586// Provide specializations of GraphTraits to be able to treat a function as a
1587// graph of basic blocks... and to walk it in inverse order. Inverse order for
1588// a function is considered to be when traversing the predecessor edges of a BB
1589// instead of the successor edges.
1590//
1591template <> struct GraphTraits<Inverse<MachineFunction*>> :
1594 return &G.Graph->front();
1595 }
1596
1597 static unsigned getMaxNumber(MachineFunction *F) {
1598 return F->getMaxAnalysisBlockNumber();
1599 }
1601 return F->getAnalysisBlockNumberEpoch();
1602 }
1603};
1607 return &G.Graph->front();
1608 }
1609
1610 static unsigned getMaxNumber(const MachineFunction *F) {
1611 return F->getMaxAnalysisBlockNumber();
1612 }
1613 static unsigned getNumberEpoch(const MachineFunction *F) {
1614 return F->getAnalysisBlockNumberEpoch();
1615 }
1616};
1617
1618LLVM_ABI void verifyMachineFunction(const std::string &Banner,
1619 const MachineFunction &MF);
1620
1621} // end namespace llvm
1622
1623#endif // LLVM_CODEGEN_MACHINEFUNCTION_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
This file defines the BumpPtrAllocator interface.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
Atomic ordering constants.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI, const BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
#define LLVM_ABI
Definition Compiler.h:213
static unsigned InstrCount
This file defines the DenseMap class.
@ CallSiteInfo
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
IRTranslator LLVM IR MI
static uint64_t estimateFunctionSizeInBytes(const LoongArchInstrInfo *TII, const MachineFunction &MF)
#define F(x, y, z)
Definition MD5.cpp:54
#define G(x, y, z)
Definition MD5.cpp:55
#define PPACCESSORS(X)
Register Reg
static unsigned addLiveIn(MachineFunction &MF, unsigned PReg, const TargetRegisterClass *RC)
#define P(N)
ppc ctr loops verify
static StringRef getName(Value *V)
Basic Register Allocator
This file defines the SmallVector class.
static MachineMemOperand * getMachineMemOperand(MachineFunction &MF, FrameIndexSDNode &FI)
The size of an allocated array is represented by a Capacity instance.
Recycle small arrays allocated from a BumpPtrAllocator.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
LLVM Basic Block Representation.
Definition BasicBlock.h:62
The address of a basic block.
Definition Constants.h:1065
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
DWARF expression.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:123
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Definition DenseMap.h:74
Abstract class that contains various methods for clients to notify about changes.
static constexpr LLT scalable_vector(unsigned MinNumElements, unsigned ScalarSizeInBits)
Get a low-level scalable vector of some number of elements and element width.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
static LocationSize precise(uint64_t Value)
Context object for machine code objects.
Definition MCContext.h:83
Describe properties that are true of each instruction in the target description file.
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition MCSection.h:516
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Metadata node.
Definition Metadata.h:1080
MachineInstrBundleIterator< MachineInstr > iterator
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & reset()
Reset all the properties.
MachineFunctionProperties & resetToInitial()
Reset all properties and re-establish baseline invariants.
MachineFunctionProperties & set(const MachineFunctionProperties &MFP)
LLVM_ABI void print(raw_ostream &OS) const
Print the MachineFunctionProperties in human-readable form.
bool verifyRequiredProperties(const MachineFunctionProperties &V) const
MachineFunctionProperties & reset(const MachineFunctionProperties &MFP)
MachineFunctionProperties & set(Property P)
bool hasProperty(Property P) const
MachineFunctionProperties & reset(Property P)
DebugPHIRegallocPos(MachineBasicBlock *MBB, Register Reg, unsigned SubReg)
Register Reg
VReg where the control-flow-merge happens.
unsigned SubReg
Optional subreg qualifier within Reg.
MachineBasicBlock * MBB
Block where this PHI was originally located.
bool operator<(const DebugSubstitution &Other) const
Order only by source instruction / operand pair: there should never be duplicate entries for the same...
DebugInstrOperandPair Dest
Replacement instruction / operand pair.
DebugInstrOperandPair Src
Source instruction / operand pair.
DebugSubstitution(const DebugInstrOperandPair &Src, const DebugInstrOperandPair &Dest, unsigned Subreg)
unsigned Subreg
Qualifier for which part of Dest is read.
virtual void MF_HandleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID)
Callback before changing MCInstrDesc.
virtual void MF_HandleRemoval(MachineInstr &MI)=0
Callback before a removal. This should not modify the MI directly.
virtual void MF_HandleInsertion(MachineInstr &MI)=0
Callback after an insertion. This should not modify the MI directly.
bool inStackSlot() const
Return true if this variable is in a stack slot.
void updateStackSlot(int NewSlot)
Updates the stack slot of this variable, assuming inStackSlot() is true.
MCRegister getEntryValueRegister() const
Returns the MCRegister of this variable, assuming inEntryValueRegister() is true.
bool inEntryValueRegister() const
Return true if this variable is in the entry value of a register.
VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
int getStackSlot() const
Returns the stack slot of this variable, assuming inStackSlot() is true.
VariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, MCRegister EntryValReg, const DILocation *Loc)
unsigned getInstructionCount() const
Return the number of MachineInstrs in this MachineFunction.
auto getEntryValueVariableDbgInfo() const
Returns the collection of variables for which we have debug info and that have been assigned an entry...
void setBBSectionsType(BasicBlockSection V)
MachineJumpTableInfo * getJumpTableInfo()
const WinEHFuncInfo * getWinEHFuncInfo() const
getWinEHFuncInfo - Return information about how the current function uses Windows exception handling.
void setCallsUnwindInit(bool b)
unsigned addToMBBNumbering(MachineBasicBlock *MBB)
Adds the MBB to the internal numbering.
void addLongjmpTarget(MCSymbol *Target)
Add the specified symbol to the list of valid longjmp targets for Windows Control Flow Guard.
const MachineConstantPool * getConstantPool() const
const MachineFrameInfo & getFrameInfo() const
bool UseDebugInstrRef
Flag for whether this function contains DBG_VALUEs (false) or DBG_INSTR_REF (true).
std::pair< unsigned, unsigned > DebugInstrOperandPair
Pair of instruction number and operand number.
ArrayRecycler< MachineOperand >::Capacity OperandCapacity
void addEHContTarget(MCSymbol *Target)
Add the specified symbol to the list of targets for Windows EH Continuation Guard.
bool useDebugInstrRef() const
Returns true if the function's variable locations are tracked with instruction referencing.
void setExposesReturnsTwice(bool B)
setCallsSetJmp - Set a flag that indicates if there's a call to a "returns twice" function.
void removeFromMBBNumbering(unsigned N)
removeFromMBBNumbering - Remove the specific machine basic block from our tracker,...
SmallVector< DebugSubstitution, 8 > DebugValueSubstitutions
Debug value substitutions: a collection of DebugSubstitution objects, recording changes in where a va...
unsigned getFunctionNumber() const
getFunctionNumber - Return a unique ID for the current function.
void setHasInlineAsm(bool B)
Set a flag that indicates that the function contains inline assembly.
bool hasAnyCallSiteLabel() const
CalledGlobalInfo tryGetCalledGlobal(const MachineInstr *MI) const
Tries to get the global and target flags for a call site, if the instruction is a call to a global.
PseudoSourceValueManager & getPSVManager() const
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New, unsigned MaxOperand=UINT_MAX)
Create substitutions for any tracked values in Old, to point at New.
void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site)
Map the begin label for a call site.
void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index)
Map the landing pad to its index. Used for Wasm exception handling.
const DenseMap< UniqueBBID, SmallVector< unsigned > > & getPrefetchTargets() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const std::vector< MCCFIInstruction > & getFrameInstructions() const
Returns a reference to a list of cfi instructions in the function's prologue.
DenseMap< const MachineInstr *, CallSiteInfo > CallSiteInfoMap
MachineFunction & operator=(const MachineFunction &)=delete
bool hasInlineAsm() const
Returns true if the function contains any inline assembly.
void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair, unsigned SubReg=0)
Create a substitution between one <instr,operand> value to a different, new value.
MachineFunction(Function &F, const TargetMachine &Target, const TargetSubtargetInfo &STI, MCContext &Ctx, unsigned FunctionNum)
BasicBlockListType::reverse_iterator reverse_iterator
void setAlignment(Align A)
setAlignment - Set the alignment of the function.
WinEHFuncInfo * getWinEHFuncInfo()
bool exposesReturnsTwice() const
exposesReturnsTwice - Returns true if the function calls setjmp or any other similar functions with a...
MachineFunctionProperties & getProperties()
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, TypeSize Size, Align BaseAlignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
GISelChangeObserver * getObserver() const
void setPrefetchTargets(const DenseMap< UniqueBBID, SmallVector< unsigned > > &V)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
const std::vector< MCSymbol * > & getEHContTargets() const
Returns a reference to a list of symbols that are targets for Windows EH Continuation Guard.
void finalizeDebugInstrRefs()
Finalise any partially emitted debug instructions.
void deallocateOperandArray(OperandCapacity Cap, MachineOperand *Array)
Dellocate an array of MachineOperands and recycle the memory.
void setSection(MCSection *S)
Indicates the Section this function belongs to.
MachineMemOperand * getMachineMemOperand(const MachineMemOperand *MMO, int64_t Offset, uint64_t Size)
void push_front(MachineBasicBlock *MBB)
const std::vector< unsigned > & getFilterIds() const
Return a reference to the typeids encoding filters used in the current function.
const std::vector< const GlobalValue * > & getTypeInfos() const
Return a reference to the C++ typeinfo for the current function.
auto getInStackSlotVariableDbgInfo() const
Returns the collection of variables for which we have debug info and that have been assigned a stack ...
bool hasAnyWasmLandingPadIndex() const
Return if there is any wasm exception handling.
const CallSiteInfoMap & getCallSitesInfo() const
void ensureAlignment(Align A)
ensureAlignment - Make sure the function is at least A bytes aligned.
void push_back(MachineBasicBlock *MBB)
reverse_iterator rbegin()
void setUseDebugInstrRef(bool UseInstrRef)
Set whether this function will use instruction referencing or not.
bool hasBBSections() const
Returns true if this function has basic block sections enabled.
MCContext & getContext() const
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, MCRegister Reg, const DILocation *Loc)
Collect information used to emit debugging information of a variable in the entry value of a register...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
MachineOperand * allocateOperandArray(OperandCapacity Cap)
Allocate an array of MachineOperands.
unsigned getMaxAnalysisBlockNumber() const
MachineMemOperand * getMachineMemOperand(const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, TypeSize Size)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
reverse_iterator rend()
unsigned DebugInstrNumberingCount
A count of how many instructions in the function have had numbers assigned to them.
auto getInStackSlotVariableDbgInfo()
Returns the collection of variables for which we have debug info and that have been assigned a stack ...
Align getAlignment() const
getAlignment - Return the alignment of the function.
void splice(iterator InsertPt, iterator MBBI, iterator MBBE)
void handleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID)
unsigned getWasmLandingPadIndex(const MachineBasicBlock *LPad) const
Get the index in wasm EH for a given landing pad.
const_iterator end() const
static const unsigned int DebugOperandMemNumber
A reserved operand number representing the instructions memory operand, for instructions that have a ...
void setObserver(GISelChangeObserver *O)
void resetDelegate(Delegate *delegate)
Reset the currently registered delegate - otherwise assert.
void addCodeViewAnnotation(MCSymbol *Label, MDNode *MD)
Record annotations associated with a particular label.
Function & getFunction()
Return the LLVM function that this machine code represents.
MachineMemOperand * getMachineMemOperand(const MachineMemOperand *MMO, const MachinePointerInfo &PtrInfo, uint64_t Size)
void erase(MachineBasicBlock *MBBI)
unsigned getNumBlockIDs() const
getNumBlockIDs - Return the number of MBB ID's allocated.
const_iterator begin() const
void remove(MachineBasicBlock *MBBI)
const std::vector< MCSymbol * > & getLongjmpTargets() const
Returns a reference to a list of symbols immediately following calls to _setjmp in the function.
DebugInstrOperandPair salvageCopySSAImpl(MachineInstr &MI)
const std::vector< LandingPadInfo > & getLandingPads() const
Return a reference to the landing pad info for the current function.
MCSection * getSection() const
Returns the Section this function belongs to.
const VariableDbgInfoMapTy & getVariableDbgInfo() const
const MachineBasicBlock & back() const
BasicBlockListType::iterator iterator
void setDebugInstrNumberingCount(unsigned Num)
Set value of DebugInstrNumberingCount field.
const_reverse_iterator rbegin() const
const STC & getSubtarget() const
getSubtarget - This method returns a pointer to the specified type of TargetSubtargetInfo.
BasicBlockListType::const_reverse_iterator const_reverse_iterator
unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const
Get the call site number for a begin label.
void remove(iterator MBBI)
VariableDbgInfoMapTy & getVariableDbgInfo()
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineRegisterInfo & getRegInfo() const
const WasmEHFuncInfo * getWasmEHFuncInfo() const
getWasmEHFuncInfo - Return information about how the current function uses Wasm exception handling.
bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) const
Return true if the begin label has a call site number associated with it.
void splice(iterator InsertPt, MachineBasicBlock *MBB)
void addCallSiteInfo(const MachineInstr *CallI, CallSiteInfo &&CallInfo)
Start tracking the arguments passed to the call CallI.
static BasicBlockListType MachineFunction::* getSublistAccess(MachineBasicBlock *)
Support for MachineBasicBlock::getNextNode().
bool hasWasmLandingPadIndex(const MachineBasicBlock *LPad) const
Returns true if the landing pad has an associate index in wasm EH.
bool shouldUseDebugInstrRef() const
Determine whether, in the current machine configuration, we should use instruction referencing or not...
const MachineFunctionProperties & getProperties() const
Get the function properties.
Ty * cloneInfo(const Ty &Old)
bool hasCallSiteLandingPad(MCSymbol *Sym)
Return true if the landing pad Eh symbol has an associated call site.
void setVariableDbgInfo(const DILocalVariable *Var, const DIExpression *Expr, int Slot, const DILocation *Loc)
Collect information used to emit debugging information of a variable in a stack slot.
void setDelegate(Delegate *delegate)
Set the delegate.
void reset()
Reset the instance as if it was just created.
DenseMap< unsigned, DebugPHIRegallocPos > DebugPHIPositions
Map of debug instruction numbers to the position of their PHI instructions during register allocation...
const MachineBasicBlock & front() const
MachineMemOperand * getMachineMemOperand(const MachineMemOperand *MMO, int64_t Offset, LocationSize Size)
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, uint64_t Size, Align BaseAlignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
const Ty * getInfo() const
unsigned getAnalysisBlockNumberEpoch() const
Return the numbering "epoch" of analysis block numbers.
MachineMemOperand * getMachineMemOperand(const MachineMemOperand *MMO, int64_t Offset, TypeSize Size)
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const_reverse_iterator rend() const
void setHasEHContTarget(bool V)
bool hasAnyCallSiteLandingPad() const
WasmEHFuncInfo * getWasmEHFuncInfo()
void splice(iterator InsertPt, iterator MBBI)
SmallVector< VariableDbgInfo, 4 > VariableDbgInfoMapTy
auto getCalledGlobals() const
Iterates over the full set of call sites and their associated globals.
void addCalledGlobal(const MachineInstr *MI, CalledGlobalInfo Details)
Notes the global and target flags for a call site.
void erase(iterator MBBI)
ArrayRef< std::pair< MCSymbol *, MDNode * > > getCodeViewAnnotations() const
VariableDbgInfoMapTy VariableDbgInfos
MachineFunction(const MachineFunction &)=delete
void insert(iterator MBBI, MachineBasicBlock *MBB)
MachineBasicBlock & back()
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
DebugInstrOperandPair salvageCopySSA(MachineInstr &MI, DenseMap< Register, DebugInstrOperandPair > &DbgPHICache)
Find the underlying defining instruction / operand for a COPY instruction while in SSA form.
BasicBlockListType::const_iterator const_iterator
MachineFunctionInfo * cloneInfoFrom(const MachineFunction &OrigMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB)
MachineBasicBlock & front()
SmallVectorImpl< unsigned > & getCallSiteLandingPad(MCSymbol *Sym)
Get the call site indexes for a landing pad EH symbol.
Representation of each machine instruction.
LLVM_ABI bool isCandidateForAdditionalCallInfo(QueryType Type=IgnoreBundle) const
Return true if this is a call instruction that may have an additional information associated with it.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
MachineOperand class - Representation of each machine instruction operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Pass interface - Implemented by all 'passes'.
Definition Pass.h:99
Manages creation of pseudo source values.
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
Definition Recycler.h:37
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SlotIndexes pass.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
TargetSubtargetInfo - Generic base class for all target subtargets.
LLVM Value Representation.
Definition Value.h:75
typename base_list_type::const_reverse_iterator const_reverse_iterator
Definition ilist.h:124
typename base_list_type::reverse_iterator reverse_iterator
Definition ilist.h:123
typename base_list_type::const_iterator const_iterator
Definition ilist.h:122
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This file defines classes to implement an intrusive doubly linked list class (i.e.
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
Definition CallingConv.h:47
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h:58
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
@ Offset
Definition DWP.cpp:532
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
MachineFunctionDataHotness
iplist< T, Options... > ilist
Definition ilist.h:344
LLVM_ABI void verifyMachineFunction(const std::string &Banner, const MachineFunction &MF)
iterator_range< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
Definition STLExtras.h:552
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Other
Any other memory.
Definition ModRef.h:68
BasicBlockSection
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:763
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Represent subnormal handling kind for floating point instruction inputs and outputs.
static unsigned getNumberEpoch(MachineFunction *F)
static unsigned getMaxNumber(MachineFunction *F)
static NodeRef getEntryNode(Inverse< MachineFunction * > G)
static unsigned getNumberEpoch(const MachineFunction *F)
static unsigned getMaxNumber(const MachineFunction *F)
static NodeRef getEntryNode(Inverse< const MachineFunction * > G)
static unsigned getNumberEpoch(MachineFunction *F)
pointer_iterator< MachineFunction::iterator > nodes_iterator
static unsigned size(MachineFunction *F)
static nodes_iterator nodes_begin(MachineFunction *F)
static unsigned getMaxNumber(MachineFunction *F)
static nodes_iterator nodes_end(MachineFunction *F)
static NodeRef getEntryNode(MachineFunction *F)
static nodes_iterator nodes_begin(const MachineFunction *F)
pointer_iterator< MachineFunction::const_iterator > nodes_iterator
static nodes_iterator nodes_end(const MachineFunction *F)
static unsigned size(const MachineFunction *F)
static unsigned getMaxNumber(const MachineFunction *F)
static NodeRef getEntryNode(const MachineFunction *F)
static unsigned getNumberEpoch(const MachineFunction *F)
typename MachineFunction *::UnknownGraphTypeError NodeRef
Definition GraphTraits.h:95
This structure is used to retain landing pad info for the current function.
SmallVector< MCSymbol *, 1 > EndLabels
SmallVector< SEHHandler, 1 > SEHHandlers
LandingPadInfo(MachineBasicBlock *MBB)
MachineBasicBlock * LandingPadBlock
SmallVector< MCSymbol *, 1 > BeginLabels
std::vector< int > TypeIds
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static FuncInfoTy * create(BumpPtrAllocator &Allocator, const Function &F, const SubtargetTy *STI)
Factory function: default behavior is to call new using the supplied allocator.
virtual MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap< MachineBasicBlock *, MachineBasicBlock * > &Src2DstMBB) const
Make a functionally equivalent copy of this MachineFunctionInfo in MF.
static Ty * create(BumpPtrAllocator &Allocator, const Ty &MFI)
ArgRegPair(Register R, unsigned Arg)
SmallVector< ConstantInt *, 4 > CalleeTypeIds
Callee type ids.
MDNode * CallTarget
'call_target' metadata for the DISubprogram.
SmallVector< ArgRegPair, 1 > ArgRegPairs
Vector of call argument and its forwarding register.
This class contains a discriminated union of information about pointers in memory operands,...
const BlockAddress * RecoverBA
Address of block to recover at. Null for a finally handler.
const Function * FilterOrFinally
Filter or finally function. Null indicates a catch-all.
LLVM_ABI void deleteNode(MachineBasicBlock *MBB)
Use delete by default for iplist and ilist.
Definition ilist.h:41
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
LLVM_ABI void removeNodeFromList(MachineBasicBlock *N)
LLVM_ABI void addNodeToList(MachineBasicBlock *N)
Callbacks do nothing by default in iplist and ilist.
Definition ilist.h:65
Template traits for intrusive list.
Definition ilist.h:90