27 #define DEBUG_TYPE "instcombine"
29 STATISTIC(NumDeadStore,
"Number of dead stores eliminated");
30 STATISTIC(NumGlobalCopies,
"Number of allocas copied from constant global");
37 return GV->isConstant();
40 if (CE->getOpcode() == Instruction::BitCast ||
41 CE->getOpcode() == Instruction::AddrSpaceCast ||
42 CE->getOpcode() == Instruction::GetElementPtr)
64 while (!ValuesToInspect.
empty()) {
66 const bool IsOffset = ValuePair.second;
67 for (
auto &U : ValuePair.first->uses()) {
68 auto *
I = cast<Instruction>(U.getUser());
70 if (
auto *LI = dyn_cast<LoadInst>(
I)) {
72 if (!LI->isSimple())
return false;
76 if (isa<BitCastInst>(
I) || isa<AddrSpaceCastInst>(
I)) {
81 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
94 unsigned DataOpNo = CS.getDataOperandNo(&U);
95 bool IsArgOperand = CS.isArgOperand(&U);
98 if (IsArgOperand && CS.isInAllocaArgument(DataOpNo))
104 if (CS.onlyReadsMemory() &&
105 (CS.getInstruction()->use_empty() || CS.doesNotCapture(DataOpNo)))
110 if (IsArgOperand && CS.isByValArgument(DataOpNo))
116 if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
117 II->getIntrinsicID() == Intrinsic::lifetime_end) {
118 assert(II->use_empty() &&
"Lifetime markers have no result to use!");
132 if (U.getOperandNo() == 1) {
138 if (TheCopy)
return false;
142 if (IsOffset)
return false;
145 if (U.getOperandNo() != 0)
return false;
193 while (isa<AllocaInst>(*It) || isa<DbgInfoIntrinsic>(*It))
201 Value *Idx[2] = {NullIdx, NullIdx};
250 if (FirstInst != &AI) {
289 Copy->getSource(), AI.
getAlignment(), DL, &AI, &AC, &DT);
290 if (AI.getAlignment() <= SourceAlign) {
291 DEBUG(
dbgs() <<
"Found alloca equal to global: " << AI <<
'\n');
292 DEBUG(
dbgs() <<
" memcpy = " << *Copy <<
'\n');
293 for (
unsigned i = 0, e = ToDelete.
size();
i != e; ++
i)
295 Constant *TheSrc = cast<Constant>(Copy->getSource());
326 const Twine &Suffix =
"") {
328 "can't fold an atomic load to requested type");
340 for (
const auto &MDPair : MD) {
341 unsigned ID = MDPair.first;
373 auto *ITy = cast<IntegerType>(NewTy);
379 MDB.createRange(NonNullInt, NullInt));
412 "can't fold an atomic store of requested type");
423 for (
const auto &MDPair : MD) {
424 unsigned ID = MDPair.first;
505 return SI &&
SI->getPointerOperand() != &LI &&
506 !
SI->getPointerOperand()->isSwiftError();
513 auto *
SI = cast<StoreInst>(*UI++);
529 if (
auto* CI = dyn_cast<CastInst>(LI.
user_back()))
530 if (CI->isNoopCast(DL))
556 if (
auto *
ST = dyn_cast<StructType>(T)) {
558 auto NumElements =
ST->getNumElements();
559 if (NumElements == 1) {
570 if (SL->hasPadding())
582 for (
unsigned i = 0;
i < NumElements;
i++) {
583 Value *Indices[2] = {
589 auto EltAlign =
MinAlign(Align, SL->getElementOffset(
i));
598 if (
auto *AT = dyn_cast<ArrayType>(T)) {
599 auto *ET = AT->getElementType();
600 auto NumElements = AT->getNumElements();
601 if (NumElements == 1) {
611 if (NumElements > 1024)
626 for (uint64_t
i = 0;
i < NumElements;
i++) {
627 Value *Indices[2] = {
661 if (!Visited.
insert(P).second)
670 if (
PHINode *PN = dyn_cast<PHINode>(P)) {
671 for (
Value *IncValue : PN->incoming_values())
677 if (GA->isInterposable())
685 if (
AllocaInst *AI = dyn_cast<AllocaInst>(P)) {
686 if (!AI->getAllocatedType()->isSized())
702 if (!GV->hasDefinitiveInitializer() || !GV->isConstant())
706 if (InitSize > MaxSize)
712 }
while (!Worklist.
empty());
743 if (
const ConstantInt *CI = dyn_cast<ConstantInt>(V))
755 Idx = FirstNZIdx(GEPI);
764 if (!AllocTy || !AllocTy->isSized())
773 auto IsAllNonNegative = [&]() {
775 bool KnownNonNegative, KnownNegative;
777 KnownNegative, 0, MemI);
778 if (KnownNonNegative)
803 template <
typename T>
813 MemI.setOperand(MemI.getPointerOperandIndex(), NewGEPI);
832 unsigned EffectiveLoadAlign =
835 if (KnownAlign > EffectiveLoadAlign)
837 else if (LoadAlign == 0)
853 bool IsLoadCSE =
false;
870 const Value *GEPI0 = GEPI->getOperand(0);
872 if (isa<ConstantPointerNull>(GEPI0) && GEPI->getPointerAddressSpace() == 0){
885 if (isa<UndefValue>(Op) ||
912 SI->getOperand(1)->getName()+
".val");
914 SI->getOperand(2)->getName()+
".val");
924 if (isa<ConstantPointerNull>(
SI->getOperand(1)) &&
931 if (isa<ConstantPointerNull>(
SI->getOperand(2)) &&
957 while (
auto *IV = dyn_cast<InsertValueInst>(V)) {
961 auto *W =
E->getVectorOperand();
967 if (!CI || IV->getNumIndices() != 1 || CI->getZExtValue() != *IV->idx_begin())
969 V = IV->getAggregateOperand();
971 if (!isa<UndefValue>(V) ||!U)
974 auto *UT = cast<VectorType>(U->
getType());
978 if (DL.getTypeStoreSizeInBits(UT) != DL.getTypeStoreSizeInBits(VT)) {
981 if (
auto *AT = dyn_cast<ArrayType>(VT)) {
982 if (AT->getNumElements() != UT->getNumElements())
985 auto *
ST = cast<StructType>(VT);
986 if (
ST->getNumElements() != UT->getNumElements())
988 for (
const auto *EltT :
ST->elements()) {
989 if (EltT != UT->getElementType())
1029 if (
auto *BC = dyn_cast<BitCastInst>(V)) {
1030 V = BC->getOperand(0);
1060 if (
auto *
ST = dyn_cast<StructType>(T)) {
1062 unsigned Count =
ST->getNumElements();
1073 if (SL->hasPadding())
1084 AddrName +=
".repack";
1088 for (
unsigned i = 0;
i < Count;
i++) {
1089 Value *Indices[2] = {
1096 auto EltAlign =
MinAlign(Align, SL->getElementOffset(
i));
1103 if (
auto *AT = dyn_cast<ArrayType>(T)) {
1105 auto NumElements = AT->getNumElements();
1106 if (NumElements == 1) {
1116 if (NumElements > 1024)
1129 AddrName +=
".repack";
1135 for (uint64_t
i = 0;
i < NumElements;
i++) {
1136 Value *Indices[2] = {
1143 auto EltAlign =
MinAlign(Align, Offset);
1164 if (A == B)
return true;
1171 if (isa<BinaryOperator>(A) ||
1174 isa<GetElementPtrInst>(A))
1176 if (cast<Instruction>(A)->isIdenticalToWhenDefined(BI))
1195 unsigned EffectiveStoreAlign =
1198 if (KnownAlign > EffectiveStoreAlign)
1200 else if (StoreAlign == 0)
1220 if (isa<AllocaInst>(Ptr))
1223 if (isa<AllocaInst>(
GEP->getOperand(0))) {
1224 if (
GEP->getOperand(0)->hasOneUse())
1234 for (
unsigned ScanInsts = 6; BBI != SI.
getParent()->
begin() && ScanInsts;
1239 if (isa<DbgInfoIntrinsic>(BBI) ||
1240 (isa<BitCastInst>(BBI) && BBI->getType()->isPointerTy())) {
1245 if (
StoreInst *PrevSI = dyn_cast<StoreInst>(BBI)) {
1260 if (
LoadInst *LI = dyn_cast<LoadInst>(BBI)) {
1272 if (BBI->mayWriteToMemory() || BBI->mayReadFromMemory())
1278 if (!isa<UndefValue>(Val)) {
1287 if (isa<UndefValue>(Val))
1296 }
while (isa<DbgInfoIntrinsic>(BBI) ||
1297 (isa<BitCastInst>(BBI) && BBI->getType()->isPointerTy()));
1298 if (
BranchInst *BI = dyn_cast<BranchInst>(BBI))
1299 if (BI->isUnconditional())
1300 if (SimplifyStoreAtEndOfBlock(SI))
1314 bool InstCombiner::SimplifyStoreAtEndOfBlock(
StoreInst &SI) {
1316 "this code has not been auditted for volatile or ordered store case");
1348 if (StoreBB == DestBB || OtherBB == DestBB)
1354 if (!OtherBr || BBI == OtherBB->
begin())
1360 if (OtherBr->isUnconditional()) {
1363 while (isa<DbgInfoIntrinsic>(BBI) ||
1364 (isa<BitCastInst>(BBI) && BBI->getType()->isPointerTy())) {
1365 if (BBI==OtherBB->
begin())
1378 if (OtherBr->getSuccessor(0) != StoreBB &&
1379 OtherBr->getSuccessor(1) != StoreBB)
1387 if ((OtherStore = dyn_cast<StoreInst>(BBI))) {
1395 if (BBI->mayReadFromMemory() || BBI->mayWriteToMemory() ||
1396 BBI == OtherBB->
begin())
1405 if (
I->mayReadFromMemory() ||
I->mayWriteToMemory())
Value * getValueOperand()
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to ensure that the alignment of V is at least PrefAlign bytes.
bool isNonIntegralPointerType(PointerType *PT) const
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
Type * getSourceElementType() const
STATISTIC(NumFunctions,"Total number of functions")
bool isVolatile() const
Return true if this is a store to a volatile memory location.
SynchronizationScope getSynchScope() const
void setAlignment(unsigned Align)
unsigned getNumOperands() const
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
cl::opt< unsigned > DefMaxInstsToScan
The default number of maximum instructions to scan in the block, used by FindAvailableLoadedValue().
const DataLayout & getDataLayout() const
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr, Instruction *MDFrom=nullptr)
void Add(Instruction *I)
Add - Add the specified instruction to the worklist if it isn't already in it.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
const Function * getParent() const
Return the enclosing method, or null if none.
const Instruction & front() const
static LoadInst * combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewTy, const Twine &Suffix="")
Helper to combine a load to a new type.
An instruction for reading from memory.
static bool pointsToConstantGlobal(Value *V)
pointsToConstantGlobal - Return true if V (possibly indirectly) points to some part of a constant glo...
static IntegerType * getInt64Ty(LLVMContext &C)
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Get all metadata attached to this Instruction.
static bool isOnlyCopiedFromConstantGlobal(Value *V, MemTransferInst *&TheCopy, SmallVectorImpl< Instruction * > &ToDelete)
isOnlyCopiedFromConstantGlobal - Recursively walk the uses of a (derived) pointer to an alloca...
bool isSafeToLoadUnconditionally(Value *V, unsigned Align, const DataLayout &DL, Instruction *ScanFrom=nullptr, const DominatorTree *DT=nullptr)
Return true if we know that executing a load from this value cannot trap.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
StringRef getName() const
Return a constant reference to the value's name.
iterator begin()
Instruction iterator methods.
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, unsigned Align, bool isVolatile=false)
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1...
Instruction * getFirstNonPHIOrDbg()
Returns a pointer to the first instruction in this block that is not a PHINode or a debug intrinsic...
AllocaInst * CreateAlloca(Type *Ty, Value *ArraySize=nullptr, const Twine &Name="")
This class represents the LLVM 'select' instruction.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
const APInt & getValue() const
Return the constant as an APInt value reference.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Instruction * eraseInstFromFunction(Instruction &I)
Combiner aware instruction erasure.
static Instruction * replaceGEPIdxWithZero(InstCombiner &IC, Value *Ptr, T &MemI)
The core instruction combiner logic.
void setName(const Twine &Name)
Change the name of the value.
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following: ...
SynchronizationScope getSynchScope() const
LLVM_NODISCARD bool empty() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
A constant value that is initialized with an expression using other constant values.
static GetElementPtrInst * CreateInBounds(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Create an "inbounds" getelementptr.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
APInt zextOrSelf(unsigned width) const
Zero extend or truncate to width.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool contains(const APInt &Val) const
Return true if the specified value is in the set.
static Instruction * simplifyAllocaArraySize(InstCombiner &IC, AllocaInst &AI)
This class represents a no-op cast from one type to another.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Value * FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB, BasicBlock::iterator &ScanFrom, unsigned MaxInstsToScan=DefMaxInstsToScan, AliasAnalysis *AA=nullptr, bool *IsLoadCSE=nullptr)
Scan backwards to see if we have the value of the given load available locally within a small number ...
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
bool isInBounds() const
Determine whether the GEP has the inbounds flag.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
constexpr uint64_t MinAlign(uint64_t A, uint64_t B)
MinAlign - A and B are either alignments or offsets.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
LoadInst * CreateLoad(Value *Ptr, const char *Name)
static Instruction * combineLoadToOperationType(InstCombiner &IC, LoadInst &LI)
Combine loads to match the type of their uses' value after looking through intervening bitcasts...
static bool equivalentAddressValues(Value *A, Value *B)
equivalentAddressValues - Test if A and B will obviously have the same value.
static bool unpackStoreToAggregate(InstCombiner &IC, StoreInst &SI)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction...
void setAAMetadata(const AAMDNodes &N)
Sets the metadata on this instruction from the AAMDNodes structure.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
BasicBlock * getSuccessor(unsigned idx) const
Return the specified successor.
uint64_t getTypeStoreSizeInBits(Type *Ty) const
Returns the maximum number of bits that may be overwritten by storing the specified type; always a mu...
Conditional or Unconditional Branch instruction.
This is an important base class in LLVM.
PointerType * getType() const
Overload to return most specific pointer type.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
static StoreInst * combineStoreToNewValue(InstCombiner &IC, StoreInst &SI, Value *V)
Combine a store to a new type.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Instruction * visitAllocaInst(AllocaInst &AI)
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
Value * getPointerOperand()
self_iterator getIterator()
void setAlignment(unsigned Align)
bool isPointerTy() const
True if this is an instance of PointerType.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
InstCombineWorklist & Worklist
A worklist of the instructions that need to be simplified.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
unsigned getABITypeAlignment(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
Iterator for intrusive lists based on ilist_node.
AtomicOrdering getOrdering() const
Returns the ordering effect of this store.
This is the shared class of boolean and integer constants.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
Instruction * user_back()
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
static bool isSupportedAtomicType(Type *Ty)
bool isVolatile() const
Return true if this is a load from a volatile memory location.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
bool isSwiftError() const
Return true if this value is a swifterror value.
LLVM_NODISCARD T pop_back_val()
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
const BasicBlock & getEntryBlock() const
unsigned getPointerAddressSpace() const
Returns the address space of the pointer operand.
static bool combineStoreToValueType(InstCombiner &IC, StoreInst &SI)
Combine stores to match the type of value being stored.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
void setOperand(unsigned i, Value *Val)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Class for arbitrary precision integers.
bool isIntegerTy() const
True if this is an instance of IntegerType.
iterator_range< user_iterator > users()
static bool isObjectSizeLessThanOrEq(Value *V, uint64_t MaxSize, const DataLayout &DL)
static Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the type of the element that would be loaded with a load instruction with the specified param...
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Value * getSource() const
This is just like getRawSource, but it strips off any cast instructions that feed it...
This class wraps the llvm.memcpy/memmove intrinsics.
void emplace_back(ArgTypes &&...Args)
bool isAggregateType() const
Return true if the type is an aggregate type.
static IntegerType * getInt32Ty(LLVMContext &C)
unsigned getAlignment() const
Return the alignment of the access that is being performed.
void getAAMetadata(AAMDNodes &N, bool Merge=false) const
Fills the AAMDNodes structure with AA metadata from this instruction.
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
static Value * likeBitCastFromVector(InstCombiner &IC, Value *V)
Look for extractelement/insertvalue sequence that acts like a bitcast.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Instruction * InsertNewInstBefore(Instruction *New, Instruction &Old)
Inserts an instruction New before instruction Old.
void ComputeSignBit(Value *V, bool &KnownZero, bool &KnownOne, unsigned Depth=0, Instruction *CxtI=nullptr) const
void combineMetadataForCSE(Instruction *K, const Instruction *J)
Combine the metadata of two instructions so that K can replace J.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
static bool canReplaceGEPIdxWithZero(InstCombiner &IC, GetElementPtrInst *GEPI, Instruction *MemI, unsigned &Idx)
Instruction * replaceInstUsesWith(Instruction &I, Value *V)
A combiner-aware RAUW-like routine.
LoadInst * CreateAlignedLoad(Value *Ptr, unsigned Align, const char *Name)
Instruction * visitLoadInst(LoadInst &LI)
LLVM Value Representation.
void setAlignment(unsigned Align)
This file provides internal interfaces used to implement the InstCombine.
Instruction * visitStoreInst(StoreInst &SI)
const Value * getArraySize() const
Get the number of elements allocated.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
StringRef - Represent a constant reference to a string, i.e.
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const
This function determines if the specified instruction executes the same operation as the current one...
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU...
iterator getFirstInsertionPt()
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
Value * getPointerOperand()
static Instruction * unpackLoadToAggregate(InstCombiner &IC, LoadInst &LI)
Instruction * visitAllocSite(Instruction &FI)
const BasicBlock * getParent() const
A wrapper class for inspecting calls to intrinsic functions.
an instruction to allocate memory on the stack