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