36 const unsigned *Indices,
37 const unsigned *IndicesEnd,
40 if (Indices && Indices == IndicesEnd)
47 if (Indices && *Indices ==
I.index())
51 assert(!Indices &&
"Unexpected out of bound");
56 Type *EltTy = ATy->getElementType();
57 unsigned NumElts = ATy->getNumElements();
61 assert(*Indices < NumElts &&
"Unexpected out of bound");
64 CurIndex += EltLinearOffset* *Indices;
67 CurIndex += EltLinearOffset*NumElts;
79 StartingOffset.
isZero()) &&
80 "Offset/TypeSize mismatch!");
86 const StructLayout *SL = Offsets ?
DL.getStructLayout(STy) :
nullptr;
88 EE = STy->element_end();
99 Type *EltTy = ATy->getElementType();
100 TypeSize EltSize =
DL.getTypeAllocSize(EltTy);
101 for (
unsigned i = 0, e = ATy->getNumElements(); i != e; ++i)
103 StartingOffset + i * EltSize);
111 Offsets->push_back(StartingOffset);
128 ValueVTs.
reserve(Types.size());
131 for (
Type *Ty : Types) {
142 uint64_t StartingOffset) {
147 FixedOffsets->
reserve(Offsets.size());
162 for (
Type *ValTy : ValTys)
169 uint64_t FixedStartingOffset) {
174 FixedOffsets->
reserve(Offsets.size());
188 if (Var && Var->
getName() ==
"llvm.eh.catch.all.value") {
190 "The EH catch-all value must have an initializer");
197 "TypeInfo must be a global variable or NULL");
203 if (!STy || STy->getNumElements() != 2)
205 Type *ExnTy = STy->getElementType(0);
294 return T1 == T2 || (
T1->isPointerTy() && T2->isPointerTy()) ||
319 if (!
I ||
I->getNumOperands() == 0)
return V;
320 const Value *NoopInput =
nullptr;
336 DL.getPointerSizeInBits() ==
344 DL.getPointerSizeInBits() ==
351 I->getType()->getPrimitiveSizeInBits().getFixedValue());
354 const Value *ReturnedOp = CB->getReturnedArgOperand();
356 NoopInput = ReturnedOp;
360 if (ValLoc.
size() >= InsertLoc.
size() &&
361 std::equal(InsertLoc.
begin(), InsertLoc.
end(), ValLoc.
rbegin())) {
366 NoopInput = IVI->getInsertedValueOperand();
395 bool AllowDifferingSizes,
403 unsigned BitsRequired = UINT_MAX;
415 unsigned BitsProvided = UINT_MAX;
416 CallVal =
getNoopInput(CallVal, CallIndices, BitsProvided, TLI,
DL);
420 if (CallVal != RetVal || CallIndices != RetIndices)
427 if (BitsProvided < BitsRequired ||
428 (!AllowDifferingSizes && BitsProvided != BitsRequired))
438 return Idx < AT->getNumElements();
440 return Idx < cast<StructType>(
T)->getNumElements();
520 ->isAggregateType()) {
536 assert(!Path.empty() &&
"found a leaf but didn't set the path?");
538 ->isAggregateType());
583 if (GVar->hasGlobalUnnamedAddr() && GVar->isConstant() &&
584 GVar->hasInitializer() && GVar->isDiscardableIfUnused() &&
590 if (M.getCodeViewFlag())
626 if (!
C->getType()->isPointerTy())
657 bool ReturnsFirstArg) {
684 if (BBI->isDebugOrPseudoInst())
689 if (
II->getIntrinsicID() == Intrinsic::lifetime_end ||
690 II->getIntrinsicID() == Intrinsic::assume ||
691 II->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl ||
692 II->getIntrinsicID() == Intrinsic::fake_use)
694 if (BBI->mayHaveSideEffects() || BBI->mayReadFromMemory() ||
708 bool *AllowDifferingSizes) {
711 bool &ADS = AllowDifferingSizes ? *AllowDifferingSizes : DummyADS;
714 AttrBuilder CallerAttrs(
F->getContext(),
F->getAttributes().getRetAttrs());
715 AttrBuilder CalleeAttrs(
F->getContext(),
720 for (
const auto &Attr : {Attribute::Alignment, Attribute::Dereferenceable,
721 Attribute::DereferenceableOrNull, Attribute::NoAlias,
722 Attribute::NonNull, Attribute::NoUndef,
723 Attribute::Range, Attribute::NoFPClass}) {
724 CallerAttrs.removeAttribute(Attr);
725 CalleeAttrs.removeAttribute(Attr);
728 if (CallerAttrs.contains(Attribute::ZExt)) {
729 if (!CalleeAttrs.contains(Attribute::ZExt))
733 CallerAttrs.removeAttribute(Attribute::ZExt);
734 CalleeAttrs.removeAttribute(Attribute::ZExt);
735 }
else if (CallerAttrs.contains(Attribute::SExt)) {
736 if (!CalleeAttrs.contains(Attribute::SExt))
740 CallerAttrs.removeAttribute(Attribute::SExt);
741 CalleeAttrs.removeAttribute(Attribute::SExt);
754 if (
I->use_empty()) {
755 CalleeAttrs.removeAttribute(Attribute::SExt);
756 CalleeAttrs.removeAttribute(Attribute::ZExt);
762 return CallerAttrs == CalleeAttrs;
769 bool ReturnsFirstArg) {
779 bool AllowDifferingSizes;
792 bool CallEmpty = !
firstRealType(CallVal->getType(), CallSubTypes, CallPath);
826 AllowDifferingSizes, TLI,
839 bool ReturnsFirstArg =
false;
841 ReturnsFirstArg =
true;
842 return ReturnsFirstArg;
849 while (!Worklist.
empty()) {
856 auto P = EHScopeMembership.
insert(std::make_pair(Visiting, EHScope));
860 assert(
P.first->second == EHScope &&
"MBB is part of two scopes!");
879 return EHScopeMembership;
891 if (
MBB.isEHScopeEntry()) {
893 }
else if (IsSEH &&
MBB.isEHPad()) {
895 }
else if (
MBB.pred_empty()) {
903 if (
MBBI ==
MBB.end() ||
MBBI->getOpcode() !=
TII->getCatchReturnOpcode())
915 if (EHScopeBlocks.
empty())
916 return EHScopeMembership;
930 for (std::pair<const MachineBasicBlock *, int> CatchRetPair :
942 return EHScopeMembership;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static bool isNoopBitcast(Type *T1, Type *T2, const TargetLoweringBase &TLI)
static bool firstRealType(Type *Next, SmallVectorImpl< Type * > &SubTypes, SmallVectorImpl< unsigned > &Path)
Find the first non-empty, scalar-like type in Next and setup the iterator components.
static bool slotOnlyDiscardsData(const Value *RetVal, const Value *CallVal, SmallVectorImpl< unsigned > &RetIndices, SmallVectorImpl< unsigned > &CallIndices, bool AllowDifferingSizes, const TargetLoweringBase &TLI, const DataLayout &DL)
Return true if this scalar return value only has bits discarded on its path from the "tail call" to t...
static void collectEHScopeMembers(DenseMap< const MachineBasicBlock *, int > &EHScopeMembership, int EHScope, const MachineBasicBlock *MBB)
static bool indexReallyValid(Type *T, unsigned Idx)
For an aggregate type, determine whether a given index is within bounds or not.
static bool nextRealType(SmallVectorImpl< Type * > &SubTypes, SmallVectorImpl< unsigned > &Path)
Set the iterator data-structures to the next non-empty, non-aggregate subtype.
static unsigned getDwarfVersion(const MachineFunction &MF)
Resolve the DWARF version the way DwarfDebug does.
static bool advanceToNextLeafType(SmallVectorImpl< Type * > &SubTypes, SmallVectorImpl< unsigned > &Path)
Move the given iterators to the next leaf type in depth first traversal.
static const Value * getNoopInput(const Value *V, SmallVectorImpl< unsigned > &ValLoc, unsigned &DataBits, const TargetLoweringBase &TLI, const DataLayout &DL)
Look through operations that will be free to find the earliest source of this value.
This file contains constants used for implementing Dwarf debug support.
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
uint64_t IntrinsicInst * II
This file describes how to lower LLVM code to machine code.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
reverse_iterator rend() const
size_t size() const
Get the array size.
reverse_iterator rbegin() const
Class to represent array types.
LLVM Basic Block Representation.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::const_iterator const_iterator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Value * getArgOperand(unsigned i) const
This class represents a function call, abstracting a target machine's calling convention.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ FCMP_TRUE
1 1 1 1 Always true (always folded)
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ FCMP_ORD
0 1 1 1 True if ordered (no nans)
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
@ FCMP_FALSE
0 0 0 0 Always false (always folded)
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
This is an important base class in LLVM.
const Constant * stripPointerCasts() const
A parsed version of the target data layout string in and methods for querying it.
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Constant * getPersonalityFn() const
Get the personality function associated with this function.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
bool hasDLLImportStorageClass() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
This instruction inserts a struct field of array element value into an aggregate value.
A wrapper class for inspecting calls to intrinsic functions.
std::string SplitDwarfFile
bool isEHPad() const
Returns true if the block is a landing pad.
MachineInstrBundleIterator< const MachineInstr > const_iterator
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator_range< succ_iterator > successors()
bool isEHScopeReturnBlock() const
Convenience function that returns true if the bock ends in a EH scope return instruction.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineBasicBlock & front() const
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
A Module instance is used to store all the information related to an LLVM module.
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Return a value (possibly void), from a function.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
reverse_iterator rbegin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
TypeSize getElementOffset(unsigned Idx) const
Class to represent struct types.
Type::subtype_iterator element_iterator
TargetInstrInfo - Interface to description of machine instruction set.
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
EVT getMemValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
virtual bool allowTruncateForTailCall(Type *FromTy, Type *ToTy) const
Return true if a truncation from FromTy to ToTy is permitted when deciding whether a call is in tail ...
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
bool supportIndirectSymViaGOTPCRel() const
Target supports replacing a data "PC"-relative access to a symbol through another symbol,...
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
virtual TargetLoweringObjectFile * getObjFileLowering() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
MCTargetOptions MCOptions
Machine level options.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline.
virtual const TargetInstrInfo * getInstrInfo() const
virtual const TargetLowering * getTargetLowering() const
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize getZero()
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
bool isAggregateType() const
Return true if the type is an aggregate type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr bool isZero() const
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Tail
Attemps to make calls as fast as possible while guaranteeing that tail call optimization can always b...
@ SwiftTail
This follows the Swift calling convention in how arguments are passed but guarantees tail calls will ...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
@ DWARF_VERSION
Other constants.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool canDescribeGlobalAddressInLocationList(const MachineFunction &MF)
Test if the debug info for MF can name a describable global address in a location list too,...
LLVM_ABI ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
getICmpCondCode - Return the ISD condition code corresponding to the given LLVM IR integer condition ...
LLVM_ABI void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< EVT > *MemVTs=nullptr, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool isExceptionPointerAndSelectorType(Type *Ty)
Return true if landingpad result type Ty is a struct of an exception pointer (pointer or integer) and...
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset.
LLVM_ABI bool isSafeToSpeculativelyExecute(const Instruction *I, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr, bool UseVariableInfo=true, bool IgnoreUBImplyingAttrs=true)
Return true if the instruction does not have any effects besides calculating the result and does not ...
LLVM_ABI void ComputeValueTypes(const DataLayout &DL, Type *Ty, SmallVectorImpl< Type * > &Types, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
Given an LLVM IR type, compute non-aggregate subtypes.
auto reverse(ContainerTy &&C)
LLVM_ABI bool returnTypeIsEligibleForTailCall(const Function *F, const Instruction *I, const ReturnInst *Ret, const TargetLoweringBase &TLI, bool ReturnsFirstArg=false)
Test if given that the input instruction is in the tail call position if the return type or any attri...
LLVM_ABI ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
getFCmpCondCode - Return the ISD condition code corresponding to the given LLVM IR floating-point con...
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI bool attributesPermitTailCall(const Function *F, const Instruction *I, const ReturnInst *Ret, const TargetLoweringBase &TLI, bool *AllowDifferingSizes=nullptr)
Test if given that the input instruction is in the tail call position, if there is an attribute misma...
LLVM_ABI bool isInTailCallPosition(const CallBase &Call, const TargetMachine &TM, bool ReturnsFirstArg=false)
Test if the given instruction is in a position to be optimized with a tail-call.
DWARFExpression::Operation Op
LLVM_ABI ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC)
getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, return the equivalent code if w...
LLVM_ABI const GlobalValue * getDescribableGlobalAddress(const Constant *C, int64_t &Offset, const MachineFunction &MF)
If C is the address of a global, possibly displaced by a constant, return that global and set Offset ...
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
LLVM_ABI bool funcReturnsFirstArgOfCall(const CallInst &CI)
Returns true if the parent of CI returns CI's first argument after calling CI.
LLVM_ABI bool canDescribeGlobalAddressInDebugInfo(const GlobalValue *GV, const MachineFunction &MF)
Test if the address of GV can be described in debug info as a plain reference to its symbol,...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI void computeValueLLTs(const DataLayout &DL, Type &Ty, SmallVectorImpl< LLT > &ValueLLTs, SmallVectorImpl< TypeSize > *Offsets=nullptr, TypeSize StartingOffset=TypeSize::getZero())
computeValueLLTs - Given an LLVM IR type, compute a sequence of LLTs that represent all the individua...
LLVM_ABI GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
LLVM_ABI unsigned ComputeLinearIndex(Type *Ty, const unsigned *Indices, const unsigned *IndicesEnd, unsigned CurIndex=0)
Compute the linearized index of a member in a nested aggregate/struct/array.
LLVM_ABI DenseMap< const MachineBasicBlock *, int > getEHScopeMembership(const MachineFunction &MF)
LLVM_ABI LLT getLLTForType(Type &Ty, const DataLayout &DL)
Construct a low-level type based on an LLVM type.
static LLVM_ABI EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.