Go to the documentation of this file.
39 cl::desc(
"Deref attributes and metadata infer facts at definition only"));
45 assert(Ty &&
"Value defined with a null type: Error!");
50 : VTy(
checkType(ty)), UseList(nullptr), SubclassID(scid), HasValueHandle(0),
51 SubclassOptionalData(0), SubclassData(0), NumUserOperands(0),
53 static_assert(ConstantFirstVal == 0,
"!(SubclassID < ConstantFirstVal)");
58 if (SubclassID >= InstructionVal)
59 OpCode = SubclassID - InstructionVal;
61 OpCode == Instruction::CallBr)
63 "invalid CallBase type!");
64 else if (SubclassID != BasicBlockVal &&
65 ( SubclassID > ConstantLastVal))
67 "Cannot create non-first-class values except for constants!");
68 static_assert(
sizeof(
Value) == 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
83 #ifndef NDEBUG // Only in -g mode...
94 dbgs() <<
"While deleting: " << *VTy <<
" %" <<
getName() <<
"\n";
95 for (
auto *U :
users())
96 dbgs() <<
"Use still stuck around after Def is destroyed:" << *U <<
"\n";
108 #define HANDLE_VALUE(Name) \
109 case Value::Name##Val: \
110 delete static_cast<Name *>(this); \
112 #define HANDLE_MEMORY_VALUE(Name) \
113 case Value::Name##Val: \
114 static_cast<DerivedUser *>(this)->DeleteValue( \
115 static_cast<DerivedUser *>(this)); \
117 #define HANDLE_CONSTANT(Name) \
118 case Value::Name##Val: \
119 llvm_unreachable("constants should be destroyed with destroyConstant"); \
121 #define HANDLE_INSTRUCTION(Name)
122 #include "llvm/IR/Value.def"
124 #define HANDLE_INST(N, OPC, CLASS) \
125 case Value::InstructionVal + Instruction::OPC: \
126 delete static_cast<CLASS *>(this); \
128 #define HANDLE_USER_INST(N, OPC, CLASS)
129 #include "llvm/IR/Instruction.def"
136 void Value::destroyValueName() {
164 Use *Result =
nullptr;
166 if (!U.getUser()->isDroppable()) {
176 User *Result =
nullptr;
177 for (
auto *U :
users()) {
178 if (!U->isDroppable()) {
179 if (Result && Result != U)
199 if (U.getUser()->isDroppable() && ShouldDrop(&U))
200 ToBeEdited.push_back(&U);
201 for (
Use *U : ToBeEdited)
208 if (UsrOp.get() ==
this)
215 if (
auto *Assume = dyn_cast<AssumeInst>(U.
getUser())) {
222 BOI.
Tag = Assume->getContext().pImpl->getOrInsertBundleTag(
"ignore");
239 for (; BI != BE && UI != UE; ++BI, ++UI) {
244 const auto *
User = dyn_cast<Instruction>(*UI);
260 ST = PP->getValueSymbolTable();
263 ST =
P->getValueSymbolTable();
264 }
else if (
GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
265 if (
Module *
P = GV->getParent())
266 ST = &
P->getValueSymbolTable();
267 }
else if (
Argument *A = dyn_cast<Argument>(V)) {
269 ST =
P->getValueSymbolTable();
271 assert(isa<Constant>(V) &&
"Unknown value type!");
283 "No name entry found!");
292 "HasName bit out of sync!");
314 void Value::setNameImpl(
const Twine &NewName) {
316 if (
getContext().shouldDiscardValueNames() && !isa<GlobalValue>(
this))
326 "Null bytes are not allowed in names");
332 assert(!
getType()->isVoidTy() &&
"Cannot assign a name to void values!");
340 if (NameRef.
empty()) {
373 setNameImpl(NewName);
374 if (
Function *
F = dyn_cast<Function>(
this))
375 F->recalculateIntrinsicID();
379 assert(V !=
this &&
"Illegal call to this->takeName(this)!");
414 assert(!Failure &&
"V has a name, so it should have a ST!"); (void)Failure;
436 ST->reinsertValue(
this);
453 const GlobalValue *GV = dyn_cast<GlobalValue>(
this);
466 if (!Cache.
insert(Expr).second)
472 auto *CE = dyn_cast<ConstantExpr>(
O);
485 auto *
C = dyn_cast<Constant>(V);
489 auto *CE = dyn_cast<ConstantExpr>(Expr);
498 void Value::doRAUW(
Value *New, ReplaceMetadataUses ReplaceMetaUses) {
499 assert(New &&
"Value::replaceAllUsesWith(<null>) is invalid!");
501 "this->replaceAllUsesWith(expr(this)) is NOT valid!");
503 "replaceAllUses of value with new value of different type!");
515 if (
auto *
C = dyn_cast<Constant>(U.
getUser())) {
516 if (!isa<GlobalValue>(
C)) {
517 C->handleOperandChange(
this, New);
526 BB->replaceSuccessorsPhiUsesWith(cast<BasicBlock>(New));
530 doRAUW(New, ReplaceMetadataUses::Yes);
534 doRAUW(New, ReplaceMetadataUses::No);
539 assert(New &&
"Value::replaceUsesWithIf(<null>) is invalid!");
541 "replaceUses of value with new value of different type!");
547 if (!ShouldReplace(U))
551 if (
auto *
C = dyn_cast<Constant>(U.
getUser())) {
552 if (!isa<GlobalValue>(
C)) {
561 while (!Consts.empty()) {
573 for (
auto *DVI : DbgUsers) {
574 if (DVI->getParent() !=
BB)
575 DVI->replaceVariableLocationOp(V, New);
582 assert(New &&
"Value::replaceUsesOutsideBlock(<null>, BB) is invalid!");
584 "this->replaceUsesOutsideBlock(expr(this), BB) is NOT valid!");
586 "replaceUses of value with new value of different type!");
587 assert(
BB &&
"Basic block that may contain a use of 'New' must be defined\n");
591 auto *
I = dyn_cast<Instruction>(U.
getUser());
593 return !
I ||
I->getParent() !=
BB;
599 enum PointerStripKind {
601 PSK_ZeroIndicesAndAliases,
602 PSK_ZeroIndicesSameRepresentation,
603 PSK_ForAliasAnalysis,
604 PSK_InBoundsConstantIndices,
608 template <Po
interStripKind StripKind>
static void NoopCallback(
const Value *) {}
610 template <Po
interStripKind StripKind>
611 static const Value *stripPointerCastsAndOffsets(
624 if (
auto *
GEP = dyn_cast<GEPOperator>(V)) {
626 case PSK_ZeroIndices:
627 case PSK_ZeroIndicesAndAliases:
628 case PSK_ZeroIndicesSameRepresentation:
629 case PSK_ForAliasAnalysis:
630 if (!
GEP->hasAllZeroIndices())
633 case PSK_InBoundsConstantIndices:
634 if (!
GEP->hasAllConstantIndices())
638 if (!
GEP->isInBounds())
642 V =
GEP->getPointerOperand();
644 V = cast<Operator>(V)->getOperand(0);
647 }
else if (StripKind != PSK_ZeroIndicesSameRepresentation &&
651 V = cast<Operator>(V)->getOperand(0);
652 }
else if (StripKind == PSK_ZeroIndicesAndAliases && isa<GlobalAlias>(V)) {
653 V = cast<GlobalAlias>(V)->getAliasee();
654 }
else if (StripKind == PSK_ForAliasAnalysis && isa<PHINode>(V) &&
655 cast<PHINode>(V)->getNumIncomingValues() == 1) {
656 V = cast<PHINode>(V)->getIncomingValue(0);
658 if (
const auto *Call = dyn_cast<CallBase>(V)) {
659 if (
const Value *RV =
Call->getReturnedArgOperand()) {
666 if (StripKind == PSK_ForAliasAnalysis &&
667 (
Call->getIntrinsicID() == Intrinsic::launder_invariant_group ||
668 Call->getIntrinsicID() == Intrinsic::strip_invariant_group)) {
669 V =
Call->getArgOperand(0);
676 }
while (Visited.
insert(V).second);
683 return stripPointerCastsAndOffsets<PSK_ZeroIndices>(
this);
687 return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndAliases>(
this);
691 return stripPointerCastsAndOffsets<PSK_ZeroIndicesSameRepresentation>(
this);
695 return stripPointerCastsAndOffsets<PSK_InBoundsConstantIndices>(
this);
699 return stripPointerCastsAndOffsets<PSK_ForAliasAnalysis>(
this);
704 bool AllowInvariantGroup,
706 if (!
getType()->isPtrOrPtrVectorTy())
709 unsigned BitWidth = Offset.getBitWidth();
711 "The offset bit width does not match the DL specification.");
717 const Value *V =
this;
719 if (
auto *
GEP = dyn_cast<GEPOperator>(V)) {
721 if (!AllowNonInbounds && !
GEP->isInBounds())
731 if (!
GEP->accumulateConstantOffset(
DL, GEPOffset, ExternalAnalysis))
737 if (GEPOffset.getMinSignedBits() >
BitWidth)
743 if (!ExternalAnalysis) {
744 Offset += GEPOffsetST;
746 bool Overflow =
false;
747 APInt OldOffset = Offset;
748 Offset = Offset.sadd_ov(GEPOffsetST, Overflow);
754 V =
GEP->getPointerOperand();
757 V = cast<Operator>(V)->getOperand(0);
758 }
else if (
auto *GA = dyn_cast<GlobalAlias>(V)) {
759 if (!GA->isInterposable())
760 V = GA->getAliasee();
761 }
else if (
const auto *Call = dyn_cast<CallBase>(V)) {
762 if (
const Value *RV =
Call->getReturnedArgOperand())
764 if (AllowInvariantGroup &&
Call->isLaunderOrStripInvariantGroup())
765 V =
Call->getArgOperand(0);
768 }
while (Visited.
insert(V).second);
775 return stripPointerCastsAndOffsets<PSK_InBounds>(
this, Func);
783 if (isa<Constant>(
this))
788 if (
auto *A = dyn_cast<Argument>(
this)) {
789 if (A->hasPointeeInMemoryValueAttr())
797 if (
F->doesNotFreeMemory() &&
F->hasNoSync())
802 if (
auto *
I = dyn_cast<Instruction>(
this))
803 F =
I->getFunction();
804 if (
auto *A = dyn_cast<Argument>(
this))
819 const auto &GCName =
F->getGC();
820 if (GCName ==
"statepoint-example") {
821 auto *PT = cast<PointerType>(this->
getType());
822 if (PT->getAddressSpace() != 1)
832 for (
auto &Fn : *
F->getParent())
833 if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
842 bool &CanBeFreed)
const {
848 if (
const Argument *A = dyn_cast<Argument>(
this)) {
849 DerefBytes = A->getDereferenceableBytes();
850 if (DerefBytes == 0) {
852 if (
Type *ArgMemTy = A->getPointeeInMemoryValueType()) {
853 if (ArgMemTy->isSized()) {
855 DerefBytes =
DL.getTypeStoreSize(ArgMemTy).getKnownMinSize();
860 if (DerefBytes == 0) {
861 DerefBytes = A->getDereferenceableOrNullBytes();
864 }
else if (
const auto *Call = dyn_cast<CallBase>(
this)) {
865 DerefBytes = Call->getRetDereferenceableBytes();
866 if (DerefBytes == 0) {
867 DerefBytes = Call->getRetDereferenceableOrNullBytes();
870 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(
this)) {
871 if (
MDNode *MD = LI->getMetadata(LLVMContext::MD_dereferenceable)) {
872 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
875 if (DerefBytes == 0) {
877 LI->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
878 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
883 }
else if (
auto *
IP = dyn_cast<IntToPtrInst>(
this)) {
884 if (
MDNode *MD =
IP->getMetadata(LLVMContext::MD_dereferenceable)) {
885 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
888 if (DerefBytes == 0) {
890 IP->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
891 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
896 }
else if (
auto *AI = dyn_cast<AllocaInst>(
this)) {
897 if (!AI->isArrayAllocation()) {
899 DL.getTypeStoreSize(AI->getAllocatedType()).getKnownMinSize();
903 }
else if (
auto *GV = dyn_cast<GlobalVariable>(
this)) {
904 if (GV->getValueType()->isSized() && !GV->hasExternalWeakLinkage()) {
907 DerefBytes =
DL.getTypeStoreSize(GV->getValueType()).getFixedSize();
917 if (
auto *GO = dyn_cast<GlobalObject>(
this)) {
918 if (isa<Function>(GO)) {
919 Align FunctionPtrAlign =
DL.getFunctionPtrAlign().valueOrOne();
920 switch (
DL.getFunctionPtrAlignType()) {
922 return FunctionPtrAlign;
924 return std::max(FunctionPtrAlign, GO->getAlign().valueOrOne());
930 if (
auto *GVar = dyn_cast<GlobalVariable>(GO)) {
936 if (GVar->isStrongDefinitionForLinker())
937 return DL.getPreferredAlign(GVar);
943 return Alignment.valueOrOne();
944 }
else if (
const Argument *A = dyn_cast<Argument>(
this)) {
945 const MaybeAlign Alignment = A->getParamAlign();
946 if (!Alignment && A->hasStructRetAttr()) {
948 Type *EltTy = A->getParamStructRetType();
950 return DL.getABITypeAlign(EltTy);
952 return Alignment.valueOrOne();
953 }
else if (
const AllocaInst *AI = dyn_cast<AllocaInst>(
this)) {
954 return AI->getAlign();
955 }
else if (
const auto *Call = dyn_cast<CallBase>(
this)) {
957 if (!Alignment && Call->getCalledFunction())
958 Alignment = Call->getCalledFunction()->getAttributes().getRetAlignment();
959 return Alignment.valueOrOne();
960 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(
this)) {
961 if (
MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
962 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
965 }
else if (
auto *CstPtr = dyn_cast<Constant>(
this)) {
968 CstPtr = CstPtr->stripPointerCasts();
972 size_t TrailingZeros = CstInt->getValue().countTrailingZeros();
985 auto *PN = dyn_cast<PHINode>(
this);
986 if (PN && PN->getParent() == CurBB)
987 return PN->getIncomingValueForBlock(PredBB);
994 if (!UseList || !UseList->Next)
999 Use *Current = UseList->Next;
1000 Head->Next =
nullptr;
1002 Use *Next = Current->Next;
1003 Current->Next = Head;
1004 Head->Prev = &Current->Next;
1009 Head->Prev = &UseList;
1013 auto *
Arg = dyn_cast<Argument>(
this);
1015 return Arg->hasSwiftErrorAttr();
1016 auto *Alloca = dyn_cast<AllocaInst>(
this);
1019 return Alloca->isSwiftError();
1025 while (!WorkList.empty()) {
1029 if (!isa<Constant>(U) || isa<GlobalValue>(U))
1032 if (Visited.
insert(UU).second)
1033 WorkList.push_back(UU);
1043 assert(List &&
"Handle list is null?");
1050 Next->setPrevPtr(&Next);
1055 void ValueHandleBase::AddToExistingUseListAfter(
ValueHandleBase *List) {
1056 assert(List &&
"Must insert after existing node");
1062 Next->setPrevPtr(&Next);
1065 void ValueHandleBase::AddToUseList() {
1074 assert(Entry &&
"Value doesn't have any handles?");
1075 AddToExistingUseList(&Entry);
1088 assert(!Entry &&
"Value really did already have handles?");
1089 AddToExistingUseList(&Entry);
1095 Handles.
size() == 1) {
1101 E = Handles.
end();
I !=
E; ++
I) {
1102 assert(
I->second &&
I->first ==
I->second->getValPtr() &&
1103 "List invariant broken!");
1104 I->second->setPrevPtr(&
I->second);
1110 "Pointer doesn't have a use list!");
1114 assert(*PrevPtr ==
this &&
"List invariant broken");
1118 assert(Next->getPrevPtr() == &Next &&
"List invariant broken");
1119 Next->setPrevPtr(PrevPtr);
1135 assert(V->HasValueHandle &&
"Should only be called if ValueHandles present");
1141 assert(Entry &&
"Value bit set but no entries exist");
1153 Iterator.RemoveFromUseList();
1154 Iterator.AddToExistingUseListAfter(Entry);
1155 assert(Entry->Next == &Iterator &&
"Loop invariant broken.");
1157 switch (Entry->getKind()) {
1164 Entry->operator=(
nullptr);
1174 if (V->HasValueHandle) {
1175 #ifndef NDEBUG // Only in +Asserts mode...
1188 assert(Old->HasValueHandle &&
"Should only be called if ValueHandles present");
1189 assert(Old != New &&
"Changing value into itself!");
1191 "replaceAllUses of value with new value of different type!");
1198 assert(Entry &&
"Value bit set but no entries exist");
1205 Iterator.RemoveFromUseList();
1206 Iterator.AddToExistingUseListAfter(Entry);
1207 assert(Entry->Next == &Iterator &&
"Loop invariant broken.");
1209 switch (Entry->getKind()) {
1216 Entry->operator=(New);
1220 static_cast<CallbackVH*
>(Entry)->allUsesReplacedWith(New);
1228 if (Old->HasValueHandle)
1229 for (Entry = pImpl->
ValueHandles[Old]; Entry; Entry = Entry->Next)
1230 switch (Entry->getKind()) {
1232 dbgs() <<
"After RAUW from " << *Old->
getType() <<
" %"
1233 << Old->
getName() <<
" to " << *New->getType() <<
" %"
1234 << New->getName() <<
"\n";
1236 "A weak tracking value handle still pointed to the old value!\n");
1244 void CallbackVH::anchor() {}
LLVMContextImpl *const pImpl
This class represents an incoming formal argument to a Function.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
user_iterator_impl< const User > const_user_iterator
const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
This is an optimization pass for GlobalISel generic memory operations.
bool isUsedInBasicBlock(const BasicBlock *BB) const
Check if this value is used in the specified basic block.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
static void dropDroppableUse(Use &U)
Remove the droppable use U.
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
A parsed version of the target data layout string in and methods for querying it.
static StringMapEntry * Create(StringRef key, AllocatorTy &allocator, InitTy &&... initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
bool hasOneUse() const
Return true if there is exactly one use of this value.
static constexpr uint64_t MaximumAlignment
bool isPointerTy() const
True if this is an instance of PointerType.
bool hasNItems(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)>>::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has exactly N items.
This is the common base class of value handles.
static Type * checkType(Type *Ty)
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
@ Independent
The function pointer alignment is independent of the function alignment.
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
A raw_ostream that writes to an std::string.
static constexpr size_t npos
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V)
Finds the debug info intrinsics describing a value.
bool erase(const KeyT &Val)
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
unsigned getOperandNo() const
Return the operand # of this use in its User.
Value * getValPtr() const
bool hasOneUser() const
Return true if there is exactly one user of this value.
bool isPointerIntoBucketsArray(const void *Ptr) const
isPointerIntoBucketsArray - Return true if the specified pointer points somewhere into the DenseMap's...
const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr) const
Accumulate the constant offset this value has compared to a base pointer.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
DenseMap< const Value *, ValueName * > ValueNames
user_iterator user_begin()
LLVM_NODISCARD T pop_back_val()
void dropDroppableUses(llvm::function_ref< bool(const Use *)> ShouldDrop=[](const Use *) { return true;})
Remove every uses that can safely be removed.
@ MultipleOfFunctionAlign
The function pointer alignment is a multiple of the function alignment.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static cl::opt< unsigned > UseDerefAtPointSemantics("use-dereferenceable-at-point-semantics", cl::Hidden, cl::init(false), cl::desc("Deref attributes and metadata infer facts at definition only"))
LLVM Basic Block Representation.
bool isSwiftError() const
Return true if this value is a swifterror value.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
void reverseUseList()
Reverse the use-list.
This is the shared class of boolean and integer constants.
ValueHandlesTy ValueHandles
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
(vector float) vec_cmpeq(*A, *B) C
Use * getSingleUndroppableUse()
Return true if there is exactly one use of this value that cannot be dropped.
void assertModuleIsMaterializedImpl() const
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
iterator_range< use_iterator > uses()
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
unsigned getValueID() const
Return an ID for the concrete type of this object.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
void setName(const Twine &Name)
Change the name of the value.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
User * getUser() const
Returns the User that contains this Use.
bool hasNItemsOrMore(IterTy &&Begin, IterTy &&End, unsigned N, Pred &&ShouldBeCounted=[](const decltype(*std::declval< IterTy >()) &) { return true;}, std::enable_if_t< !std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< std::remove_reference_t< decltype(Begin)>>::iterator_category >::value, void > *=nullptr)
Return true if the sequence [Begin, End) has N or more items.
Used to keep track of an operand bundle.
const void * getPointerIntoBucketsArray() const
getPointerIntoBucketsArray() - Return an opaque pointer into the buckets array.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
bool isTransitiveUsedByMetadataOnly() const
void dropDroppableUsesIn(User &Usr)
Remove every use of this value in User that can safely be removed.
static void ValueIsRAUWd(Value *Old, Value *New)
An efficient, type-erasing, non-owning reference to a callable.
const Value * stripPointerCastsSameRepresentation() const
Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the ...
Value(Type *Ty, unsigned scid)
bool hasNUndroppableUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
This is an important base class in LLVM.
std::string getNameOrAsOperand() const
uint64_t getPointerDereferenceableBytes(const DataLayout &DL, bool &CanBeNull, bool &CanBeFreed) const
Returns the number of bytes known to be dereferenceable for the pointer value.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
void RemoveFromUseList()
Remove this ValueHandle from its current use list.
Module * getParent()
Get the module that this global value is contained inside of...
User * getUniqueUndroppableUser()
Return true if there is exactly one unique user of this value that cannot be dropped (that user can h...
This is an important class for using LLVM in a threaded context.
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
bool materialized_use_empty() const
void setValue(const ValueTy &V)
initializer< Ty > init(const Ty &Val)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
ValueName * getValueName() const
void replaceNonMetadataUsesWith(Value *V)
Change non-metadata uses of this to point to a new Value.
Value handle that tracks a Value across RAUW.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void setValueName(ValueName *VN)
void replaceUsesOutsideBlock(Value *V, BasicBlock *BB)
replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V"...
const Value * stripPointerCastsForAliasAnalysis() const
Strip off pointer casts, all-zero GEPs, single-argument phi nodes and invariant group info.
bool isVoidTy() const
Return true if this is 'void'.
A Module instance is used to store all the information related to an LLVM module.
void clearMetadata()
Erase all metadata attached to this Value.
bool isDroppable() const
A droppable user is a user for which uses can be dropped without affecting correctness and should be ...
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
Class for arbitrary precision integers.
static void ValueIsDeleted(Value *V)
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned getNumUses() const
This method computes the number of uses of this Value.
Type * getType() const
All values are typed, get the type of this value.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
StringRef getName() const
Return a constant reference to the value's name.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
An instruction for reading from memory.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
const Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {}) const
Strip off pointer casts and inbounds GEPs.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
A constant value that is initialized with an expression using other constant values.
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
static ConstantInt * getTrue(LLVMContext &Context)
static bool isUnDroppableUser(const User *U)
bool hasNUndroppableUses(unsigned N) const
Return true if there this value.
~Value()
Value's destructor should be virtual by design, but that would require that Value and all of its subc...
static void replaceDbgUsesOutsideBlock(Value *V, Value *New, BasicBlock *BB)
Replace llvm.dbg.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
bool hasNUses(unsigned N) const
Return true if this Value has exactly N uses.
constexpr unsigned BitWidth
Value handle with callbacks on RAUW and destruction.
bool canBeFreed() const
Return true if the memory object referred to by V can by freed in the scope for which the SSA value d...
bool isStructTy() const
True if this is an instance of StructType.
This class provides a symbol table of name/value pairs.
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
const Value * DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) const
Translate PHI node to its predecessor from the given basic block.
static bool getSymTab(Value *V, ValueSymbolTable *&ST)
void deleteValue()
Delete a pointer to a generic Value.
Align max(MaybeAlign Lhs, Align Rhs)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
LLVM_NODISCARD size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
void replaceUsesWithIf(Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
Go through the uses list for this definition and make each use point to "V" if the callback ShouldRep...
void takeName(Value *V)
Transfer the name from V to this value.
an instruction to allocate memory on the stack
std::string & str()
Returns the string's reference.
LLVM Value Representation.
iterator_range< user_iterator > users()
InstListType::const_iterator const_iterator
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
A Use represents the edge between a Value definition and its users.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.