LLVM 20.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"
36#include <bitset>
37#include <cassert>
38#include <cstdint>
39#include <memory>
40#include <utility>
41#include <variant>
42#include <vector>
43
44namespace llvm {
45
46class BasicBlock;
47class BlockAddress;
48class DataLayout;
49class DebugLoc;
50struct DenormalMode;
51class DIExpression;
52class DILocalVariable;
53class DILocation;
54class Function;
55class GISelChangeObserver;
56class GlobalValue;
57class TargetMachine;
58class MachineConstantPool;
59class MachineFrameInfo;
60class MachineFunction;
61class MachineJumpTableInfo;
62class MachineRegisterInfo;
63class MCContext;
64class MCInstrDesc;
65class MCSymbol;
66class MCSection;
67class Pass;
68class PseudoSourceValueManager;
69class raw_ostream;
70class SlotIndexes;
71class StringRef;
72class TargetRegisterClass;
73class TargetSubtargetInfo;
74struct WasmEHFuncInfo;
75struct WinEHFuncInfo;
76
79};
80
84
85 template <class Iterator>
86 void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator) {
87 assert(this == &OldList && "never transfer MBBs between functions");
88 }
89};
90
91/// MachineFunctionInfo - This class can be derived from and used by targets to
92/// hold private target-specific information for each MachineFunction. Objects
93/// of type are accessed/created with MF::getInfo and destroyed when the
94/// MachineFunction is destroyed.
97
98 /// Factory function: default behavior is to call new using the
99 /// supplied allocator.
100 ///
101 /// This function can be overridden in a derive class.
102 template <typename FuncInfoTy, typename SubtargetTy = TargetSubtargetInfo>
103 static FuncInfoTy *create(BumpPtrAllocator &Allocator, const Function &F,
104 const SubtargetTy *STI) {
105 return new (Allocator.Allocate<FuncInfoTy>()) FuncInfoTy(F, STI);
106 }
107
108 template <typename Ty>
109 static Ty *create(BumpPtrAllocator &Allocator, const Ty &MFI) {
110 return new (Allocator.Allocate<Ty>()) Ty(MFI);
111 }
112
113 /// Make a functionally equivalent copy of this MachineFunctionInfo in \p MF.
114 /// This requires remapping MachineBasicBlock references from the original
115 /// parent to values in the new function. Targets may assume that virtual
116 /// register and frame index values are preserved in the new function.
117 virtual MachineFunctionInfo *
120 const {
121 return nullptr;
122 }
123};
124
125/// Properties which a MachineFunction may have at a given point in time.
126/// Each of these has checking code in the MachineVerifier, and passes can
127/// require that a property be set.
129 // Possible TODO: Allow targets to extend this (perhaps by allowing the
130 // constructor to specify the size of the bit vector)
131 // Possible TODO: Allow requiring the negative (e.g. VRegsAllocated could be
132 // stated as the negative of "has vregs"
133
134public:
135 // The properties are stated in "positive" form; i.e. a pass could require
136 // that the property hold, but not that it does not hold.
137
138 // Property descriptions:
139 // IsSSA: True when the machine function is in SSA form and virtual registers
140 // have a single def.
141 // NoPHIs: The machine function does not contain any PHI instruction.
142 // TracksLiveness: True when tracking register liveness accurately.
143 // While this property is set, register liveness information in basic block
144 // live-in lists and machine instruction operands (e.g. implicit defs) is
145 // accurate, kill flags are conservatively accurate (kill flag correctly
146 // indicates the last use of a register, an operand without kill flag may or
147 // may not be the last use of a register). This means it can be used to
148 // change the code in ways that affect the values in registers, for example
149 // by the register scavenger.
150 // When this property is cleared at a very late time, liveness is no longer
151 // reliable.
152 // NoVRegs: The machine function does not use any virtual registers.
153 // Legalized: In GlobalISel: the MachineLegalizer ran and all pre-isel generic
154 // instructions have been legalized; i.e., all instructions are now one of:
155 // - generic and always legal (e.g., COPY)
156 // - target-specific
157 // - legal pre-isel generic instructions.
158 // RegBankSelected: In GlobalISel: the RegBankSelect pass ran and all generic
159 // virtual registers have been assigned to a register bank.
160 // Selected: In GlobalISel: the InstructionSelect pass ran and all pre-isel
161 // generic instructions have been eliminated; i.e., all instructions are now
162 // target-specific or non-pre-isel generic instructions (e.g., COPY).
163 // Since only pre-isel generic instructions can have generic virtual register
164 // operands, this also means that all generic virtual registers have been
165 // constrained to virtual registers (assigned to register classes) and that
166 // all sizes attached to them have been eliminated.
167 // TiedOpsRewritten: The twoaddressinstruction pass will set this flag, it
168 // means that tied-def have been rewritten to meet the RegConstraint.
169 // FailsVerification: Means that the function is not expected to pass machine
170 // verification. This can be set by passes that introduce known problems that
171 // have not been fixed yet.
172 // TracksDebugUserValues: Without this property enabled, debug instructions
173 // such as DBG_VALUE are allowed to reference virtual registers even if those
174 // registers do not have a definition. With the property enabled virtual
175 // registers must only be used if they have a definition. This property
176 // allows earlier passes in the pipeline to skip updates of `DBG_VALUE`
177 // instructions to save compile time.
178 enum class Property : unsigned {
179 IsSSA,
180 NoPHIs,
182 NoVRegs,
184 Legalized,
186 Selected,
192 };
193
194 bool hasProperty(Property P) const {
195 return Properties[static_cast<unsigned>(P)];
196 }
197
199 Properties.set(static_cast<unsigned>(P));
200 return *this;
201 }
202
204 Properties.reset(static_cast<unsigned>(P));
205 return *this;
206 }
207
208 /// Reset all the properties.
210 Properties.reset();
211 return *this;
212 }
213
215 Properties |= MFP.Properties;
216 return *this;
217 }
218
220 Properties &= ~MFP.Properties;
221 return *this;
222 }
223
224 // Returns true if all properties set in V (i.e. required by a pass) are set
225 // in this.
227 return (Properties | ~V.Properties).all();
228 }
229
230 /// Print the MachineFunctionProperties in human-readable form.
231 void print(raw_ostream &OS) const;
232
233private:
234 std::bitset<static_cast<unsigned>(Property::LastProperty) + 1> Properties;
235};
236
238 /// Filter or finally function. Null indicates a catch-all.
240
241 /// Address of block to recover at. Null for a finally handler.
243};
244
245/// This structure is used to retain landing pad info for the current function.
247 MachineBasicBlock *LandingPadBlock; // Landing pad block.
248 SmallVector<MCSymbol *, 1> BeginLabels; // Labels prior to invoke.
249 SmallVector<MCSymbol *, 1> EndLabels; // Labels after invoke.
250 SmallVector<SEHHandler, 1> SEHHandlers; // SEH handlers active at this lpad.
251 MCSymbol *LandingPadLabel = nullptr; // Label at beginning of landing pad.
252 std::vector<int> TypeIds; // List of type ids (filters negative).
253
255 : LandingPadBlock(MBB) {}
256};
257
258class LLVM_ABI MachineFunction {
259 Function &F;
260 const TargetMachine &Target;
261 const TargetSubtargetInfo *STI;
262 MCContext &Ctx;
263
264 // RegInfo - Information about each register in use in the function.
266
267 // Used to keep track of target-specific per-machine-function information for
268 // the target implementation.
269 MachineFunctionInfo *MFInfo;
270
271 // Keep track of objects allocated on the stack.
272 MachineFrameInfo *FrameInfo;
273
274 // Keep track of constants which are spilled to memory
276
277 // Keep track of jump tables for switch instructions
278 MachineJumpTableInfo *JumpTableInfo;
279
280 // Keep track of the function section.
281 MCSection *Section = nullptr;
282
283 // Catchpad unwind destination info for wasm EH.
284 // Keeps track of Wasm exception handling related data. This will be null for
285 // functions that aren't using a wasm EH personality.
286 WasmEHFuncInfo *WasmEHInfo = nullptr;
287
288 // Keeps track of Windows exception handling related data. This will be null
289 // for functions that aren't using a funclet-based EH personality.
290 WinEHFuncInfo *WinEHInfo = nullptr;
291
292 // Function-level unique numbering for MachineBasicBlocks. When a
293 // MachineBasicBlock is inserted into a MachineFunction is it automatically
294 // numbered and this vector keeps track of the mapping from ID's to MBB's.
295 std::vector<MachineBasicBlock*> MBBNumbering;
296
297 // MBBNumbering epoch, incremented after renumbering to detect use of old
298 // block numbers.
299 unsigned MBBNumberingEpoch = 0;
300
301 // Pool-allocate MachineFunction-lifetime and IR objects.
303
304 // Allocation management for instructions in function.
305 Recycler<MachineInstr> InstructionRecycler;
306
307 // Allocation management for operand arrays on instructions.
308 ArrayRecycler<MachineOperand> OperandRecycler;
309
310 // Allocation management for basic blocks in function.
311 Recycler<MachineBasicBlock> BasicBlockRecycler;
312
313 // List of machine basic blocks in function
315 BasicBlockListType BasicBlocks;
316
317 /// FunctionNumber - This provides a unique ID for each function emitted in
318 /// this translation unit.
319 ///
320 unsigned FunctionNumber;
321
322 /// Alignment - The alignment of the function.
323 Align Alignment;
324
325 /// ExposesReturnsTwice - True if the function calls setjmp or related
326 /// functions with attribute "returns twice", but doesn't have
327 /// the attribute itself.
328 /// This is used to limit optimizations which cannot reason
329 /// about the control flow of such functions.
330 bool ExposesReturnsTwice = false;
331
332 /// True if the function includes any inline assembly.
333 bool HasInlineAsm = false;
334
335 /// True if any WinCFI instruction have been emitted in this function.
336 bool HasWinCFI = false;
337
338 /// Current high-level properties of the IR of the function (e.g. is in SSA
339 /// form or whether registers have been allocated)
340 MachineFunctionProperties Properties;
341
342 // Allocation management for pseudo source values.
343 std::unique_ptr<PseudoSourceValueManager> PSVManager;
344
345 /// List of moves done by a function's prolog. Used to construct frame maps
346 /// by debug and exception handling consumers.
347 std::vector<MCCFIInstruction> FrameInstructions;
348
349 /// List of basic blocks immediately following calls to _setjmp. Used to
350 /// construct a table of valid longjmp targets for Windows Control Flow Guard.
351 std::vector<MCSymbol *> LongjmpTargets;
352
353 /// List of basic blocks that are the target of catchrets. Used to construct
354 /// a table of valid targets for Windows EHCont Guard.
355 std::vector<MCSymbol *> CatchretTargets;
356
357 /// \name Exception Handling
358 /// \{
359
360 /// List of LandingPadInfo describing the landing pad information.
361 std::vector<LandingPadInfo> LandingPads;
362
363 /// Map a landing pad's EH symbol to the call site indexes.
365
366 /// Map a landing pad to its index.
368
369 /// Map of invoke call site index values to associated begin EH_LABEL.
371
372 /// CodeView label annotations.
373 std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations;
374
375 bool CallsEHReturn = false;
376 bool CallsUnwindInit = false;
377 bool HasEHCatchret = false;
378 bool HasEHScopes = false;
379 bool HasEHFunclets = false;
380 bool HasFakeUses = false;
381 bool IsOutlined = false;
382
383 /// BBID to assign to the next basic block of this function.
384 unsigned NextBBID = 0;
385
386 /// Section Type for basic blocks, only relevant with basic block sections.
387 BasicBlockSection BBSectionsType = BasicBlockSection::None;
388
389 /// List of C++ TypeInfo used.
390 std::vector<const GlobalValue *> TypeInfos;
391
392 /// List of typeids encoding filters used.
393 std::vector<unsigned> FilterIds;
394
395 /// List of the indices in FilterIds corresponding to filter terminators.
396 std::vector<unsigned> FilterEnds;
397
398 EHPersonality PersonalityTypeCache = EHPersonality::Unknown;
399
400 /// \}
401
402 /// Clear all the members of this MachineFunction, but the ones used to
403 /// initialize again the MachineFunction. More specifically, this deallocates
404 /// all the dynamically allocated objects and get rids of all the XXXInfo data
405 /// structure, but keeps unchanged the references to Fn, Target, and
406 /// FunctionNumber.
407 void clear();
408 /// Allocate and initialize the different members.
409 /// In particular, the XXXInfo data structure.
410 /// \pre Fn, Target, and FunctionNumber are properly set.
411 void init();
412
413public:
414 /// Description of the location of a variable whose Address is valid and
415 /// unchanging during function execution. The Address may be:
416 /// * A stack index, which can be negative for fixed stack objects.
417 /// * A MCRegister, whose entry value contains the address of the variable.
419 std::variant<int, MCRegister> Address;
420
421 public:
425
427 int Slot, const DILocation *Loc)
428 : Address(Slot), Var(Var), Expr(Expr), Loc(Loc) {}
429
431 MCRegister EntryValReg, const DILocation *Loc)
432 : Address(EntryValReg), Var(Var), Expr(Expr), Loc(Loc) {}
433
434 /// Return true if this variable is in a stack slot.
435 bool inStackSlot() const { return std::holds_alternative<int>(Address); }
436
437 /// Return true if this variable is in the entry value of a register.
438 bool inEntryValueRegister() const {
439 return std::holds_alternative<MCRegister>(Address);
440 }
441
442 /// Returns the stack slot of this variable, assuming `inStackSlot()` is
443 /// true.
444 int getStackSlot() const { return std::get<int>(Address); }
445
446 /// Returns the MCRegister of this variable, assuming
447 /// `inEntryValueRegister()` is true.
449 return std::get<MCRegister>(Address);
450 }
451
452 /// Updates the stack slot of this variable, assuming `inStackSlot()` is
453 /// true.
454 void updateStackSlot(int NewSlot) {
455 assert(inStackSlot());
456 Address = NewSlot;
457 }
458 };
459
460 class Delegate {
461 virtual void anchor();
462
463 public:
464 virtual ~Delegate() = default;
465 /// Callback after an insertion. This should not modify the MI directly.
467 /// Callback before a removal. This should not modify the MI directly.
468 virtual void MF_HandleRemoval(MachineInstr &MI) = 0;
469 /// Callback before changing MCInstrDesc. This should not modify the MI
470 /// directly.
471 virtual void MF_HandleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID) {
472 }
473 };
474
475 /// Structure used to represent pair of argument number after call lowering
476 /// and register used to transfer that argument.
477 /// For now we support only cases when argument is transferred through one
478 /// register.
479 struct ArgRegPair {
482 ArgRegPair(Register R, unsigned Arg) : Reg(R), ArgNo(Arg) {
483 assert(Arg < (1 << 16) && "Arg out of range");
484 }
485 };
486
488 /// Vector of call argument and its forwarding register.
490 };
491
492private:
493 Delegate *TheDelegate = nullptr;
494 GISelChangeObserver *Observer = nullptr;
495
497 /// Map a call instruction to call site arguments forwarding info.
498 CallSiteInfoMap CallSitesInfo;
499
500 /// A helper function that returns call site info for a give call
501 /// instruction if debug entry value support is enabled.
502 CallSiteInfoMap::iterator getCallSiteInfo(const MachineInstr *MI);
503
504 // Callbacks for insertion and removal.
505 void handleInsertion(MachineInstr &MI);
506 void handleRemoval(MachineInstr &MI);
507 friend struct ilist_traits<MachineInstr>;
508
509public:
510 // Need to be accessed from MachineInstr::setDesc.
511 void handleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID);
512
515
516 /// A count of how many instructions in the function have had numbers
517 /// assigned to them. Used for debug value tracking, to determine the
518 /// next instruction number.
519 unsigned DebugInstrNumberingCount = 0;
520
521 /// Set value of DebugInstrNumberingCount field. Avoid using this unless
522 /// you're deserializing this data.
523 void setDebugInstrNumberingCount(unsigned Num);
524
525 /// Pair of instruction number and operand number.
526 using DebugInstrOperandPair = std::pair<unsigned, unsigned>;
527
528 /// Replacement definition for a debug instruction reference. Made up of a
529 /// source instruction / operand pair, destination pair, and a qualifying
530 /// subregister indicating what bits in the operand make up the substitution.
531 // For example, a debug user
532 /// of %1:
533 /// %0:gr32 = someinst, debug-instr-number 1
534 /// %1:gr16 = %0.some_16_bit_subreg, debug-instr-number 2
535 /// Would receive the substitution {{2, 0}, {1, 0}, $subreg}, where $subreg is
536 /// the subregister number for some_16_bit_subreg.
538 public:
539 DebugInstrOperandPair Src; ///< Source instruction / operand pair.
540 DebugInstrOperandPair Dest; ///< Replacement instruction / operand pair.
541 unsigned Subreg; ///< Qualifier for which part of Dest is read.
542
544 const DebugInstrOperandPair &Dest, unsigned Subreg)
545 : Src(Src), Dest(Dest), Subreg(Subreg) {}
546
547 /// Order only by source instruction / operand pair: there should never
548 /// be duplicate entries for the same source in any collection.
549 bool operator<(const DebugSubstitution &Other) const {
550 return Src < Other.Src;
551 }
552 };
553
554 /// Debug value substitutions: a collection of DebugSubstitution objects,
555 /// recording changes in where a value is defined. For example, when one
556 /// instruction is substituted for another. Keeping a record allows recovery
557 /// of variable locations after compilation finishes.
559
560 /// Location of a PHI instruction that is also a debug-info variable value,
561 /// for the duration of register allocation. Loaded by the PHI-elimination
562 /// pass, and emitted as DBG_PHI instructions during VirtRegRewriter, with
563 /// maintenance applied by intermediate passes that edit registers (such as
564 /// coalescing and the allocator passes).
566 public:
567 MachineBasicBlock *MBB; ///< Block where this PHI was originally located.
568 Register Reg; ///< VReg where the control-flow-merge happens.
569 unsigned SubReg; ///< Optional subreg qualifier within Reg.
571 : MBB(MBB), Reg(Reg), SubReg(SubReg) {}
572 };
573
574 /// Map of debug instruction numbers to the position of their PHI instructions
575 /// during register allocation. See DebugPHIRegallocPos.
577
578 /// Flag for whether this function contains DBG_VALUEs (false) or
579 /// DBG_INSTR_REF (true).
580 bool UseDebugInstrRef = false;
581
582 /// Create a substitution between one <instr,operand> value to a different,
583 /// new value.
584 void makeDebugValueSubstitution(DebugInstrOperandPair, DebugInstrOperandPair,
585 unsigned SubReg = 0);
586
587 /// Create substitutions for any tracked values in \p Old, to point at
588 /// \p New. Needed when we re-create an instruction during optimization,
589 /// which has the same signature (i.e., def operands in the same place) but
590 /// a modified instruction type, flags, or otherwise. An example: X86 moves
591 /// are sometimes transformed into equivalent LEAs.
592 /// If the two instructions are not the same opcode, limit which operands to
593 /// examine for substitutions to the first N operands by setting
594 /// \p MaxOperand.
595 void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New,
596 unsigned MaxOperand = UINT_MAX);
597
598 /// Find the underlying defining instruction / operand for a COPY instruction
599 /// while in SSA form. Copies do not actually define values -- they move them
600 /// between registers. Labelling a COPY-like instruction with an instruction
601 /// number is to be avoided as it makes value numbers non-unique later in
602 /// compilation. This method follows the definition chain for any sequence of
603 /// COPY-like instructions to find whatever non-COPY-like instruction defines
604 /// the copied value; or for parameters, creates a DBG_PHI on entry.
605 /// May insert instructions into the entry block!
606 /// \p MI The copy-like instruction to salvage.
607 /// \p DbgPHICache A container to cache already-solved COPYs.
608 /// \returns An instruction/operand pair identifying the defining value.
610 salvageCopySSA(MachineInstr &MI,
612
613 DebugInstrOperandPair salvageCopySSAImpl(MachineInstr &MI);
614
615 /// Finalise any partially emitted debug instructions. These are DBG_INSTR_REF
616 /// instructions where we only knew the vreg of the value they use, not the
617 /// instruction that defines that vreg. Once isel finishes, we should have
618 /// enough information for every DBG_INSTR_REF to point at an instruction
619 /// (or DBG_PHI).
620 void finalizeDebugInstrRefs();
621
622 /// Determine whether, in the current machine configuration, we should use
623 /// instruction referencing or not.
624 bool shouldUseDebugInstrRef() const;
625
626 /// Returns true if the function's variable locations are tracked with
627 /// instruction referencing.
628 bool useDebugInstrRef() const;
629
630 /// Set whether this function will use instruction referencing or not.
631 void setUseDebugInstrRef(bool UseInstrRef);
632
633 /// A reserved operand number representing the instructions memory operand,
634 /// for instructions that have a stack spill fused into them.
635 const static unsigned int DebugOperandMemNumber;
636
638 const TargetSubtargetInfo &STI, MCContext &Ctx,
639 unsigned FunctionNum);
643
644 /// Reset the instance as if it was just created.
645 void reset() {
646 clear();
647 init();
648 }
649
650 /// Reset the currently registered delegate - otherwise assert.
651 void resetDelegate(Delegate *delegate) {
652 assert(TheDelegate == delegate &&
653 "Only the current delegate can perform reset!");
654 TheDelegate = nullptr;
655 }
656
657 /// Set the delegate. resetDelegate must be called before attempting
658 /// to set.
659 void setDelegate(Delegate *delegate) {
660 assert(delegate && !TheDelegate &&
661 "Attempted to set delegate to null, or to change it without "
662 "first resetting it!");
663
664 TheDelegate = delegate;
665 }
666
667 void setObserver(GISelChangeObserver *O) { Observer = O; }
668
669 GISelChangeObserver *getObserver() const { return Observer; }
670
671 MCContext &getContext() const { return Ctx; }
672
673 /// Returns the Section this function belongs to.
674 MCSection *getSection() const { return Section; }
675
676 /// Indicates the Section this function belongs to.
677 void setSection(MCSection *S) { Section = S; }
678
679 PseudoSourceValueManager &getPSVManager() const { return *PSVManager; }
680
681 /// Return the DataLayout attached to the Module associated to this MF.
682 const DataLayout &getDataLayout() const;
683
684 /// Return the LLVM function that this machine code represents
685 Function &getFunction() { return F; }
686
687 /// Return the LLVM function that this machine code represents
688 const Function &getFunction() const { return F; }
689
690 /// getName - Return the name of the corresponding LLVM function.
691 StringRef getName() const;
692
693 /// getFunctionNumber - Return a unique ID for the current function.
694 unsigned getFunctionNumber() const { return FunctionNumber; }
695
696 /// Returns true if this function has basic block sections enabled.
697 bool hasBBSections() const {
698 return (BBSectionsType == BasicBlockSection::All ||
699 BBSectionsType == BasicBlockSection::List ||
700 BBSectionsType == BasicBlockSection::Preset);
701 }
702
703 void setBBSectionsType(BasicBlockSection V) { BBSectionsType = V; }
704
705 /// Assign IsBeginSection IsEndSection fields for basic blocks in this
706 /// function.
707 void assignBeginEndSections();
708
709 /// getTarget - Return the target machine this machine code is compiled with
710 const TargetMachine &getTarget() const { return Target; }
711
712 /// getSubtarget - Return the subtarget for which this machine code is being
713 /// compiled.
714 const TargetSubtargetInfo &getSubtarget() const { return *STI; }
715
716 /// getSubtarget - This method returns a pointer to the specified type of
717 /// TargetSubtargetInfo. In debug builds, it verifies that the object being
718 /// returned is of the correct type.
719 template<typename STC> const STC &getSubtarget() const {
720 return *static_cast<const STC *>(STI);
721 }
722
723 /// getRegInfo - Return information about the registers currently in use.
725 const MachineRegisterInfo &getRegInfo() const { return *RegInfo; }
726
727 /// getFrameInfo - Return the frame info object for the current function.
728 /// This object contains information about objects allocated on the stack
729 /// frame of the current function in an abstract way.
730 MachineFrameInfo &getFrameInfo() { return *FrameInfo; }
731 const MachineFrameInfo &getFrameInfo() const { return *FrameInfo; }
732
733 /// getJumpTableInfo - Return the jump table info object for the current
734 /// function. This object contains information about jump tables in the
735 /// current function. If the current function has no jump tables, this will
736 /// return null.
737 const MachineJumpTableInfo *getJumpTableInfo() const { return JumpTableInfo; }
738 MachineJumpTableInfo *getJumpTableInfo() { return JumpTableInfo; }
739
740 /// getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it
741 /// does already exist, allocate one.
742 MachineJumpTableInfo *getOrCreateJumpTableInfo(unsigned JTEntryKind);
743
744 /// getConstantPool - Return the constant pool object for the current
745 /// function.
748
749 /// getWasmEHFuncInfo - Return information about how the current function uses
750 /// Wasm exception handling. Returns null for functions that don't use wasm
751 /// exception handling.
752 const WasmEHFuncInfo *getWasmEHFuncInfo() const { return WasmEHInfo; }
753 WasmEHFuncInfo *getWasmEHFuncInfo() { return WasmEHInfo; }
754
755 /// getWinEHFuncInfo - Return information about how the current function uses
756 /// Windows exception handling. Returns null for functions that don't use
757 /// funclets for exception handling.
758 const WinEHFuncInfo *getWinEHFuncInfo() const { return WinEHInfo; }
759 WinEHFuncInfo *getWinEHFuncInfo() { return WinEHInfo; }
760
761 /// getAlignment - Return the alignment of the function.
762 Align getAlignment() const { return Alignment; }
763
764 /// setAlignment - Set the alignment of the function.
765 void setAlignment(Align A) { Alignment = A; }
766
767 /// ensureAlignment - Make sure the function is at least A bytes aligned.
769 if (Alignment < A)
770 Alignment = A;
771 }
772
773 /// exposesReturnsTwice - Returns true if the function calls setjmp or
774 /// any other similar functions with attribute "returns twice" without
775 /// having the attribute itself.
776 bool exposesReturnsTwice() const {
777 return ExposesReturnsTwice;
778 }
779
780 /// setCallsSetJmp - Set a flag that indicates if there's a call to
781 /// a "returns twice" function.
783 ExposesReturnsTwice = B;
784 }
785
786 /// Returns true if the function contains any inline assembly.
787 bool hasInlineAsm() const {
788 return HasInlineAsm;
789 }
790
791 /// Set a flag that indicates that the function contains inline assembly.
792 void setHasInlineAsm(bool B) {
793 HasInlineAsm = B;
794 }
795
796 bool hasWinCFI() const {
797 return HasWinCFI;
798 }
799 void setHasWinCFI(bool v) { HasWinCFI = v; }
800
801 /// True if this function needs frame moves for debug or exceptions.
802 bool needsFrameMoves() const;
803
804 /// Get the function properties
805 const MachineFunctionProperties &getProperties() const { return Properties; }
806 MachineFunctionProperties &getProperties() { return Properties; }
807
808 /// getInfo - Keep track of various per-function pieces of information for
809 /// backends that would like to do so.
810 ///
811 template<typename Ty>
812 Ty *getInfo() {
813 return static_cast<Ty*>(MFInfo);
814 }
815
816 template<typename Ty>
817 const Ty *getInfo() const {
818 return static_cast<const Ty *>(MFInfo);
819 }
820
821 template <typename Ty> Ty *cloneInfo(const Ty &Old) {
822 assert(!MFInfo);
823 MFInfo = Ty::template create<Ty>(Allocator, Old);
824 return static_cast<Ty *>(MFInfo);
825 }
826
827 /// Initialize the target specific MachineFunctionInfo
828 void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI);
829
831 const MachineFunction &OrigMF,
833 assert(!MFInfo && "new function already has MachineFunctionInfo");
834 if (!OrigMF.MFInfo)
835 return nullptr;
836 return OrigMF.MFInfo->clone(Allocator, *this, Src2DstMBB);
837 }
838
839 /// Returns the denormal handling type for the default rounding mode of the
840 /// function.
841 DenormalMode getDenormalMode(const fltSemantics &FPType) const;
842
843 /// getBlockNumbered - MachineBasicBlocks are automatically numbered when they
844 /// are inserted into the machine function. The block number for a machine
845 /// basic block can be found by using the MBB::getNumber method, this method
846 /// provides the inverse mapping.
848 assert(N < MBBNumbering.size() && "Illegal block number");
849 assert(MBBNumbering[N] && "Block was removed from the machine function!");
850 return MBBNumbering[N];
851 }
852
853 /// Should we be emitting segmented stack stuff for the function
854 bool shouldSplitStack() const;
855
856 /// getNumBlockIDs - Return the number of MBB ID's allocated.
857 unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); }
858
859 /// Return the numbering "epoch" of block numbers, incremented after each
860 /// numbering. Intended for asserting that no renumbering was performed when
861 /// used by, e.g., preserved analyses.
862 unsigned getBlockNumberEpoch() const { return MBBNumberingEpoch; }
863
864 /// RenumberBlocks - This discards all of the MachineBasicBlock numbers and
865 /// recomputes them. This guarantees that the MBB numbers are sequential,
866 /// dense, and match the ordering of the blocks within the function. If a
867 /// specific MachineBasicBlock is specified, only that block and those after
868 /// it are renumbered.
869 void RenumberBlocks(MachineBasicBlock *MBBFrom = nullptr);
870
871 /// Return an estimate of the function's code size,
872 /// taking into account block and function alignment
874
875 /// print - Print out the MachineFunction in a format suitable for debugging
876 /// to the specified stream.
877 void print(raw_ostream &OS, const SlotIndexes* = nullptr) const;
878
879 /// viewCFG - This function is meant for use from the debugger. You can just
880 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
881 /// program, displaying the CFG of the current function with the code for each
882 /// basic block inside. This depends on there being a 'dot' and 'gv' program
883 /// in your path.
884 void viewCFG() const;
885
886 /// viewCFGOnly - This function is meant for use from the debugger. It works
887 /// just like viewCFG, but it does not include the contents of basic blocks
888 /// into the nodes, just the label. If you are only interested in the CFG
889 /// this can make the graph smaller.
890 ///
891 void viewCFGOnly() const;
892
893 /// dump - Print the current MachineFunction to cerr, useful for debugger use.
894 void dump() const;
895
896 /// Run the current MachineFunction through the machine code verifier, useful
897 /// for debugger use.
898 /// \returns true if no problems were found.
899 bool verify(Pass *p = nullptr, const char *Banner = nullptr,
900 raw_ostream *OS = nullptr, bool AbortOnError = true) const;
901
902 /// Run the current MachineFunction through the machine code verifier, useful
903 /// for debugger use.
904 /// \returns true if no problems were found.
905 bool verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
906 const char *Banner = nullptr, raw_ostream *OS = nullptr,
907 bool AbortOnError = true) const;
908
909 // Provide accessors for the MachineBasicBlock list...
914
915 /// Support for MachineBasicBlock::getNextNode().
918 return &MachineFunction::BasicBlocks;
919 }
920
921 /// addLiveIn - Add the specified physical register as a live-in value and
922 /// create a corresponding virtual register for it.
924
925 //===--------------------------------------------------------------------===//
926 // BasicBlock accessor functions.
927 //
928 iterator begin() { return BasicBlocks.begin(); }
929 const_iterator begin() const { return BasicBlocks.begin(); }
930 iterator end () { return BasicBlocks.end(); }
931 const_iterator end () const { return BasicBlocks.end(); }
932
933 reverse_iterator rbegin() { return BasicBlocks.rbegin(); }
934 const_reverse_iterator rbegin() const { return BasicBlocks.rbegin(); }
935 reverse_iterator rend () { return BasicBlocks.rend(); }
936 const_reverse_iterator rend () const { return BasicBlocks.rend(); }
937
938 unsigned size() const { return (unsigned)BasicBlocks.size();}
939 bool empty() const { return BasicBlocks.empty(); }
940 const MachineBasicBlock &front() const { return BasicBlocks.front(); }
941 MachineBasicBlock &front() { return BasicBlocks.front(); }
942 const MachineBasicBlock & back() const { return BasicBlocks.back(); }
943 MachineBasicBlock & back() { return BasicBlocks.back(); }
944
945 void push_back (MachineBasicBlock *MBB) { BasicBlocks.push_back (MBB); }
948 BasicBlocks.insert(MBBI, MBB);
949 }
950 void splice(iterator InsertPt, iterator MBBI) {
951 BasicBlocks.splice(InsertPt, BasicBlocks, MBBI);
952 }
954 BasicBlocks.splice(InsertPt, BasicBlocks, MBB);
955 }
956 void splice(iterator InsertPt, iterator MBBI, iterator MBBE) {
957 BasicBlocks.splice(InsertPt, BasicBlocks, MBBI, MBBE);
958 }
959
960 void remove(iterator MBBI) { BasicBlocks.remove(MBBI); }
961 void remove(MachineBasicBlock *MBBI) { BasicBlocks.remove(MBBI); }
962 void erase(iterator MBBI) { BasicBlocks.erase(MBBI); }
963 void erase(MachineBasicBlock *MBBI) { BasicBlocks.erase(MBBI); }
964
965 template <typename Comp>
966 void sort(Comp comp) {
967 BasicBlocks.sort(comp);
968 }
969
970 /// Return the number of \p MachineInstrs in this \p MachineFunction.
971 unsigned getInstructionCount() const {
972 unsigned InstrCount = 0;
973 for (const MachineBasicBlock &MBB : BasicBlocks)
974 InstrCount += MBB.size();
975 return InstrCount;
976 }
977
978 //===--------------------------------------------------------------------===//
979 // Internal functions used to automatically number MachineBasicBlocks
980
981 /// Adds the MBB to the internal numbering. Returns the unique number
982 /// assigned to the MBB.
984 MBBNumbering.push_back(MBB);
985 return (unsigned)MBBNumbering.size()-1;
986 }
987
988 /// removeFromMBBNumbering - Remove the specific machine basic block from our
989 /// tracker, this is only really to be used by the MachineBasicBlock
990 /// implementation.
991 void removeFromMBBNumbering(unsigned N) {
992 assert(N < MBBNumbering.size() && "Illegal basic block #");
993 MBBNumbering[N] = nullptr;
994 }
995
996 /// CreateMachineInstr - Allocate a new MachineInstr. Use this instead
997 /// of `new MachineInstr'.
998 MachineInstr *CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL,
999 bool NoImplicit = false);
1000
1001 /// Create a new MachineInstr which is a copy of \p Orig, identical in all
1002 /// ways except the instruction has no parent, prev, or next. Bundling flags
1003 /// are reset.
1004 ///
1005 /// Note: Clones a single instruction, not whole instruction bundles.
1006 /// Does not perform target specific adjustments; consider using
1007 /// TargetInstrInfo::duplicate() instead.
1008 MachineInstr *CloneMachineInstr(const MachineInstr *Orig);
1009
1010 /// Clones instruction or the whole instruction bundle \p Orig and insert
1011 /// into \p MBB before \p InsertBefore.
1012 ///
1013 /// Note: Does not perform target specific adjustments; consider using
1014 /// TargetInstrInfo::duplicate() instead.
1015 MachineInstr &
1016 cloneMachineInstrBundle(MachineBasicBlock &MBB,
1017 MachineBasicBlock::iterator InsertBefore,
1018 const MachineInstr &Orig);
1019
1020 /// DeleteMachineInstr - Delete the given MachineInstr.
1021 void deleteMachineInstr(MachineInstr *MI);
1022
1023 /// CreateMachineBasicBlock - Allocate a new MachineBasicBlock. Use this
1024 /// instead of `new MachineBasicBlock'. Sets `MachineBasicBlock::BBID` if
1025 /// basic-block-sections is enabled for the function.
1027 CreateMachineBasicBlock(const BasicBlock *BB = nullptr,
1028 std::optional<UniqueBBID> BBID = std::nullopt);
1029
1030 /// DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
1031 void deleteMachineBasicBlock(MachineBasicBlock *MBB);
1032
1033 /// getMachineMemOperand - Allocate a new MachineMemOperand.
1034 /// MachineMemOperands are owned by the MachineFunction and need not be
1035 /// explicitly deallocated.
1038 Align base_alignment, const AAMDNodes &AAInfo = AAMDNodes(),
1039 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1040 AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
1041 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
1044 Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
1045 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1046 AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
1047 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
1050 Align BaseAlignment, const AAMDNodes &AAInfo = AAMDNodes(),
1051 const MDNode *Ranges = nullptr, SyncScope::ID SSID = SyncScope::System,
1052 AtomicOrdering Ordering = AtomicOrdering::NotAtomic,
1053 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic) {
1054 return getMachineMemOperand(PtrInfo, F, LocationSize::precise(Size),
1055 BaseAlignment, AAInfo, Ranges, SSID, Ordering,
1056 FailureOrdering);
1057 }
1058
1059 /// getMachineMemOperand - Allocate a new MachineMemOperand by copying
1060 /// an existing one, adjusting by an offset and using the given size.
1061 /// MachineMemOperands are owned by the MachineFunction and need not be
1062 /// explicitly deallocated.
1064 int64_t Offset, LLT Ty);
1066 int64_t Offset, LocationSize Size) {
1067 return getMachineMemOperand(
1068 MMO, Offset,
1069 !Size.hasValue() ? LLT()
1070 : Size.isScalable()
1071 ? LLT::scalable_vector(1, 8 * Size.getValue().getKnownMinValue())
1072 : LLT::scalar(8 * Size.getValue().getKnownMinValue()));
1073 }
1075 int64_t Offset, uint64_t Size) {
1076 return getMachineMemOperand(MMO, Offset, LocationSize::precise(Size));
1077 }
1078
1079 /// getMachineMemOperand - Allocate a new MachineMemOperand by copying
1080 /// an existing one, replacing only the MachinePointerInfo and size.
1081 /// MachineMemOperands are owned by the MachineFunction and need not be
1082 /// explicitly deallocated.
1084 const MachinePointerInfo &PtrInfo,
1087 const MachinePointerInfo &PtrInfo,
1088 LLT Ty);
1090 const MachinePointerInfo &PtrInfo,
1091 uint64_t Size) {
1092 return getMachineMemOperand(MMO, PtrInfo, LocationSize::precise(Size));
1093 }
1094
1095 /// Allocate a new MachineMemOperand by copying an existing one,
1096 /// replacing only AliasAnalysis information. MachineMemOperands are owned
1097 /// by the MachineFunction and need not be explicitly deallocated.
1099 const AAMDNodes &AAInfo);
1100
1101 /// Allocate a new MachineMemOperand by copying an existing one,
1102 /// replacing the flags. MachineMemOperands are owned
1103 /// by the MachineFunction and need not be explicitly deallocated.
1106
1108
1109 /// Allocate an array of MachineOperands. This is only intended for use by
1110 /// internal MachineInstr functions.
1112 return OperandRecycler.allocate(Cap, Allocator);
1113 }
1114
1115 /// Dellocate an array of MachineOperands and recycle the memory. This is
1116 /// only intended for use by internal MachineInstr functions.
1117 /// Cap must be the same capacity that was used to allocate the array.
1119 OperandRecycler.deallocate(Cap, Array);
1120 }
1121
1122 /// Allocate and initialize a register mask with @p NumRegister bits.
1123 uint32_t *allocateRegMask();
1124
1125 ArrayRef<int> allocateShuffleMask(ArrayRef<int> Mask);
1126
1127 /// Allocate and construct an extra info structure for a `MachineInstr`.
1128 ///
1129 /// This is allocated on the function's allocator and so lives the life of
1130 /// the function.
1131 MachineInstr::ExtraInfo *createMIExtraInfo(
1132 ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol = nullptr,
1133 MCSymbol *PostInstrSymbol = nullptr, MDNode *HeapAllocMarker = nullptr,
1134 MDNode *PCSections = nullptr, uint32_t CFIType = 0,
1135 MDNode *MMRAs = nullptr);
1136
1137 /// Allocate a string and populate it with the given external symbol name.
1138 const char *createExternalSymbolName(StringRef Name);
1139
1140 //===--------------------------------------------------------------------===//
1141 // Label Manipulation.
1142
1143 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
1144 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
1145 /// normal 'L' label is returned.
1146 MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
1147 bool isLinkerPrivate = false) const;
1148
1149 /// getPICBaseSymbol - Return a function-local symbol to represent the PIC
1150 /// base.
1151 MCSymbol *getPICBaseSymbol() const;
1152
1153 /// Returns a reference to a list of cfi instructions in the function's
1154 /// prologue. Used to construct frame maps for debug and exception handling
1155 /// comsumers.
1156 const std::vector<MCCFIInstruction> &getFrameInstructions() const {
1157 return FrameInstructions;
1158 }
1159
1160 [[nodiscard]] unsigned addFrameInst(const MCCFIInstruction &Inst);
1161
1162 /// Returns a reference to a list of symbols immediately following calls to
1163 /// _setjmp in the function. Used to construct the longjmp target table used
1164 /// by Windows Control Flow Guard.
1165 const std::vector<MCSymbol *> &getLongjmpTargets() const {
1166 return LongjmpTargets;
1167 }
1168
1169 /// Add the specified symbol to the list of valid longjmp targets for Windows
1170 /// Control Flow Guard.
1171 void addLongjmpTarget(MCSymbol *Target) { LongjmpTargets.push_back(Target); }
1172
1173 /// Returns a reference to a list of symbols that we have catchrets.
1174 /// Used to construct the catchret target table used by Windows EHCont Guard.
1175 const std::vector<MCSymbol *> &getCatchretTargets() const {
1176 return CatchretTargets;
1177 }
1178
1179 /// Add the specified symbol to the list of valid catchret targets for Windows
1180 /// EHCont Guard.
1182 CatchretTargets.push_back(Target);
1183 }
1184
1185 /// \name Exception Handling
1186 /// \{
1187
1188 bool callsEHReturn() const { return CallsEHReturn; }
1189 void setCallsEHReturn(bool b) { CallsEHReturn = b; }
1190
1191 bool callsUnwindInit() const { return CallsUnwindInit; }
1192 void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
1193
1194 bool hasEHCatchret() const { return HasEHCatchret; }
1195 void setHasEHCatchret(bool V) { HasEHCatchret = V; }
1196
1197 bool hasEHScopes() const { return HasEHScopes; }
1198 void setHasEHScopes(bool V) { HasEHScopes = V; }
1199
1200 bool hasEHFunclets() const { return HasEHFunclets; }
1201 void setHasEHFunclets(bool V) { HasEHFunclets = V; }
1202
1203 bool hasFakeUses() const { return HasFakeUses; }
1204 void setHasFakeUses(bool V) { HasFakeUses = V; }
1205
1206 bool isOutlined() const { return IsOutlined; }
1207 void setIsOutlined(bool V) { IsOutlined = V; }
1208
1209 /// Find or create an LandingPadInfo for the specified MachineBasicBlock.
1210 LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad);
1211
1212 /// Return a reference to the landing pad info for the current function.
1213 const std::vector<LandingPadInfo> &getLandingPads() const {
1214 return LandingPads;
1215 }
1216
1217 /// Provide the begin and end labels of an invoke style call and associate it
1218 /// with a try landing pad block.
1219 void addInvoke(MachineBasicBlock *LandingPad,
1220 MCSymbol *BeginLabel, MCSymbol *EndLabel);
1221
1222 /// Add a new panding pad, and extract the exception handling information from
1223 /// the landingpad instruction. Returns the label ID for the landing pad
1224 /// entry.
1225 MCSymbol *addLandingPad(MachineBasicBlock *LandingPad);
1226
1227 /// Return the type id for the specified typeinfo. This is function wide.
1228 unsigned getTypeIDFor(const GlobalValue *TI);
1229
1230 /// Return the id of the filter encoded by TyIds. This is function wide.
1231 int getFilterIDFor(ArrayRef<unsigned> TyIds);
1232
1233 /// Map the landing pad's EH symbol to the call site indexes.
1234 void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef<unsigned> Sites);
1235
1236 /// Return if there is any wasm exception handling.
1238 return !WasmLPadToIndexMap.empty();
1239 }
1240
1241 /// Map the landing pad to its index. Used for Wasm exception handling.
1242 void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index) {
1243 WasmLPadToIndexMap[LPad] = Index;
1244 }
1245
1246 /// Returns true if the landing pad has an associate index in wasm EH.
1248 return WasmLPadToIndexMap.count(LPad);
1249 }
1250
1251 /// Get the index in wasm EH for a given landing pad.
1252 unsigned getWasmLandingPadIndex(const MachineBasicBlock *LPad) const {
1253 assert(hasWasmLandingPadIndex(LPad));
1254 return WasmLPadToIndexMap.lookup(LPad);
1255 }
1256
1258 return !LPadToCallSiteMap.empty();
1259 }
1260
1261 /// Get the call site indexes for a landing pad EH symbol.
1263 assert(hasCallSiteLandingPad(Sym) &&
1264 "missing call site number for landing pad!");
1265 return LPadToCallSiteMap[Sym];
1266 }
1267
1268 /// Return true if the landing pad Eh symbol has an associated call site.
1270 return !LPadToCallSiteMap[Sym].empty();
1271 }
1272
1273 bool hasAnyCallSiteLabel() const {
1274 return !CallSiteMap.empty();
1275 }
1276
1277 /// Map the begin label for a call site.
1278 void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site) {
1279 CallSiteMap[BeginLabel] = Site;
1280 }
1281
1282 /// Get the call site number for a begin label.
1283 unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const {
1284 assert(hasCallSiteBeginLabel(BeginLabel) &&
1285 "Missing call site number for EH_LABEL!");
1286 return CallSiteMap.lookup(BeginLabel);
1287 }
1288
1289 /// Return true if the begin label has a call site number associated with it.
1290 bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) const {
1291 return CallSiteMap.count(BeginLabel);
1292 }
1293
1294 /// Record annotations associated with a particular label.
1296 CodeViewAnnotations.push_back({Label, MD});
1297 }
1298
1300 return CodeViewAnnotations;
1301 }
1302
1303 /// Return a reference to the C++ typeinfo for the current function.
1304 const std::vector<const GlobalValue *> &getTypeInfos() const {
1305 return TypeInfos;
1306 }
1307
1308 /// Return a reference to the typeids encoding filters used in the current
1309 /// function.
1310 const std::vector<unsigned> &getFilterIds() const {
1311 return FilterIds;
1312 }
1313
1314 /// \}
1315
1316 /// Collect information used to emit debugging information of a variable in a
1317 /// stack slot.
1319 int Slot, const DILocation *Loc) {
1320 VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc);
1321 }
1322
1323 /// Collect information used to emit debugging information of a variable in
1324 /// the entry value of a register.
1326 MCRegister Reg, const DILocation *Loc) {
1327 VariableDbgInfos.emplace_back(Var, Expr, Reg, Loc);
1328 }
1329
1330 VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfos; }
1332 return VariableDbgInfos;
1333 }
1334
1335 /// Returns the collection of variables for which we have debug info and that
1336 /// have been assigned a stack slot.
1338 return make_filter_range(getVariableDbgInfo(), [](auto &VarInfo) {
1339 return VarInfo.inStackSlot();
1340 });
1341 }
1342
1343 /// Returns the collection of variables for which we have debug info and that
1344 /// have been assigned a stack slot.
1346 return make_filter_range(getVariableDbgInfo(), [](const auto &VarInfo) {
1347 return VarInfo.inStackSlot();
1348 });
1349 }
1350
1351 /// Returns the collection of variables for which we have debug info and that
1352 /// have been assigned an entry value register.
1354 return make_filter_range(getVariableDbgInfo(), [](const auto &VarInfo) {
1355 return VarInfo.inEntryValueRegister();
1356 });
1357 }
1358
1359 /// Start tracking the arguments passed to the call \p CallI.
1362 bool Inserted =
1363 CallSitesInfo.try_emplace(CallI, std::move(CallInfo)).second;
1364 (void)Inserted;
1365 assert(Inserted && "Call site info not unique");
1366 }
1367
1369 return CallSitesInfo;
1370 }
1371
1372 /// Following functions update call site info. They should be called before
1373 /// removing, replacing or copying call instruction.
1374
1375 /// Erase the call site info for \p MI. It is used to remove a call
1376 /// instruction from the instruction stream.
1377 void eraseCallSiteInfo(const MachineInstr *MI);
1378 /// Copy the call site info from \p Old to \ New. Its usage is when we are
1379 /// making a copy of the instruction that will be inserted at different point
1380 /// of the instruction stream.
1381 void copyCallSiteInfo(const MachineInstr *Old,
1382 const MachineInstr *New);
1383
1384 /// Move the call site info from \p Old to \New call site info. This function
1385 /// is used when we are replacing one call instruction with another one to
1386 /// the same callee.
1387 void moveCallSiteInfo(const MachineInstr *Old,
1388 const MachineInstr *New);
1389
1391 return ++DebugInstrNumberingCount;
1392 }
1393};
1394
1395//===--------------------------------------------------------------------===//
1396// GraphTraits specializations for function basic block graphs (CFGs)
1397//===--------------------------------------------------------------------===//
1398
1399// Provide specializations of GraphTraits to be able to treat a
1400// machine function as a graph of machine basic blocks... these are
1401// the same as the machine basic block iterators, except that the root
1402// node is implicitly the first node of the function.
1403//
1404template <> struct GraphTraits<MachineFunction*> :
1406 static NodeRef getEntryNode(MachineFunction *F) { return &F->front(); }
1407
1408 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
1410
1412 return nodes_iterator(F->begin());
1413 }
1414
1416 return nodes_iterator(F->end());
1417 }
1418
1419 static unsigned size (MachineFunction *F) { return F->size(); }
1420
1421 static unsigned getMaxNumber(MachineFunction *F) {
1422 return F->getNumBlockIDs();
1423 }
1425 return F->getBlockNumberEpoch();
1426 }
1427};
1428template <> struct GraphTraits<const MachineFunction*> :
1430 static NodeRef getEntryNode(const MachineFunction *F) { return &F->front(); }
1431
1432 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
1434
1436 return nodes_iterator(F->begin());
1437 }
1438
1440 return nodes_iterator(F->end());
1441 }
1442
1443 static unsigned size (const MachineFunction *F) {
1444 return F->size();
1445 }
1446
1447 static unsigned getMaxNumber(const MachineFunction *F) {
1448 return F->getNumBlockIDs();
1449 }
1450 static unsigned getNumberEpoch(const MachineFunction *F) {
1451 return F->getBlockNumberEpoch();
1452 }
1453};
1454
1455// Provide specializations of GraphTraits to be able to treat a function as a
1456// graph of basic blocks... and to walk it in inverse order. Inverse order for
1457// a function is considered to be when traversing the predecessor edges of a BB
1458// instead of the successor edges.
1459//
1460template <> struct GraphTraits<Inverse<MachineFunction*>> :
1463 return &G.Graph->front();
1464 }
1465
1466 static unsigned getMaxNumber(MachineFunction *F) {
1467 return F->getNumBlockIDs();
1468 }
1470 return F->getBlockNumberEpoch();
1471 }
1472};
1476 return &G.Graph->front();
1477 }
1478
1479 static unsigned getMaxNumber(const MachineFunction *F) {
1480 return F->getNumBlockIDs();
1481 }
1482 static unsigned getNumberEpoch(const MachineFunction *F) {
1483 return F->getBlockNumberEpoch();
1484 }
1485};
1486
1487void verifyMachineFunction(const std::string &Banner,
1488 const MachineFunction &MF);
1489
1490} // end namespace llvm
1491
1492#endif // LLVM_CODEGEN_MACHINEFUNCTION_H
unsigned SubReg
aarch64 AArch64 CCMP Pass
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< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI, const BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
Definition: CFGPrinter.cpp:82
static unsigned InstrCount
This file defines the DenseMap class.
std::string Name
uint32_t Index
uint64_t Size
std::optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1313
uint64_t Offset
Definition: ELF_riscv.cpp:478
Symbol * Sym
Definition: ELF_riscv.cpp:479
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:55
#define G(x, y, z)
Definition: MD5.cpp:56
unsigned 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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
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.
Definition: ArrayRecycler.h:71
Recycle small arrays allocated from a BumpPtrAllocator.
Definition: ArrayRecycler.h:28
T * allocate(Capacity Cap, AllocatorType &Allocator)
Allocate an array of at least the requested capacity.
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
LLVM Basic Block Representation.
Definition: BasicBlock.h:61
The address of a basic block.
Definition: Constants.h:893
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
DWARF expression.
Debug location.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
A debug info location.
Definition: DebugLoc.h:33
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:194
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition: DenseMap.h:226
bool empty() const
Definition: DenseMap.h:98
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
Definition: DenseMap.h:152
Abstract class that contains various methods for clients to notify about changes.
Context object for machine code objects.
Definition: MCContext.h:83
Describe properties that are true of each instruction in the target description file.
Definition: MCInstrDesc.h:198
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Metadata node.
Definition: Metadata.h:1069
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 & set(const MachineFunctionProperties &MFP)
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)
Location of a PHI instruction that is also a debug-info variable value, for the duration of register ...
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.
Replacement definition for a debug instruction reference.
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.
Description of the location of a variable whose Address is valid and unchanging during function execu...
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
void setHasEHFunclets(bool V)
std::pair< unsigned, unsigned > DebugInstrOperandPair
Pair of instruction number and operand number.
ArrayRecycler< MachineOperand >::Capacity OperandCapacity
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
PseudoSourceValueManager & getPSVManager() const
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 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.
void setHasEHCatchret(bool V)
MachineFunction & operator=(const MachineFunction &)=delete
bool hasInlineAsm() const
Returns true if the function contains any inline assembly.
void setCallsEHReturn(bool b)
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()
GISelChangeObserver * getObserver() const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
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.
bool callsUnwindInit() const
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()
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 size() const
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()
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 addCatchretTarget(MCSymbol *Target)
Add the specified symbol to the list of valid catchret targets for Windows EHCont Guard.
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)
unsigned getBlockNumberEpoch() const
Return the numbering "epoch" of block numbers, incremented after each numbering.
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.
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
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().
void sort(Comp comp)
bool hasWasmLandingPadIndex(const MachineBasicBlock *LPad) const
Returns true if the landing pad has an associate index in wasm EH.
const MachineFunctionProperties & getProperties() const
Get the function properties.
Ty * cloneInfo(const Ty &Old)
const std::vector< MCSymbol * > & getCatchretTargets() const
Returns a reference to a list of symbols that we have catchrets.
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
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const_reverse_iterator rend() const
bool hasAnyCallSiteLandingPad() const
WasmEHFuncInfo * getWasmEHFuncInfo()
void splice(iterator InsertPt, iterator MBBI)
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
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.
Definition: MachineInstr.h:69
bool isCandidateForCallSiteEntry(QueryType Type=IgnoreBundle) const
Return true if this is a call instruction that may have an associated call site entry in the debug in...
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:94
Manages creation of pseudo source values.
Recycler - This class manages a linked-list of deallocated nodes and facilitates reusing deallocated ...
Definition: Recycler.h:34
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
SlotIndexes pass.
Definition: SlotIndexes.h:297
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
reference emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:937
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: SmallVector.h:254
std::reverse_iterator< iterator > reverse_iterator
Definition: SmallVector.h:255
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
TargetSubtargetInfo - Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
void splice(iterator where, iplist_impl &L2)
Definition: ilist.h:266
void push_back(pointer val)
Definition: ilist.h:250
iterator erase(iterator where)
Definition: ilist.h:204
pointer remove(iterator &IT)
Definition: ilist.h:188
void push_front(pointer val)
Definition: ilist.h:249
iterator insert(iterator where, pointer New)
Definition: ilist.h:165
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
Definition: ilist.h:328
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This file defines classes to implement an intrusive doubly linked list class (i.e.
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
@ BlockAddress
Definition: ISDOpcodes.h:84
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
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:573
AtomicOrdering
Atomic ordering for LLVM's memory model.
BasicBlockSection
Definition: TargetOptions.h:61
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:760
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)
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)
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)
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)
Structure used to represent pair of argument number after call lowering and register used to transfer...
ArgRegPair(Register R, unsigned Arg)
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.
Use delete by default for iplist and ilist.
Definition: ilist.h:41
static void deleteNode(NodeTy *V)
Definition: ilist.h:42
void transferNodesFromList(ilist_callback_traits &OldList, Iterator, Iterator)
Callbacks do nothing by default in iplist and ilist.
Definition: ilist.h:65
void removeNodeFromList(NodeTy *)
Definition: ilist.h:67
void addNodeToList(NodeTy *)
Definition: ilist.h:66
Template traits for intrusive list.
Definition: ilist.h:90