LLVM 24.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;
73class MCRegisterClass;
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
274/// This structure is used to retain landing pad info for the current function.
276 MachineBasicBlock *LandingPadBlock; // Landing pad block.
277 SmallVector<MCSymbol *, 1> BeginLabels; // Labels prior to invoke.
278 SmallVector<MCSymbol *, 1> EndLabels; // Labels after invoke.
279 MCSymbol *LandingPadLabel = nullptr; // Label at beginning of landing pad.
280 std::vector<int> TypeIds; // List of type ids (filters negative).
281
284};
285
287 Function &F;
288 const TargetMachine &Target;
289 const TargetSubtargetInfo &STI;
290 MCContext &Ctx;
291
292 // RegInfo - Information about each register in use in the function.
293 MachineRegisterInfo *RegInfo;
294
295 // Used to keep track of target-specific per-machine-function information for
296 // the target implementation.
297 MachineFunctionInfo *MFInfo;
298
299 // Keep track of objects allocated on the stack.
300 MachineFrameInfo *FrameInfo;
301
302 // Keep track of constants which are spilled to memory
303 MachineConstantPool *ConstantPool;
304
305 // Keep track of jump tables for switch instructions
306 MachineJumpTableInfo *JumpTableInfo;
307
308 // Keep track of the function section.
309 MCSection *Section = nullptr;
310
311 // Keeps track of Windows exception handling related data. This will be null
312 // for functions that aren't using a funclet-based EH personality.
313 WinEHFuncInfo *WinEHInfo = nullptr;
314
315 // Function-level unique numbering for MachineBasicBlocks. When a
316 // MachineBasicBlock is inserted into a MachineFunction is it automatically
317 // numbered and this vector keeps track of the mapping from ID's to MBB's.
318 std::vector<MachineBasicBlock*> MBBNumbering;
319
320 // Analysis number epoch, currently never changed as we don't renumber the
321 // block numbers used for analyses.
322 unsigned AnalysisNumberingEpoch = 0;
323
324 // Next MBB analysis number.
325 unsigned NextAnalysisNumber = 0;
326
327 // Pool-allocate MachineFunction-lifetime and IR objects.
328 BumpPtrAllocator Allocator;
329
330 // Allocation management for instructions in function.
331 Recycler<MachineInstr> InstructionRecycler;
332
333 // Allocation management for operand arrays on instructions.
334 ArrayRecycler<MachineOperand> OperandRecycler;
335
336 // Allocation management for basic blocks in function.
337 Recycler<MachineBasicBlock> BasicBlockRecycler;
338
339 // List of machine basic blocks in function
340 using BasicBlockListType = ilist<MachineBasicBlock>;
341 BasicBlockListType BasicBlocks;
342
343 /// FunctionNumber - This provides a unique ID for each function emitted in
344 /// this translation unit.
345 ///
346 unsigned FunctionNumber;
347
348 /// Alignment - The alignment of the function.
349 Align Alignment;
350
351 /// ExposesReturnsTwice - True if the function calls setjmp or related
352 /// functions with attribute "returns twice", but doesn't have
353 /// the attribute itself.
354 /// This is used to limit optimizations which cannot reason
355 /// about the control flow of such functions.
356 bool ExposesReturnsTwice = false;
357
358 /// True if the function includes any inline assembly.
359 bool HasInlineAsm = false;
360
361 /// True if any WinCFI instruction have been emitted in this function.
362 bool HasWinCFI = false;
363
364 /// Current high-level properties of the IR of the function (e.g. is in SSA
365 /// form or whether registers have been allocated)
366 MachineFunctionProperties Properties;
367
368 // Allocation management for pseudo source values.
369 std::unique_ptr<PseudoSourceValueManager> PSVManager;
370
371 /// List of moves done by a function's prolog. Used to construct frame maps
372 /// by debug and exception handling consumers.
373 std::vector<MCCFIInstruction> FrameInstructions;
374
375 /// List of basic blocks immediately following calls to _setjmp. Used to
376 /// construct a table of valid longjmp targets for Windows Control Flow Guard.
377 std::vector<MCSymbol *> LongjmpTargets;
378
379 /// List of basic blocks that are the targets for Windows EH Continuation
380 /// Guard.
381 std::vector<MCSymbol *> EHContTargets;
382
383 /// \name Exception Handling
384 /// \{
385
386 /// List of LandingPadInfo describing the landing pad information.
387 std::vector<LandingPadInfo> LandingPads;
388
389 /// Map a landing pad's EH symbol to the call site indexes.
391
392 /// Map a landing pad to its index.
394
395 /// Map of invoke call site index values to associated begin EH_LABEL.
397
398 /// CodeView label annotations.
399 std::vector<std::pair<MCSymbol *, MDNode *>> CodeViewAnnotations;
400
401 bool CallsEHReturn = false;
402 bool CallsUnwindInit = false;
403 bool HasEHContTarget = false;
404 bool HasEHScopes = false;
405 bool HasEHFunclets = false;
406 bool HasFakeUses = false;
407 bool IsOutlined = false;
408
409 /// BBID to assign to the next basic block of this function.
410 unsigned NextBBID = 0;
411
412 /// Section Type for basic blocks, only relevant with basic block sections.
414
415 /// Prefetch targets in this function. This includes targets that are mapped
416 /// to a basic block and dangling targets.
418
419 /// List of C++ TypeInfo used.
420 std::vector<const GlobalValue *> TypeInfos;
421
422 /// List of typeids encoding filters used.
423 std::vector<unsigned> FilterIds;
424
425 /// List of the indices in FilterIds corresponding to filter terminators.
426 std::vector<unsigned> FilterEnds;
427
428 /// \}
429
430 /// Clear all the members of this MachineFunction, but the ones used to
431 /// initialize again the MachineFunction. More specifically, this deallocates
432 /// all the dynamically allocated objects and get rids of all the XXXInfo data
433 /// structure, but keeps unchanged the references to Fn, Target, and
434 /// FunctionNumber.
435 void clear();
436 /// Allocate and initialize the different members.
437 /// In particular, the XXXInfo data structure.
438 /// \pre Fn, Target, and FunctionNumber are properly set.
439 void init();
440
441public:
442 /// Description of the location of a variable whose Address is valid and
443 /// unchanging during function execution. The Address may be:
444 /// * A stack index, which can be negative for fixed stack objects.
445 /// * A MCRegister, whose entry value contains the address of the variable.
447 std::variant<int, MCRegister> Address;
448
449 public:
453
455 int Slot, const DILocation *Loc)
456 : Address(Slot), Var(Var), Expr(Expr), Loc(Loc) {}
457
459 MCRegister EntryValReg, const DILocation *Loc)
460 : Address(EntryValReg), Var(Var), Expr(Expr), Loc(Loc) {}
461
462 /// Return true if this variable is in a stack slot.
463 bool inStackSlot() const { return std::holds_alternative<int>(Address); }
464
465 /// Return true if this variable is in the entry value of a register.
466 bool inEntryValueRegister() const {
467 return std::holds_alternative<MCRegister>(Address);
468 }
469
470 /// Returns the stack slot of this variable, assuming `inStackSlot()` is
471 /// true.
472 int getStackSlot() const { return std::get<int>(Address); }
473
474 /// Returns the MCRegister of this variable, assuming
475 /// `inEntryValueRegister()` is true.
477 return std::get<MCRegister>(Address);
478 }
479
480 /// Updates the stack slot of this variable, assuming `inStackSlot()` is
481 /// true.
482 void updateStackSlot(int NewSlot) {
484 Address = NewSlot;
485 }
486 };
487
489 virtual void anchor();
490
491 public:
492 virtual ~Delegate() = default;
493 /// Callback after an insertion. This should not modify the MI directly.
495 /// Callback before a removal. This should not modify the MI directly.
496 virtual void MF_HandleRemoval(MachineInstr &MI) = 0;
497 /// Callback before changing MCInstrDesc. This should not modify the MI
498 /// directly.
499 virtual void MF_HandleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID) {
500 }
501 };
502
503 /// Structure used to represent pair of argument number after call lowering
504 /// and register used to transfer that argument.
505 /// For now we support only cases when argument is transferred through one
506 /// register.
507 struct ArgRegPair {
510 ArgRegPair(Register R, unsigned Arg) : Reg(R), ArgNo(Arg) {
511 assert(Arg < (1 << 16) && "Arg out of range");
512 }
513 };
514
516 /// Vector of call argument and its forwarding register.
518 /// Callee type ids.
520
521 /// 'call_target' metadata for the DISubprogram. It is the declaration
522 /// or definition of the target function and might be indirect.
523 MDNode *CallTarget = nullptr;
524
525 CallSiteInfo() = default;
526
527 /// Extracts the numeric type id from the CallBase's callee_type Metadata,
528 /// and sets CalleeTypeIds. This is used as type id for the indirect call in
529 /// the call graph section.
530 /// Extracts the MDNode from the CallBase's call_target Metadata to be used
531 /// during the construction of the debug info call site entries.
532 LLVM_ABI CallSiteInfo(const CallBase &CB);
533 };
534
537 unsigned TargetFlags;
538 };
539
541
542private:
543 Delegate *TheDelegate = nullptr;
544 GISelChangeObserver *Observer = nullptr;
545
546 /// Map a call instruction to call site arguments forwarding info.
547 CallSiteInfoMap CallSitesInfo;
548
549 /// A helper function that returns call site info for a give call
550 /// instruction if debug entry value support is enabled.
551 CallSiteInfoMap::iterator getCallSiteInfo(const MachineInstr *MI);
552
554 /// Mapping of call instruction to the global value and target flags that it
555 /// calls, if applicable.
556 CalledGlobalsMap CalledGlobalsInfo;
557
558 // Callbacks for insertion and removal.
559 void handleInsertion(MachineInstr &MI);
560 void handleRemoval(MachineInstr &MI);
561 friend struct ilist_traits<MachineInstr>;
562
563public:
564 // Need to be accessed from MachineInstr::setDesc.
565 void handleChangeDesc(MachineInstr &MI, const MCInstrDesc &TID);
566
569
570 /// A count of how many instructions in the function have had numbers
571 /// assigned to them. Used for debug value tracking, to determine the
572 /// next instruction number.
574
575 /// Set value of DebugInstrNumberingCount field. Avoid using this unless
576 /// you're deserializing this data.
577 void setDebugInstrNumberingCount(unsigned Num);
578
579 /// Pair of instruction number and operand number.
580 using DebugInstrOperandPair = std::pair<unsigned, unsigned>;
581
582 /// Replacement definition for a debug instruction reference. Made up of a
583 /// source instruction / operand pair, destination pair, and a qualifying
584 /// subregister indicating what bits in the operand make up the substitution.
585 // For example, a debug user
586 /// of %1:
587 /// %0:gr32 = someinst, debug-instr-number 1
588 /// %1:gr16 = %0.some_16_bit_subreg, debug-instr-number 2
589 /// Would receive the substitution {{2, 0}, {1, 0}, $subreg}, where $subreg is
590 /// the subregister number for some_16_bit_subreg.
592 public:
593 DebugInstrOperandPair Src; ///< Source instruction / operand pair.
594 DebugInstrOperandPair Dest; ///< Replacement instruction / operand pair.
595 unsigned Subreg; ///< Qualifier for which part of Dest is read.
596
600
601 /// Order only by source instruction / operand pair: there should never
602 /// be duplicate entries for the same source in any collection.
603 bool operator<(const DebugSubstitution &Other) const {
604 return Src < Other.Src;
605 }
606 };
607
608 /// Debug value substitutions: a collection of DebugSubstitution objects,
609 /// recording changes in where a value is defined. For example, when one
610 /// instruction is substituted for another. Keeping a record allows recovery
611 /// of variable locations after compilation finishes.
613
614 /// Location of a PHI instruction that is also a debug-info variable value,
615 /// for the duration of register allocation. Loaded by the PHI-elimination
616 /// pass, and emitted as DBG_PHI instructions during VirtRegRewriter, with
617 /// maintenance applied by intermediate passes that edit registers (such as
618 /// coalescing and the allocator passes).
620 public:
621 MachineBasicBlock *MBB; ///< Block where this PHI was originally located.
622 Register Reg; ///< VReg where the control-flow-merge happens.
623 unsigned SubReg; ///< Optional subreg qualifier within Reg.
626 };
627
628 /// Map of debug instruction numbers to the position of their PHI instructions
629 /// during register allocation. See DebugPHIRegallocPos.
631
632 /// Flag for whether this function contains DBG_VALUEs (false) or
633 /// DBG_INSTR_REF (true).
634 bool UseDebugInstrRef = false;
635
636 /// Create a substitution between one <instr,operand> value to a different,
637 /// new value.
639 unsigned SubReg = 0);
640
641 /// Create substitutions for any tracked values in \p Old, to point at
642 /// \p New. Needed when we re-create an instruction during optimization,
643 /// which has the same signature (i.e., def operands in the same place) but
644 /// a modified instruction type, flags, or otherwise. An example: X86 moves
645 /// are sometimes transformed into equivalent LEAs.
646 /// If the two instructions are not the same opcode, limit which operands to
647 /// examine for substitutions to the first N operands by setting
648 /// \p MaxOperand.
650 unsigned MaxOperand = UINT_MAX);
651
652 /// Find the underlying defining instruction / operand for a COPY instruction
653 /// while in SSA form. Copies do not actually define values -- they move them
654 /// between registers. Labelling a COPY-like instruction with an instruction
655 /// number is to be avoided as it makes value numbers non-unique later in
656 /// compilation. This method follows the definition chain for any sequence of
657 /// COPY-like instructions to find whatever non-COPY-like instruction defines
658 /// the copied value; or for parameters, creates a DBG_PHI on entry.
659 /// May insert instructions into the entry block!
660 /// \p MI The copy-like instruction to salvage.
661 /// \p DbgPHICache A container to cache already-solved COPYs.
662 /// \returns An instruction/operand pair identifying the defining value.
666
668
669 /// Finalise any partially emitted debug instructions. These are DBG_INSTR_REF
670 /// instructions where we only knew the vreg of the value they use, not the
671 /// instruction that defines that vreg. Once isel finishes, we should have
672 /// enough information for every DBG_INSTR_REF to point at an instruction
673 /// (or DBG_PHI).
675
676 /// Determine whether, in the current machine configuration, we should use
677 /// instruction referencing or not.
678 bool shouldUseDebugInstrRef() const;
679
680 /// Returns true if the function's variable locations are tracked with
681 /// instruction referencing.
682 bool useDebugInstrRef() const;
683
684 /// Set whether this function will use instruction referencing or not.
685 void setUseDebugInstrRef(bool UseInstrRef);
686
687 /// A reserved operand number representing the instructions memory operand,
688 /// for instructions that have a stack spill fused into them.
689 const static unsigned int DebugOperandMemNumber;
690
691 MachineFunction(Function &F, const TargetMachine &Target,
692 const TargetSubtargetInfo &STI, MCContext &Ctx,
693 unsigned FunctionNum);
697
698 /// Reset the instance as if it was just created.
699 void reset() {
700 clear();
701 init();
702 }
703
704 /// Reset the currently registered delegate - otherwise assert.
705 void resetDelegate(Delegate *delegate) {
706 assert(TheDelegate == delegate &&
707 "Only the current delegate can perform reset!");
708 TheDelegate = nullptr;
709 }
710
711 /// Set the delegate. resetDelegate must be called before attempting
712 /// to set.
713 void setDelegate(Delegate *delegate) {
714 assert(delegate && !TheDelegate &&
715 "Attempted to set delegate to null, or to change it without "
716 "first resetting it!");
717
718 TheDelegate = delegate;
719 }
720
721 void setObserver(GISelChangeObserver *O) { Observer = O; }
722
723 GISelChangeObserver *getObserver() const { return Observer; }
724
725 MCContext &getContext() const { return Ctx; }
726
727 /// Returns the Section this function belongs to.
728 MCSection *getSection() const { return Section; }
729
730 /// Indicates the Section this function belongs to.
731 void setSection(MCSection *S) { Section = S; }
732
733 PseudoSourceValueManager &getPSVManager() const { return *PSVManager; }
734
735 /// Return the DataLayout attached to the Module associated to this MF.
736 const DataLayout &getDataLayout() const;
737
738 /// Return the LLVM function that this machine code represents
739 Function &getFunction() { return F; }
740
741 /// Return the LLVM function that this machine code represents
742 const Function &getFunction() const { return F; }
743
744 /// getName - Return the name of the corresponding LLVM function.
745 StringRef getName() const;
746
747 /// getFunctionNumber - Return a unique ID for the current function.
748 unsigned getFunctionNumber() const { return FunctionNumber; }
749
750 /// Returns true if this function has basic block sections enabled.
751 bool hasBBSections() const {
752 return (BBSectionsType == BasicBlockSection::All ||
753 BBSectionsType == BasicBlockSection::List ||
754 BBSectionsType == BasicBlockSection::Preset);
755 }
756
757 void setBBSectionsType(BasicBlockSection V) { BBSectionsType = V; }
758
759 void
761 PrefetchTargets = V;
762 }
763
766 return PrefetchTargets;
767 }
768
769 /// Assign IsBeginSection IsEndSection fields for basic blocks in this
770 /// function.
771 void assignBeginEndSections();
772
773 /// getTarget - Return the target machine this machine code is compiled with
774 const TargetMachine &getTarget() const { return Target; }
775
776 /// getSubtarget - Return the subtarget for which this machine code is being
777 /// compiled.
778 const TargetSubtargetInfo &getSubtarget() const { return STI; }
779
780 /// getSubtarget - This method returns a pointer to the specified type of
781 /// TargetSubtargetInfo. In debug builds, it verifies that the object being
782 /// returned is of the correct type.
783 template<typename STC> const STC &getSubtarget() const {
784 return static_cast<const STC &>(STI);
785 }
786
787 /// getRegInfo - Return information about the registers currently in use.
788 MachineRegisterInfo &getRegInfo() { return *RegInfo; }
789 const MachineRegisterInfo &getRegInfo() const { return *RegInfo; }
790
791 /// getFrameInfo - Return the frame info object for the current function.
792 /// This object contains information about objects allocated on the stack
793 /// frame of the current function in an abstract way.
794 MachineFrameInfo &getFrameInfo() { return *FrameInfo; }
795 const MachineFrameInfo &getFrameInfo() const { return *FrameInfo; }
796
797 /// Returns true if frame pointer elimination should be disabled for this
798 /// function.
799 bool disableFramePointerElim() const;
800
801 /// Returns true if the frame pointer must always either point to a new frame
802 /// record or be un-modified in this function.
803 bool framePointerIsReserved() const;
804
805 /// getJumpTableInfo - Return the jump table info object for the current
806 /// function. This object contains information about jump tables in the
807 /// current function. If the current function has no jump tables, this will
808 /// return null.
809 const MachineJumpTableInfo *getJumpTableInfo() const { return JumpTableInfo; }
810 MachineJumpTableInfo *getJumpTableInfo() { return JumpTableInfo; }
811
812 /// getOrCreateJumpTableInfo - Get the JumpTableInfo for this function, if it
813 /// does already exist, allocate one.
814 MachineJumpTableInfo *getOrCreateJumpTableInfo(unsigned JTEntryKind);
815
816 /// getConstantPool - Return the constant pool object for the current
817 /// function.
818 MachineConstantPool *getConstantPool() { return ConstantPool; }
819 const MachineConstantPool *getConstantPool() const { return ConstantPool; }
820
821 /// getWinEHFuncInfo - Return information about how the current function uses
822 /// Windows exception handling. Returns null for functions that don't use
823 /// funclets for exception handling.
824 const WinEHFuncInfo *getWinEHFuncInfo() const { return WinEHInfo; }
825 WinEHFuncInfo *getWinEHFuncInfo() { return WinEHInfo; }
826
827 /// getAlignment - Return the alignment of the function.
828 Align getAlignment() const { return Alignment; }
829
830 /// setAlignment - Set the alignment of the function.
831 void setAlignment(Align A) { Alignment = A; }
832
833 /// ensureAlignment - Make sure the function is at least A bytes aligned.
835 if (Alignment < A)
836 Alignment = A;
837 }
838
839 /// Returns the preferred alignment which comes from the function attributes
840 /// (optsize, minsize, prefalign) and TargetLowering.
841 Align getPreferredAlignment() const;
842
843 /// exposesReturnsTwice - Returns true if the function calls setjmp or
844 /// any other similar functions with attribute "returns twice" without
845 /// having the attribute itself.
846 bool exposesReturnsTwice() const {
847 return ExposesReturnsTwice;
848 }
849
850 /// setCallsSetJmp - Set a flag that indicates if there's a call to
851 /// a "returns twice" function.
853 ExposesReturnsTwice = B;
854 }
855
856 /// Returns true if the function contains any inline assembly.
857 bool hasInlineAsm() const {
858 return HasInlineAsm;
859 }
860
861 /// Set a flag that indicates that the function contains inline assembly.
862 void setHasInlineAsm(bool B) {
863 HasInlineAsm = B;
864 }
865
866 bool hasWinCFI() const {
867 return HasWinCFI;
868 }
869 void setHasWinCFI(bool v) { HasWinCFI = v; }
870
871 /// True if this function needs frame moves for debug or exceptions.
872 bool needsFrameMoves() const;
873
874 /// Get the function properties
875 const MachineFunctionProperties &getProperties() const { return Properties; }
876 MachineFunctionProperties &getProperties() { return Properties; }
877
878 /// getInfo - Keep track of various per-function pieces of information for
879 /// backends that would like to do so.
880 ///
881 template<typename Ty>
882 Ty *getInfo() {
883 return static_cast<Ty*>(MFInfo);
884 }
885
886 template<typename Ty>
887 const Ty *getInfo() const {
888 return static_cast<const Ty *>(MFInfo);
889 }
890
891 template <typename Ty> Ty *cloneInfo(const Ty &Old) {
892 assert(!MFInfo);
893 MFInfo = Ty::template create<Ty>(Allocator, Old);
894 return static_cast<Ty *>(MFInfo);
895 }
896
897 /// Initialize the target specific MachineFunctionInfo
898 void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI);
899
900 MachineFunctionInfo *cloneInfoFrom(
901 const MachineFunction &OrigMF,
903
904 /// Returns the denormal handling type for the default rounding mode of the
905 /// function.
906 DenormalMode getDenormalMode(const fltSemantics &FPType) const;
907
908 /// getBlockNumbered - MachineBasicBlocks are automatically numbered when they
909 /// are inserted into the machine function. The block number for a machine
910 /// basic block can be found by using the MBB::getNumber method, this method
911 /// provides the inverse mapping.
913 assert(N < MBBNumbering.size() && "Illegal block number");
914 assert(MBBNumbering[N] && "Block was removed from the machine function!");
915 return MBBNumbering[N];
916 }
917
918 /// Should we be emitting segmented stack stuff for the function
919 bool shouldSplitStack() const;
920
921 /// getNumBlockIDs - Return the number of MBB ID's allocated.
922 unsigned getNumBlockIDs() const { return (unsigned)MBBNumbering.size(); }
923
924 /// Return the numbering "epoch" of analysis block numbers.
926 return AnalysisNumberingEpoch;
927 }
928
929 unsigned assignAnalysisNumber() { return NextAnalysisNumber++; }
930
931 unsigned getMaxAnalysisBlockNumber() const { return NextAnalysisNumber; }
932
933 /// RenumberBlocks - This discards all of the MachineBasicBlock numbers and
934 /// recomputes them. This guarantees that the MBB numbers are sequential,
935 /// dense, and match the ordering of the blocks within the function. If a
936 /// specific MachineBasicBlock is specified, only that block and those after
937 /// it are renumbered.
938 void RenumberBlocks(MachineBasicBlock *MBBFrom = nullptr);
939
940 /// Return an estimate of the function's code size,
941 /// taking into account block and function alignment
943
944 /// print - Print out the MachineFunction in a format suitable for debugging
945 /// to the specified stream.
946 void print(raw_ostream &OS, const SlotIndexes* = nullptr) const;
947
948 /// viewCFG - This function is meant for use from the debugger. You can just
949 /// say 'call F->viewCFG()' and a ghostview window should pop up from the
950 /// program, displaying the CFG of the current function with the code for each
951 /// basic block inside. This depends on there being a 'dot' and 'gv' program
952 /// in your path.
953 void viewCFG() const;
954
955 /// viewCFGOnly - This function is meant for use from the debugger. It works
956 /// just like viewCFG, but it does not include the contents of basic blocks
957 /// into the nodes, just the label. If you are only interested in the CFG
958 /// this can make the graph smaller.
959 ///
960 void viewCFGOnly() const;
961
962 /// dump - Print the current MachineFunction to cerr, useful for debugger use.
963 void dump() const;
964
965 /// Run the current MachineFunction through the machine code verifier, useful
966 /// for debugger use.
967 /// \returns true if no problems were found.
968 bool verify(Pass *p = nullptr, const char *Banner = nullptr,
969 raw_ostream *OS = nullptr, bool AbortOnError = true) const;
970
971 /// For New Pass Manager: Run the current MachineFunction through the machine
972 /// code verifier, useful for debugger use.
973 /// \returns true if no problems were found.
975 const char *Banner = nullptr, raw_ostream *OS = nullptr,
976 bool AbortOnError = true) const;
977
978 /// Run the current MachineFunction through the machine code verifier, useful
979 /// for debugger use.
980 /// TODO: Add the param for LiveStacks analysis.
981 /// \returns true if no problems were found.
982 bool verify(LiveIntervals *LiveInts, SlotIndexes *Indexes,
983 const char *Banner = nullptr, raw_ostream *OS = nullptr,
984 bool AbortOnError = true) const;
985
986 // Provide accessors for the MachineBasicBlock list...
991
992 /// Support for MachineBasicBlock::getNextNode().
993 static BasicBlockListType MachineFunction::*
995 return &MachineFunction::BasicBlocks;
996 }
997
998 /// addLiveIn - Add the specified physical register as a live-in value and
999 /// create a corresponding virtual register for it.
1001
1002 //===--------------------------------------------------------------------===//
1003 // BasicBlock accessor functions.
1004 //
1005 iterator begin() { return BasicBlocks.begin(); }
1006 const_iterator begin() const { return BasicBlocks.begin(); }
1007 iterator end () { return BasicBlocks.end(); }
1008 const_iterator end () const { return BasicBlocks.end(); }
1009
1010 reverse_iterator rbegin() { return BasicBlocks.rbegin(); }
1011 const_reverse_iterator rbegin() const { return BasicBlocks.rbegin(); }
1012 reverse_iterator rend () { return BasicBlocks.rend(); }
1013 const_reverse_iterator rend () const { return BasicBlocks.rend(); }
1014
1015 unsigned size() const { return (unsigned)BasicBlocks.size();}
1016 bool empty() const { return BasicBlocks.empty(); }
1017 const MachineBasicBlock &front() const { return BasicBlocks.front(); }
1018 MachineBasicBlock &front() { return BasicBlocks.front(); }
1019 const MachineBasicBlock & back() const { return BasicBlocks.back(); }
1020 MachineBasicBlock & back() { return BasicBlocks.back(); }
1021
1022 void push_back (MachineBasicBlock *MBB) { BasicBlocks.push_back (MBB); }
1023 void push_front(MachineBasicBlock *MBB) { BasicBlocks.push_front(MBB); }
1025 BasicBlocks.insert(MBBI, MBB);
1026 }
1027 void splice(iterator InsertPt, iterator MBBI) {
1028 BasicBlocks.splice(InsertPt, BasicBlocks, MBBI);
1029 }
1031 BasicBlocks.splice(InsertPt, BasicBlocks, MBB);
1032 }
1033 void splice(iterator InsertPt, iterator MBBI, iterator MBBE) {
1034 BasicBlocks.splice(InsertPt, BasicBlocks, MBBI, MBBE);
1035 }
1036
1037 void remove(iterator MBBI) { BasicBlocks.remove(MBBI); }
1038 void remove(MachineBasicBlock *MBBI) { BasicBlocks.remove(MBBI); }
1039 void erase(iterator MBBI) { BasicBlocks.erase(MBBI); }
1040 void erase(MachineBasicBlock *MBBI) { BasicBlocks.erase(MBBI); }
1041
1042 template <typename Comp>
1043 void sort(Comp comp) {
1044 BasicBlocks.sort(comp);
1045 }
1046
1047 /// Return the number of \p MachineInstrs in this \p MachineFunction.
1048 unsigned getInstructionCount() const {
1049 unsigned InstrCount = 0;
1050 for (const MachineBasicBlock &MBB : BasicBlocks)
1051 InstrCount += MBB.size();
1052 return InstrCount;
1053 }
1054
1055 //===--------------------------------------------------------------------===//
1056 // Internal functions used to automatically number MachineBasicBlocks
1057
1058 /// Adds the MBB to the internal numbering. Returns the unique number
1059 /// assigned to the MBB.
1061 MBBNumbering.push_back(MBB);
1062 return (unsigned)MBBNumbering.size()-1;
1063 }
1064
1065 /// removeFromMBBNumbering - Remove the specific machine basic block from our
1066 /// tracker, this is only really to be used by the MachineBasicBlock
1067 /// implementation.
1068 void removeFromMBBNumbering(unsigned N) {
1069 assert(N < MBBNumbering.size() && "Illegal basic block #");
1070 MBBNumbering[N] = nullptr;
1071 }
1072
1073 /// CreateMachineInstr - Allocate a new MachineInstr. Use this instead
1074 /// of `new MachineInstr'.
1075 MachineInstr *CreateMachineInstr(const MCInstrDesc &MCID, DebugLoc DL,
1076 bool NoImplicit = false);
1077
1078 /// Create a new MachineInstr which is a copy of \p Orig, identical in all
1079 /// ways except the instruction has no parent, prev, or next. Bundling flags
1080 /// are reset.
1081 ///
1082 /// Note: Clones a single instruction, not whole instruction bundles.
1083 /// Does not perform target specific adjustments; consider using
1084 /// TargetInstrInfo::duplicate() instead.
1085 MachineInstr *CloneMachineInstr(const MachineInstr *Orig);
1086
1087 /// Clones instruction or the whole instruction bundle \p Orig and insert
1088 /// into \p MBB before \p InsertBefore.
1089 ///
1090 /// Note: Does not perform target specific adjustments; consider using
1091 /// TargetInstrInfo::duplicate() instead.
1092 MachineInstr &
1093 cloneMachineInstrBundle(MachineBasicBlock &MBB,
1094 MachineBasicBlock::iterator InsertBefore,
1095 const MachineInstr &Orig);
1096
1097 /// DeleteMachineInstr - Delete the given MachineInstr.
1098 void deleteMachineInstr(MachineInstr *MI);
1099
1100 /// CreateMachineBasicBlock - Allocate a new MachineBasicBlock. Use this
1101 /// instead of `new MachineBasicBlock'. Sets `MachineBasicBlock::BBID` if
1102 /// basic-block-sections is enabled for the function.
1104 CreateMachineBasicBlock(const BasicBlock *BB = nullptr,
1105 std::optional<UniqueBBID> BBID = std::nullopt);
1106
1107 /// DeleteMachineBasicBlock - Delete the given MachineBasicBlock.
1108 void deleteMachineBasicBlock(MachineBasicBlock *MBB);
1109
1110 /// getMachineMemOperand - Allocate a new MachineMemOperand.
1111 /// MachineMemOperands are owned by the MachineFunction and need not be
1112 /// explicitly deallocated.
1115 Align BaseAlignment, const MMOMetadata &Metadata = MMOMetadata(),
1118 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
1121 Align BaseAlignment, const MMOMetadata &Metadata = MMOMetadata(),
1124 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic);
1127 Align BaseAlignment, const MMOMetadata &Metadata = MMOMetadata(),
1130 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic) {
1132 BaseAlignment, Metadata, SSID, Ordering,
1133 FailureOrdering);
1134 }
1137 Align BaseAlignment, const MMOMetadata &Metadata = MMOMetadata(),
1140 AtomicOrdering FailureOrdering = AtomicOrdering::NotAtomic) {
1142 BaseAlignment, Metadata, SSID, Ordering,
1143 FailureOrdering);
1144 }
1145
1146 /// getMachineMemOperand - Allocate a new MachineMemOperand by copying
1147 /// an existing one, adjusting by an offset and using the given size.
1148 /// MachineMemOperands are owned by the MachineFunction and need not be
1149 /// explicitly deallocated.
1151 int64_t Offset, LLT Ty);
1153 int64_t Offset, LocationSize Size) {
1154 return getMachineMemOperand(
1155 MMO, Offset,
1156 !Size.isPrecise() ? LLT()
1157 : Size.isScalable()
1158 ? LLT::scalable_vector(1, 8 * Size.getValue().getKnownMinValue())
1159 : LLT::scalar(8 * Size.getValue().getKnownMinValue()));
1160 }
1169
1170 /// getMachineMemOperand - Allocate a new MachineMemOperand by copying
1171 /// an existing one, replacing only the MachinePointerInfo and size.
1172 /// MachineMemOperands are owned by the MachineFunction and need not be
1173 /// explicitly deallocated.
1175 const MachinePointerInfo &PtrInfo,
1178 const MachinePointerInfo &PtrInfo,
1179 LLT Ty);
1190
1191 /// Allocate a new MachineMemOperand by copying an existing one,
1192 /// replacing only AliasAnalysis information. MachineMemOperands are owned
1193 /// by the MachineFunction and need not be explicitly deallocated.
1195 const AAMDNodes &AAInfo);
1196
1197 /// Allocate a new MachineMemOperand by copying an existing one,
1198 /// replacing the flags. MachineMemOperands are owned
1199 /// by the MachineFunction and need not be explicitly deallocated.
1202
1204
1205 /// Allocate an array of MachineOperands. This is only intended for use by
1206 /// internal MachineInstr functions.
1208 return OperandRecycler.allocate(Cap, Allocator);
1209 }
1210
1211 /// Dellocate an array of MachineOperands and recycle the memory. This is
1212 /// only intended for use by internal MachineInstr functions.
1213 /// Cap must be the same capacity that was used to allocate the array.
1215 OperandRecycler.deallocate(Cap, Array);
1216 }
1217
1218 /// Allocate and initialize a register mask with @p NumRegister bits.
1219 uint32_t *allocateRegMask();
1220
1221 ArrayRef<int> allocateShuffleMask(ArrayRef<int> Mask);
1222
1223 /// Allocate and construct an extra info structure for a `MachineInstr`.
1224 ///
1225 /// This is allocated on the function's allocator and so lives the life of
1226 /// the function.
1227 MachineInstr::ExtraInfo *createMIExtraInfo(
1228 ArrayRef<MachineMemOperand *> MMOs, MCSymbol *PreInstrSymbol = nullptr,
1229 MCSymbol *PostInstrSymbol = nullptr, MDNode *HeapAllocMarker = nullptr,
1230 MDNode *PCSections = nullptr, uint32_t CFIType = 0,
1231 MDNode *MMRAs = nullptr, Value *DS = nullptr);
1232
1233 /// Allocate a string and populate it with the given external symbol name.
1234 const char *createExternalSymbolName(StringRef Name);
1235
1236 //===--------------------------------------------------------------------===//
1237 // Label Manipulation.
1238
1239 /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table.
1240 /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a
1241 /// normal 'L' label is returned.
1242 MCSymbol *getJTISymbol(unsigned JTI, MCContext &Ctx,
1243 bool isLinkerPrivate = false) const;
1244
1245 /// getPICBaseSymbol - Return a function-local symbol to represent the PIC
1246 /// base.
1247 MCSymbol *getPICBaseSymbol() const;
1248
1249 /// Returns a reference to a list of cfi instructions in the function's
1250 /// prologue. Used to construct frame maps for debug and exception handling
1251 /// comsumers.
1252 const std::vector<MCCFIInstruction> &getFrameInstructions() const {
1253 return FrameInstructions;
1254 }
1255
1256 [[nodiscard]] unsigned addFrameInst(const MCCFIInstruction &Inst);
1257
1258 /// Replace all references to register \param From with register \param To in
1259 /// frame instructions. Note that .cfi_escape instructions will be left as-is.
1260 void replaceFrameInstRegister(MCRegister From, MCRegister To);
1261
1262 /// Returns a reference to a list of symbols immediately following calls to
1263 /// _setjmp in the function. Used to construct the longjmp target table used
1264 /// by Windows Control Flow Guard.
1265 const std::vector<MCSymbol *> &getLongjmpTargets() const {
1266 return LongjmpTargets;
1267 }
1268
1269 /// Add the specified symbol to the list of valid longjmp targets for Windows
1270 /// Control Flow Guard.
1271 void addLongjmpTarget(MCSymbol *Target) { LongjmpTargets.push_back(Target); }
1272
1273 /// Returns a reference to a list of symbols that are targets for Windows
1274 /// EH Continuation Guard.
1275 const std::vector<MCSymbol *> &getEHContTargets() const {
1276 return EHContTargets;
1277 }
1278
1279 /// Add the specified symbol to the list of targets for Windows EH
1280 /// Continuation Guard.
1281 void addEHContTarget(MCSymbol *Target) { EHContTargets.push_back(Target); }
1282
1283 /// Tries to get the global and target flags for a call site, if the
1284 /// instruction is a call to a global.
1286 return CalledGlobalsInfo.lookup(MI);
1287 }
1288
1289 /// Notes the global and target flags for a call site.
1291 assert(MI && "MI must not be null");
1292 assert(MI->isCandidateForAdditionalCallInfo() &&
1293 "Cannot store called global info for this instruction");
1294 assert(Details.Callee && "Global must not be null");
1295 CalledGlobalsInfo.insert({MI, Details});
1296 }
1297
1298 /// Iterates over the full set of call sites and their associated globals.
1299 auto getCalledGlobals() const {
1300 return llvm::make_range(CalledGlobalsInfo.begin(), CalledGlobalsInfo.end());
1301 }
1302
1303 /// \name Exception Handling
1304 /// \{
1305
1306 bool callsEHReturn() const { return CallsEHReturn; }
1307 void setCallsEHReturn(bool b) { CallsEHReturn = b; }
1308
1309 bool callsUnwindInit() const { return CallsUnwindInit; }
1310 void setCallsUnwindInit(bool b) { CallsUnwindInit = b; }
1311
1312 bool hasEHContTarget() const { return HasEHContTarget; }
1313 void setHasEHContTarget(bool V) { HasEHContTarget = V; }
1314
1315 bool hasEHScopes() const { return HasEHScopes; }
1316 void setHasEHScopes(bool V) { HasEHScopes = V; }
1317
1318 bool hasEHFunclets() const { return HasEHFunclets; }
1319 void setHasEHFunclets(bool V) { HasEHFunclets = V; }
1320
1321 bool hasFakeUses() const { return HasFakeUses; }
1322 void setHasFakeUses(bool V) { HasFakeUses = V; }
1323
1324 bool isOutlined() const { return IsOutlined; }
1325 void setIsOutlined(bool V) { IsOutlined = V; }
1326
1327 /// Find or create an LandingPadInfo for the specified MachineBasicBlock.
1328 LandingPadInfo &getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad);
1329
1330 /// Return a reference to the landing pad info for the current function.
1331 const std::vector<LandingPadInfo> &getLandingPads() const {
1332 return LandingPads;
1333 }
1334
1335 /// Provide the begin and end labels of an invoke style call and associate it
1336 /// with a try landing pad block.
1337 void addInvoke(MachineBasicBlock *LandingPad,
1338 MCSymbol *BeginLabel, MCSymbol *EndLabel);
1339
1340 /// Add a new panding pad, and extract the exception handling information from
1341 /// the landingpad instruction. Returns the label ID for the landing pad
1342 /// entry.
1343 MCSymbol *addLandingPad(MachineBasicBlock *LandingPad);
1344
1345 /// Return the type id for the specified typeinfo. This is function wide.
1346 unsigned getTypeIDFor(const GlobalValue *TI);
1347
1348 /// Return the id of the filter encoded by TyIds. This is function wide.
1349 int getFilterIDFor(ArrayRef<unsigned> TyIds);
1350
1351 /// Map the landing pad's EH symbol to the call site indexes.
1352 void setCallSiteLandingPad(MCSymbol *Sym, ArrayRef<unsigned> Sites);
1353
1354 /// Return if there is any wasm exception handling.
1356 return !WasmLPadToIndexMap.empty();
1357 }
1358
1359 /// Map the landing pad to its index. Used for Wasm exception handling.
1360 void setWasmLandingPadIndex(const MachineBasicBlock *LPad, unsigned Index) {
1361 WasmLPadToIndexMap[LPad] = Index;
1362 }
1363
1364 /// Returns true if the landing pad has an associate index in wasm EH.
1366 return WasmLPadToIndexMap.count(LPad);
1367 }
1368
1369 /// Get the index in wasm EH for a given landing pad.
1370 unsigned getWasmLandingPadIndex(const MachineBasicBlock *LPad) const {
1372 return WasmLPadToIndexMap.lookup(LPad);
1373 }
1374
1376 return !LPadToCallSiteMap.empty();
1377 }
1378
1379 /// Get the call site indexes for a landing pad EH symbol.
1382 "missing call site number for landing pad!");
1383 return LPadToCallSiteMap[Sym];
1384 }
1385
1386 /// Return true if the landing pad Eh symbol has an associated call site.
1388 return !LPadToCallSiteMap[Sym].empty();
1389 }
1390
1391 bool hasAnyCallSiteLabel() const {
1392 return !CallSiteMap.empty();
1393 }
1394
1395 /// Map the begin label for a call site.
1396 void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site) {
1397 CallSiteMap[BeginLabel] = Site;
1398 }
1399
1400 /// Get the call site number for a begin label.
1401 unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) const {
1402 assert(hasCallSiteBeginLabel(BeginLabel) &&
1403 "Missing call site number for EH_LABEL!");
1404 return CallSiteMap.lookup(BeginLabel);
1405 }
1406
1407 /// Return true if the begin label has a call site number associated with it.
1408 bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) const {
1409 return CallSiteMap.count(BeginLabel);
1410 }
1411
1412 /// Record annotations associated with a particular label.
1414 CodeViewAnnotations.push_back({Label, MD});
1415 }
1416
1418 return CodeViewAnnotations;
1419 }
1420
1421 /// Return a reference to the C++ typeinfo for the current function.
1422 const std::vector<const GlobalValue *> &getTypeInfos() const {
1423 return TypeInfos;
1424 }
1425
1426 /// Return a reference to the typeids encoding filters used in the current
1427 /// function.
1428 const std::vector<unsigned> &getFilterIds() const {
1429 return FilterIds;
1430 }
1431
1432 /// \}
1433
1434 /// Collect information used to emit debugging information of a variable in a
1435 /// stack slot.
1437 int Slot, const DILocation *Loc) {
1438 VariableDbgInfos.emplace_back(Var, Expr, Slot, Loc);
1439 }
1440
1441 /// Collect information used to emit debugging information of a variable in
1442 /// the entry value of a register.
1444 MCRegister Reg, const DILocation *Loc) {
1445 VariableDbgInfos.emplace_back(Var, Expr, Reg, Loc);
1446 }
1447
1450 return VariableDbgInfos;
1451 }
1452
1453 /// Returns the collection of variables for which we have debug info and that
1454 /// have been assigned a stack slot.
1456 return make_filter_range(getVariableDbgInfo(), [](auto &VarInfo) {
1457 return VarInfo.inStackSlot();
1458 });
1459 }
1460
1461 /// Returns the collection of variables for which we have debug info and that
1462 /// have been assigned a stack slot.
1464 return make_filter_range(getVariableDbgInfo(), [](const auto &VarInfo) {
1465 return VarInfo.inStackSlot();
1466 });
1467 }
1468
1469 /// Returns the collection of variables for which we have debug info and that
1470 /// have been assigned an entry value register.
1472 return make_filter_range(getVariableDbgInfo(), [](const auto &VarInfo) {
1473 return VarInfo.inEntryValueRegister();
1474 });
1475 }
1476
1477 /// Start tracking the arguments passed to the call \p CallI.
1480 bool Inserted =
1481 CallSitesInfo.try_emplace(CallI, std::move(CallInfo)).second;
1482 (void)Inserted;
1483 assert(Inserted && "Call site info not unique");
1484 }
1485
1487 return CallSitesInfo;
1488 }
1489
1490 /// Following functions update call site info. They should be called before
1491 /// removing, replacing or copying call instruction.
1492
1493 /// Erase the call site info for \p MI. It is used to remove a call
1494 /// instruction from the instruction stream.
1495 void eraseAdditionalCallInfo(const MachineInstr *MI);
1496 /// Copy the call site info from \p Old to \ New. Its usage is when we are
1497 /// making a copy of the instruction that will be inserted at different point
1498 /// of the instruction stream.
1499 void copyAdditionalCallInfo(const MachineInstr *Old, const MachineInstr *New);
1500
1501 /// Move the call site info from \p Old to \New call site info. This function
1502 /// is used when we are replacing one call instruction with another one to
1503 /// the same callee.
1504 void moveAdditionalCallInfo(const MachineInstr *Old, const MachineInstr *New);
1505
1507 return ++DebugInstrNumberingCount;
1508 }
1509};
1510
1511//===--------------------------------------------------------------------===//
1512// GraphTraits specializations for function basic block graphs (CFGs)
1513//===--------------------------------------------------------------------===//
1514
1515// Provide specializations of GraphTraits to be able to treat a
1516// machine function as a graph of machine basic blocks... these are
1517// the same as the machine basic block iterators, except that the root
1518// node is implicitly the first node of the function.
1519//
1520template <> struct GraphTraits<MachineFunction*> :
1522 static NodeRef getEntryNode(MachineFunction *F) { return &F->front(); }
1523
1524 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
1526
1528 return nodes_iterator(F->begin());
1529 }
1530
1532 return nodes_iterator(F->end());
1533 }
1534
1535 static unsigned size (MachineFunction *F) { return F->size(); }
1536
1537 static unsigned getMaxNumber(MachineFunction *F) {
1538 return F->getMaxAnalysisBlockNumber();
1539 }
1541 return F->getAnalysisBlockNumberEpoch();
1542 }
1543};
1544template <> struct GraphTraits<const MachineFunction*> :
1546 static NodeRef getEntryNode(const MachineFunction *F) { return &F->front(); }
1547
1548 // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
1550
1552 return nodes_iterator(F->begin());
1553 }
1554
1556 return nodes_iterator(F->end());
1557 }
1558
1559 static unsigned size (const MachineFunction *F) {
1560 return F->size();
1561 }
1562
1563 static unsigned getMaxNumber(const MachineFunction *F) {
1564 return F->getMaxAnalysisBlockNumber();
1565 }
1566 static unsigned getNumberEpoch(const MachineFunction *F) {
1567 return F->getAnalysisBlockNumberEpoch();
1568 }
1569};
1570
1571// Provide specializations of GraphTraits to be able to treat a function as a
1572// graph of basic blocks... and to walk it in inverse order. Inverse order for
1573// a function is considered to be when traversing the predecessor edges of a BB
1574// instead of the successor edges.
1575//
1576template <> struct GraphTraits<Inverse<MachineFunction*>> :
1579 return &G.Graph->front();
1580 }
1581
1582 static unsigned getMaxNumber(MachineFunction *F) {
1583 return F->getMaxAnalysisBlockNumber();
1584 }
1586 return F->getAnalysisBlockNumberEpoch();
1587 }
1588};
1592 return &G.Graph->front();
1593 }
1594
1595 static unsigned getMaxNumber(const MachineFunction *F) {
1596 return F->getMaxAnalysisBlockNumber();
1597 }
1598 static unsigned getNumberEpoch(const MachineFunction *F) {
1599 return F->getAnalysisBlockNumberEpoch();
1600 }
1601};
1602
1603LLVM_ABI void verifyMachineFunction(const std::string &Banner,
1604 const MachineFunction &MF);
1605
1606} // end namespace llvm
1607
1608#endif // LLVM_CODEGEN_MACHINEFUNCTION_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
aarch64 promote const
unsigned uint64_t
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:215
static unsigned InstrCount
@ CallSiteInfo
This file defines the DenseMap class.
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.
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:1088
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:126
DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator
Definition DenseMap.h:168
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.
MCRegisterClass - Base class of TargetRegisterClass.
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:580
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:1081
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,...
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, uint64_t Size, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
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.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, TypeSize Size, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
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()
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
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)
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
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
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,...
Root of the metadata hierarchy.
Definition Metadata.h:64
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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.
@ System
Synchronized with respect to all concurrently executing threads.
Definition LLVMContext.h:58
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
@ Offset
Definition DWP.cpp:577
@ Unknown
Not known to have no common set bits.
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:390
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:774
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
LandingPadInfo(MachineBasicBlock *MBB)
MachineBasicBlock * LandingPadBlock
SmallVector< MCSymbol *, 1 > BeginLabels
std::vector< int > TypeIds
LLVM IR metadata carried by a MachineMemOperand.
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,...
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