36 const unsigned *Indices,
37 const unsigned *IndicesEnd,
40 if (Indices && Indices == IndicesEnd)
44 if (
StructType *STy = dyn_cast<StructType>(Ty)) {
47 EE = STy->element_end();
49 if (Indices && *Indices ==
unsigned(EI - EB))
53 assert(!Indices &&
"Unexpected out of bound");
57 else if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
58 Type *EltTy = ATy->getElementType();
59 unsigned NumElts = ATy->getNumElements();
63 assert(*Indices < NumElts &&
"Unexpected out of bound");
66 CurIndex += EltLinearOffset* *Indices;
69 CurIndex += EltLinearOffset*NumElts;
87 uint64_t StartingOffset) {
89 if (
StructType *STy = dyn_cast<StructType>(Ty)) {
93 EE = STy->element_end();
100 if (
ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
101 Type *EltTy = ATy->getElementType();
103 for (
unsigned i = 0,
e = ATy->getNumElements(); i !=
e; ++i)
105 StartingOffset + i * EltSize);
122 uint64_t StartingOffset) {
130 uint64_t StartingOffset) {
132 if (
StructType *STy = dyn_cast<StructType>(&Ty)) {
134 for (
unsigned I = 0,
E = STy->getNumElements();
I !=
E; ++
I)
140 if (
ArrayType *ATy = dyn_cast<ArrayType>(&Ty)) {
141 Type *EltTy = ATy->getElementType();
143 for (
unsigned i = 0,
e = ATy->getNumElements(); i !=
e; ++i)
145 StartingOffset + i * EltSize);
153 if (Offsets !=
nullptr)
163 if (Var && Var->getName() ==
"llvm.eh.catch.all.value") {
164 assert(Var->hasInitializer() &&
165 "The EH catch-all value must have an initializer");
168 if (!GV) V = cast<ConstantPointerNull>(Init);
171 assert((GV || isa<ConstantPointerNull>(V)) &&
172 "TypeInfo must be a global variable or NULL");
181 for (
unsigned i = 0,
e = CInfos.size(); i !=
e; ++i) {
183 for (
unsigned j = 0, ee = CI.
Codes.size(); j != ee; ++j) {
258 (isa<VectorType>(T1) && isa<VectorType>(T2) &&
283 const Value *NoopInput =
nullptr;
286 if (isa<BitCastInst>(I)) {
290 }
else if (isa<GetElementPtrInst>(I)) {
292 if (cast<GetElementPtrInst>(I)->hasAllZeroIndices())
294 }
else if (isa<IntToPtrInst>(I)) {
298 if (!isa<VectorType>(I->
getType()) &&
302 }
else if (isa<PtrToIntInst>(I)) {
306 if (!isa<VectorType>(I->
getType()) &&
310 }
else if (isa<TruncInst>(I) &&
312 DataBits = std::min((uint64_t)DataBits,
316 const Value *ReturnedOp = CS.getReturnedArgOperand();
318 NoopInput = ReturnedOp;
319 }
else if (
const InsertValueInst *IVI = dyn_cast<InsertValueInst>(V)) {
322 if (ValLoc.
size() >= InsertLoc.
size() &&
328 NoopInput = IVI->getInsertedValueOperand();
357 bool AllowDifferingSizes,
365 unsigned BitsRequired = UINT_MAX;
366 RetVal =
getNoopInput(RetVal, RetIndices, BitsRequired, TLI, DL);
370 if (isa<UndefValue>(RetVal))
377 unsigned BitsProvided = UINT_MAX;
378 CallVal =
getNoopInput(CallVal, CallIndices, BitsProvided, TLI, DL);
382 if (CallVal != RetVal || CallIndices != RetIndices)
389 if (BitsProvided < BitsRequired ||
390 (!AllowDifferingSizes && BitsProvided != BitsRequired))
399 if (
ArrayType *AT = dyn_cast<ArrayType>(T))
400 return Idx < AT->getNumElements();
402 return Idx < cast<StructType>(
T)->getNumElements();
438 Type *DeeperType = SubTypes.
back()->getTypeAtIndex(Path.
back());
471 SubTypes.
push_back(cast<CompositeType>(Next));
473 Next = cast<CompositeType>(Next)->getTypeAtIndex(0U);
483 while (SubTypes.
back()->getTypeAtIndex(Path.
back())->isAggregateType()) {
499 assert(!Path.
empty() &&
"found a leaf but didn't set the path?");
500 }
while (SubTypes.
back()->getTypeAtIndex(Path.
back())->isAggregateType());
539 if (isa<DbgInfoIntrinsic>(BBI))
544 if (II->getIntrinsicID() == Intrinsic::lifetime_end ||
545 II->getIntrinsicID() == Intrinsic::assume)
547 if (BBI->mayHaveSideEffects() || BBI->mayReadFromMemory() ||
560 bool *AllowDifferingSizes) {
563 bool &ADS = AllowDifferingSizes ? *AllowDifferingSizes : DummyADS;
574 CallerAttrs.removeAttribute(Attribute::NonNull);
575 CalleeAttrs.removeAttribute(Attribute::NonNull);
576 CallerAttrs.removeAttribute(Attribute::Dereferenceable);
577 CalleeAttrs.removeAttribute(Attribute::Dereferenceable);
578 CallerAttrs.removeAttribute(Attribute::DereferenceableOrNull);
579 CalleeAttrs.removeAttribute(Attribute::DereferenceableOrNull);
581 if (CallerAttrs.contains(Attribute::ZExt)) {
582 if (!CalleeAttrs.contains(Attribute::ZExt))
586 CallerAttrs.removeAttribute(Attribute::ZExt);
587 CalleeAttrs.removeAttribute(Attribute::ZExt);
588 }
else if (CallerAttrs.contains(Attribute::SExt)) {
589 if (!CalleeAttrs.contains(Attribute::SExt))
593 CallerAttrs.removeAttribute(Attribute::SExt);
594 CalleeAttrs.removeAttribute(Attribute::SExt);
608 CalleeAttrs.removeAttribute(Attribute::SExt);
609 CalleeAttrs.removeAttribute(Attribute::ZExt);
615 return CallerAttrs == CalleeAttrs;
621 assert(A && B &&
"Expected non-null inputs!");
631 return A == BitCastIn->getOperand(0);
644 if (isa<UndefValue>(Ret->
getOperand(0)))
return true;
647 bool AllowDifferingSizes;
657 const CallInst *Call = cast<CallInst>(
I);
660 if (((IID == Intrinsic::memcpy &&
662 (IID == Intrinsic::memmove &&
664 (IID == Intrinsic::memset &&
695 Type *SlotType = RetSubTypes.
back()->getTypeAtIndex(RetPath.
back());
708 AllowDifferingSizes, TLI,
722 while (!Worklist.
empty()) {
725 if (Visiting->
isEHPad() && Visiting != MBB)
729 auto P = EHScopeMembership.
insert(std::make_pair(Visiting, EHScope));
733 assert(
P.first->second == EHScope &&
"MBB is part of two scopes!");
753 return EHScopeMembership;
765 if (MBB.isEHScopeEntry()) {
767 }
else if (IsSEH && MBB.isEHPad()) {
769 }
else if (MBB.pred_empty()) {
789 if (EHScopeBlocks.
empty())
790 return EHScopeMembership;
804 for (std::pair<const MachineBasicBlock *, int> CatchRetPair :
808 return EHScopeMembership;
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
Return a value (possibly void), from a function.
A parsed version of the target data layout string in and methods for querying it. ...
ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred)
getICmpCondCode - Return the ISD condition code corresponding to the given LLVM IR integer condition ...
bool isEHScopeReturnBlock() const
Convenience function that returns true if the bock ends in a EH scope return instruction.
This class represents lattice values for constants.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
void push_back(const T &Elt)
This class represents a function call, abstracting a target machine's calling convention.
virtual const TargetLowering * getTargetLowering() const
reverse_iterator rbegin() const
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.
The two locations do not alias at all.
0 1 0 0 True if ordered and less than
1 1 1 0 True if unordered or not equal
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
GlobalValue * ExtractTypeInfo(Value *V)
ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
bool returnTypeIsEligibleForTailCall(const Function *F, const Instruction *I, const ReturnInst *Ret, const TargetLoweringBase &TLI)
Test if given that the input instruction is in the tail call position if the return type or any attri...
ConstraintCodeVector Codes
Code - The constraint code, either the register name (in braces) or the constraint letter/number...
iterator_range< succ_iterator > successors()
CallingConv::ID getCallingConv() const
Get the calling convention of the call.
Value * getArgOperand(unsigned i) const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
1 0 0 1 True if unordered or equal
Used to lazily calculate structure layout information for a target machine, based on the DataLayout s...
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
const HexagonInstrInfo * TII
Class to represent struct types.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
0 1 0 1 True if ordered and less than or equal
unsigned getCatchReturnOpcode() const
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
InstrTy * getInstruction() const
Type * getType() const
All values are typed, get the type of this value.
Class to represent array types.
This class represents a no-op cast from one type to another.
AttributeList getAttributes() const
Return the attribute list for this Function.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
virtual const TargetInstrInfo * getInstrInfo() const
ISD::CondCode getFCmpCondCode(FCmpInst::Predicate Pred)
getFCmpCondCode - Return the ISD condition code corresponding to the given LLVM IR floating-point con...
Type::subtype_iterator element_iterator
void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty, SmallVectorImpl< EVT > &ValueVTs, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
ComputeValueVTs - Given an LLVM IR type, compute a sequence of EVTs that represent all the individual...
Value * getOperand(unsigned i) const
bool hasInlineAsmMemConstraint(InlineAsm::ConstraintInfoVector &CInfos, const TargetLowering &TLI)
hasInlineAsmMemConstraint - Return true if the inline asm instruction being processed uses a memory '...
TargetInstrInfo - Interface to description of machine instruction set.
bool isVoidTy() const
Return true if this is 'void'.
static bool indexReallyValid(CompositeType *T, unsigned Idx)
For an aggregate type, determine whether a given index is within bounds or not.
static bool nextRealType(SmallVectorImpl< CompositeType *> &SubTypes, SmallVectorImpl< unsigned > &Path)
Set the iterator data-structures to the next non-empty, non-aggregate subtype.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
LLVM Basic Block Representation.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
The instances of the Type class are immutable: once they are created, they are never changed...
virtual ConstraintType getConstraintType(StringRef Constraint) const
Given a constraint, return the type of constraint it is for this target.
bool isIndirect
isIndirect - True if this operand is an indirect operand.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool isPointerTy() const
True if this is an instance of PointerType.
uint64_t getFixedSize() const
void computeValueLLTs(const DataLayout &DL, Type &Ty, SmallVectorImpl< LLT > &ValueTys, SmallVectorImpl< uint64_t > *Offsets=nullptr, uint64_t StartingOffset=0)
computeValueLLTs - Given an LLVM IR type, compute a sequence of LLTs that represent all the individua...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool mayHaveSideEffects() const
Return true if the instruction may have side effects.
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
unsigned GuaranteedTailCallOpt
GuaranteedTailCallOpt - This flag is enabled when -tailcallopt is specified on the commandline...
static bool firstRealType(Type *Next, SmallVectorImpl< CompositeType *> &SubTypes, SmallVectorImpl< unsigned > &Path)
Find the first non-empty, scalar-like type in Next and setup the iterator components.
0 1 1 1 True if ordered (no nans)
1 1 1 1 Always true (always folded)
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 ...
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
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...
const MachineBasicBlock & front() const
1 1 0 1 True if unordered, less than, or equal
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM)
Test if the given instruction is in a position to be optimized with a tail-call.
std::vector< ConstraintInfo > ConstraintInfoVector
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
LLT getLLTForType(Type &Ty, const DataLayout &DL)
Construct a low-level type based on an LLVM type.
0 0 1 0 True if ordered and greater than
Iterator for intrusive lists based on ilist_node.
unsigned getNumOperands() const
static bool isNoopBitcast(Type *T1, Type *T2, const TargetLoweringBase &TLI)
1 1 0 0 True if unordered or less than
Module.h This file contains the declarations for the Module class.
bool isAggregateType() const
Return true if the type is an aggregate type.
LLVM_NODISCARD T pop_back_val()
DenseMap< const MachineBasicBlock *, int > getEHScopeMembership(const MachineFunction &MF)
static bool advanceToNextLeafType(SmallVectorImpl< CompositeType *> &SubTypes, SmallVectorImpl< unsigned > &Path)
Move the given iterators to the next leaf type in depth first traversal.
ISD::CondCode getFCmpCodeWithoutNaN(ISD::CondCode CC)
getFCmpCodeWithoutNaN - Given an ISD condition code comparing floats, return the equivalent code if w...
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
bool isTypeLegal(EVT VT) const
Return true if the target has native support for the specified value type.
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Common super class of ArrayType, StructType and VectorType.
static void collectEHScopeMembers(DenseMap< const MachineBasicBlock *, int > &EHScopeMembership, int EHScope, const MachineBasicBlock *MBB)
reverse_iterator rend() const
uint64_t getElementOffset(unsigned Idx) const
bool isEHPad() const
Returns true if the block is a landing pad.
LLVM_NODISCARD bool empty() const
unsigned greater or equal
Establish a view to a call site for examination.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
bool mayReadFromMemory() const
Return true if this instruction may read memory.
0 1 1 0 True if ordered and operands are unequal
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Tail - This calling convention attemps to make calls as fast as possible while guaranteeing that tail...
1 0 1 0 True if unordered or greater than
static EVT getEVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
EVT getMemValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
reverse_iterator rbegin()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isAsynchronousEHPersonality(EHPersonality Pers)
Returns true if this personality function catches asynchronous exceptions.
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
0 0 0 1 True if ordered and equal
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Constant * getPersonalityFn() const
Get the personality function associated with this function.
1 0 1 1 True if unordered, greater than, or equal
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
static bool isPointerBitcastEqualTo(const Value *A, const Value *B)
Check whether B is a bitcast of a pointer type to another pointer type, which is equal to A...
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...
0 0 1 1 True if ordered and greater than or equal
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.
0 0 0 0 Always false (always folded)
A wrapper class for inspecting calls to intrinsic functions.
This file describes how to lower LLVM code to machine code.
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
const BasicBlock * getParent() const
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
This instruction inserts a struct field of array element value into an aggregate value.