40 cl::desc(
"Deref attributes and metadata infer facts at definition only"));
46 assert(Ty &&
"Value defined with a null type: Error!");
48 "Cannot have values with typed pointer types");
53 : VTy(
checkType(ty)), UseList(nullptr), SubclassID(scid), HasValueHandle(0),
54 SubclassOptionalData(0), SubclassData(0), NumUserOperands(0),
56 static_assert(ConstantFirstVal == 0,
"!(SubclassID < ConstantFirstVal)");
61 if (SubclassID >= InstructionVal)
62 OpCode = SubclassID - InstructionVal;
63 if (OpCode == Instruction::Call || OpCode == Instruction::Invoke ||
64 OpCode == Instruction::CallBr)
66 "invalid CallBase type!");
67 else if (SubclassID != BasicBlockVal &&
68 ( SubclassID > ConstantLastVal))
70 "Cannot create non-first-class values except for constants!");
71 static_assert(
sizeof(
Value) == 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
97 dbgs() <<
"While deleting: " << *VTy <<
" %" <<
getName() <<
"\n";
98 for (
auto *U :
users())
99 dbgs() <<
"Use still stuck around after Def is destroyed:" << *U <<
"\n";
111#define HANDLE_VALUE(Name) \
112 case Value::Name##Val: \
113 delete static_cast<Name *>(this); \
115#define HANDLE_MEMORY_VALUE(Name) \
116 case Value::Name##Val: \
117 static_cast<DerivedUser *>(this)->DeleteValue( \
118 static_cast<DerivedUser *>(this)); \
120#define HANDLE_CONSTANT(Name) \
121 case Value::Name##Val: \
122 llvm_unreachable("constants should be destroyed with destroyConstant"); \
124#define HANDLE_INSTRUCTION(Name)
125#include "llvm/IR/Value.def"
127#define HANDLE_INST(N, OPC, CLASS) \
128 case Value::InstructionVal + Instruction::OPC: \
129 delete static_cast<CLASS *>(this); \
131#define HANDLE_USER_INST(N, OPC, CLASS)
132#include "llvm/IR/Instruction.def"
139void Value::destroyValueName() {
143 Name->Destroy(Allocator);
167 Use *Result =
nullptr;
169 if (!U.getUser()->isDroppable()) {
179 User *Result =
nullptr;
180 for (
auto *U :
users()) {
181 if (!U->isDroppable()) {
182 if (Result && Result != U)
202 if (U.getUser()->isDroppable() && ShouldDrop(&U))
204 for (
Use *U : ToBeEdited)
211 if (UsrOp.get() ==
this)
218 if (
auto *Assume = dyn_cast<AssumeInst>(U.
getUser())) {
225 BOI.
Tag = Assume->getContext().pImpl->getOrInsertBundleTag(
"ignore");
242 for (; BI != BE && UI != UE; ++BI, ++UI) {
247 const auto *
User = dyn_cast<Instruction>(*UI);
248 if (
User &&
User->getParent() == BB)
263 ST = PP->getValueSymbolTable();
264 }
else if (
BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
266 ST =
P->getValueSymbolTable();
267 }
else if (
GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
268 if (
Module *
P = GV->getParent())
269 ST = &
P->getValueSymbolTable();
270 }
else if (
Argument *
A = dyn_cast<Argument>(V)) {
272 ST =
P->getValueSymbolTable();
274 assert(isa<Constant>(V) &&
"Unknown value type!");
286 "No name entry found!");
295 "HasName bit out of sync!");
317void Value::setNameImpl(
const Twine &NewName) {
319 if (
getContext().shouldDiscardValueNames() && !isa<GlobalValue>(
this))
329 "Null bytes are not allowed in names");
335 assert(!
getType()->isVoidTy() &&
"Cannot assign a name to void values!");
343 if (NameRef.
empty()) {
376 setNameImpl(NewName);
377 if (
Function *
F = dyn_cast<Function>(
this))
378 F->recalculateIntrinsicID();
382 assert(V !=
this &&
"Illegal call to this->takeName(this)!");
417 assert(!Failure &&
"V has a name, so it should have a ST!"); (void)Failure;
439 ST->reinsertValue(
this);
456 const GlobalValue *GV = dyn_cast<GlobalValue>(
this);
462 assert(M->isMaterialized());
469 if (!Cache.
insert(Expr).second)
475 auto *CE = dyn_cast<ConstantExpr>(O);
488 auto *
C = dyn_cast<Constant>(V);
492 auto *CE = dyn_cast<ConstantExpr>(Expr);
501void Value::doRAUW(
Value *New, ReplaceMetadataUses ReplaceMetaUses) {
502 assert(New &&
"Value::replaceAllUsesWith(<null>) is invalid!");
504 "this->replaceAllUsesWith(expr(this)) is NOT valid!");
506 "replaceAllUses of value with new value of different type!");
518 if (
auto *
C = dyn_cast<Constant>(U.
getUser())) {
519 if (!isa<GlobalValue>(
C)) {
520 C->handleOperandChange(
this, New);
528 if (
BasicBlock *BB = dyn_cast<BasicBlock>(
this))
529 BB->replaceSuccessorsPhiUsesWith(cast<BasicBlock>(New));
533 doRAUW(New, ReplaceMetadataUses::Yes);
537 doRAUW(New, ReplaceMetadataUses::No);
542 assert(New &&
"Value::replaceUsesWithIf(<null>) is invalid!");
544 "replaceUses of value with new value of different type!");
550 if (!ShouldReplace(U))
554 if (
auto *
C = dyn_cast<Constant>(U.
getUser())) {
555 if (!isa<GlobalValue>(
C)) {
564 while (!Consts.
empty()) {
576 for (
auto *DVI : DbgUsers) {
577 if (DVI->getParent() != BB)
578 DVI->replaceVariableLocationOp(V, New);
585 assert(New &&
"Value::replaceUsesOutsideBlock(<null>, BB) is invalid!");
587 "this->replaceUsesOutsideBlock(expr(this), BB) is NOT valid!");
589 "replaceUses of value with new value of different type!");
590 assert(BB &&
"Basic block that may contain a use of 'New' must be defined\n");
594 auto *
I = dyn_cast<Instruction>(U.
getUser());
596 return !
I ||
I->getParent() != BB;
602enum PointerStripKind {
604 PSK_ZeroIndicesAndAliases,
605 PSK_ZeroIndicesSameRepresentation,
606 PSK_ForAliasAnalysis,
607 PSK_InBoundsConstantIndices,
611template <Po
interStripKind StripKind>
static void NoopCallback(
const Value *) {}
613template <Po
interStripKind StripKind>
614static const Value *stripPointerCastsAndOffsets(
627 if (
auto *
GEP = dyn_cast<GEPOperator>(V)) {
629 case PSK_ZeroIndices:
630 case PSK_ZeroIndicesAndAliases:
631 case PSK_ZeroIndicesSameRepresentation:
632 case PSK_ForAliasAnalysis:
633 if (!
GEP->hasAllZeroIndices())
636 case PSK_InBoundsConstantIndices:
637 if (!
GEP->hasAllConstantIndices())
641 if (!
GEP->isInBounds())
645 V =
GEP->getPointerOperand();
647 V = cast<Operator>(V)->getOperand(0);
650 }
else if (StripKind != PSK_ZeroIndicesSameRepresentation &&
654 V = cast<Operator>(V)->getOperand(0);
655 }
else if (StripKind == PSK_ZeroIndicesAndAliases && isa<GlobalAlias>(V)) {
656 V = cast<GlobalAlias>(V)->getAliasee();
657 }
else if (StripKind == PSK_ForAliasAnalysis && isa<PHINode>(V) &&
658 cast<PHINode>(V)->getNumIncomingValues() == 1) {
659 V = cast<PHINode>(V)->getIncomingValue(0);
661 if (
const auto *Call = dyn_cast<CallBase>(V)) {
662 if (
const Value *RV =
Call->getReturnedArgOperand()) {
669 if (StripKind == PSK_ForAliasAnalysis &&
670 (
Call->getIntrinsicID() == Intrinsic::launder_invariant_group ||
671 Call->getIntrinsicID() == Intrinsic::strip_invariant_group)) {
672 V =
Call->getArgOperand(0);
679 }
while (Visited.
insert(V).second);
686 return stripPointerCastsAndOffsets<PSK_ZeroIndices>(
this);
690 return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndAliases>(
this);
694 return stripPointerCastsAndOffsets<PSK_ZeroIndicesSameRepresentation>(
this);
698 return stripPointerCastsAndOffsets<PSK_InBoundsConstantIndices>(
this);
702 return stripPointerCastsAndOffsets<PSK_ForAliasAnalysis>(
this);
707 bool AllowInvariantGroup,
709 if (!
getType()->isPtrOrPtrVectorTy())
714 "The offset bit width does not match the DL specification.");
720 const Value *V =
this;
722 if (
auto *
GEP = dyn_cast<GEPOperator>(V)) {
724 if (!AllowNonInbounds && !
GEP->isInBounds())
734 if (!
GEP->accumulateConstantOffset(
DL, GEPOffset, ExternalAnalysis))
740 if (GEPOffset.getMinSignedBits() >
BitWidth)
746 if (!ExternalAnalysis) {
749 bool Overflow =
false;
757 V =
GEP->getPointerOperand();
760 V = cast<Operator>(V)->getOperand(0);
761 }
else if (
auto *GA = dyn_cast<GlobalAlias>(V)) {
762 if (!GA->isInterposable())
763 V = GA->getAliasee();
764 }
else if (
const auto *Call = dyn_cast<CallBase>(V)) {
765 if (
const Value *RV =
Call->getReturnedArgOperand())
767 if (AllowInvariantGroup &&
Call->isLaunderOrStripInvariantGroup())
768 V =
Call->getArgOperand(0);
771 }
while (Visited.
insert(V).second);
778 return stripPointerCastsAndOffsets<PSK_InBounds>(
this, Func);
786 if (isa<Constant>(
this))
791 if (
auto *
A = dyn_cast<Argument>(
this)) {
792 if (
A->hasPointeeInMemoryValueAttr())
800 if (
F->doesNotFreeMemory() &&
F->hasNoSync())
805 if (
auto *
I = dyn_cast<Instruction>(
this))
806 F =
I->getFunction();
807 if (
auto *
A = dyn_cast<Argument>(
this))
822 const auto &GCName =
F->getGC();
823 if (GCName ==
"statepoint-example") {
824 auto *PT = cast<PointerType>(this->
getType());
825 if (PT->getAddressSpace() != 1)
835 for (
auto &Fn : *
F->getParent())
836 if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
845 bool &CanBeFreed)
const {
851 if (
const Argument *
A = dyn_cast<Argument>(
this)) {
852 DerefBytes =
A->getDereferenceableBytes();
853 if (DerefBytes == 0) {
855 if (
Type *ArgMemTy =
A->getPointeeInMemoryValueType()) {
856 if (ArgMemTy->isSized()) {
858 DerefBytes =
DL.getTypeStoreSize(ArgMemTy).getKnownMinValue();
863 if (DerefBytes == 0) {
864 DerefBytes =
A->getDereferenceableOrNullBytes();
867 }
else if (
const auto *Call = dyn_cast<CallBase>(
this)) {
868 DerefBytes = Call->getRetDereferenceableBytes();
869 if (DerefBytes == 0) {
870 DerefBytes = Call->getRetDereferenceableOrNullBytes();
873 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(
this)) {
874 if (
MDNode *MD = LI->getMetadata(LLVMContext::MD_dereferenceable)) {
875 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
878 if (DerefBytes == 0) {
880 LI->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
881 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
886 }
else if (
auto *IP = dyn_cast<IntToPtrInst>(
this)) {
887 if (
MDNode *MD = IP->getMetadata(LLVMContext::MD_dereferenceable)) {
888 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
891 if (DerefBytes == 0) {
893 IP->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
894 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
899 }
else if (
auto *AI = dyn_cast<AllocaInst>(
this)) {
900 if (!AI->isArrayAllocation()) {
902 DL.getTypeStoreSize(AI->getAllocatedType()).getKnownMinValue();
906 }
else if (
auto *GV = dyn_cast<GlobalVariable>(
this)) {
907 if (GV->getValueType()->isSized() && !GV->hasExternalWeakLinkage()) {
910 DerefBytes =
DL.getTypeStoreSize(GV->getValueType()).getFixedValue();
920 if (
auto *GO = dyn_cast<GlobalObject>(
this)) {
921 if (isa<Function>(GO)) {
922 Align FunctionPtrAlign =
DL.getFunctionPtrAlign().valueOrOne();
923 switch (
DL.getFunctionPtrAlignType()) {
925 return FunctionPtrAlign;
927 return std::max(FunctionPtrAlign, GO->getAlign().valueOrOne());
933 if (
auto *GVar = dyn_cast<GlobalVariable>(GO)) {
934 Type *ObjectType = GVar->getValueType();
939 if (GVar->isStrongDefinitionForLinker())
940 return DL.getPreferredAlign(GVar);
942 return DL.getABITypeAlign(ObjectType);
947 }
else if (
const Argument *
A = dyn_cast<Argument>(
this)) {
949 if (!Alignment &&
A->hasStructRetAttr()) {
951 Type *EltTy =
A->getParamStructRetType();
953 return DL.getABITypeAlign(EltTy);
956 }
else if (
const AllocaInst *AI = dyn_cast<AllocaInst>(
this)) {
957 return AI->getAlign();
958 }
else if (
const auto *Call = dyn_cast<CallBase>(
this)) {
960 if (!Alignment && Call->getCalledFunction())
961 Alignment = Call->getCalledFunction()->getAttributes().getRetAlignment();
963 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(
this)) {
964 if (
MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
965 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
968 }
else if (
auto *CstPtr = dyn_cast<Constant>(
this)) {
971 CstPtr = CstPtr->stripPointerCasts();
975 size_t TrailingZeros = CstInt->getValue().countTrailingZeros();
988 auto *PN = dyn_cast<PHINode>(
this);
989 if (PN && PN->getParent() == CurBB)
990 return PN->getIncomingValueForBlock(PredBB);
997 if (!UseList || !UseList->Next)
1001 Use *Head = UseList;
1002 Use *Current = UseList->Next;
1003 Head->Next =
nullptr;
1005 Use *Next = Current->Next;
1006 Current->Next = Head;
1007 Head->Prev = &Current->Next;
1012 Head->Prev = &UseList;
1016 auto *
Arg = dyn_cast<Argument>(
this);
1018 return Arg->hasSwiftErrorAttr();
1019 auto *Alloca = dyn_cast<AllocaInst>(
this);
1022 return Alloca->isSwiftError();
1037 Next->setPrevPtr(&Next);
1043 assert(
List &&
"Must insert after existing node");
1046 setPrevPtr(&
List->Next);
1049 Next->setPrevPtr(&Next);
1052void ValueHandleBase::AddToUseList() {
1061 assert(Entry &&
"Value doesn't have any handles?");
1062 AddToExistingUseList(&Entry);
1075 assert(!Entry &&
"Value really did already have handles?");
1076 AddToExistingUseList(&Entry);
1082 Handles.
size() == 1) {
1088 E = Handles.
end();
I !=
E; ++
I) {
1089 assert(
I->second &&
I->first ==
I->second->getValPtr() &&
1090 "List invariant broken!");
1091 I->second->setPrevPtr(&
I->second);
1097 "Pointer doesn't have a use list!");
1101 assert(*PrevPtr ==
this &&
"List invariant broken");
1105 assert(Next->getPrevPtr() == &Next &&
"List invariant broken");
1106 Next->setPrevPtr(PrevPtr);
1122 assert(V->HasValueHandle &&
"Should only be called if ValueHandles present");
1128 assert(Entry &&
"Value bit set but no entries exist");
1140 Iterator.RemoveFromUseList();
1141 Iterator.AddToExistingUseListAfter(Entry);
1142 assert(Entry->Next == &Iterator &&
"Loop invariant broken.");
1144 switch (Entry->getKind()) {
1151 Entry->operator=(
nullptr);
1161 if (V->HasValueHandle) {
1175 assert(Old->HasValueHandle &&
"Should only be called if ValueHandles present");
1176 assert(Old != New &&
"Changing value into itself!");
1178 "replaceAllUses of value with new value of different type!");
1185 assert(Entry &&
"Value bit set but no entries exist");
1192 Iterator.RemoveFromUseList();
1193 Iterator.AddToExistingUseListAfter(Entry);
1194 assert(Entry->Next == &Iterator &&
"Loop invariant broken.");
1196 switch (Entry->getKind()) {
1203 Entry->operator=(New);
1207 static_cast<CallbackVH*
>(Entry)->allUsesReplacedWith(New);
1215 if (Old->HasValueHandle)
1216 for (Entry = pImpl->
ValueHandles[Old]; Entry; Entry = Entry->Next)
1217 switch (Entry->getKind()) {
1219 dbgs() <<
"After RAUW from " << *Old->
getType() <<
" %"
1220 << Old->
getName() <<
" to " << *New->getType() <<
" %"
1221 << New->getName() <<
"\n";
1223 "A weak tracking value handle still pointed to the old value!\n");
1231void CallbackVH::anchor() {}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static Type * checkType(Type *Ty)
static bool getSymTab(Value *V, ValueSymbolTable *&ST)
static void replaceDbgUsesOutsideBlock(Value *V, Value *New, BasicBlock *BB)
Replace llvm.dbg.
static bool isUnDroppableUser(const User *U)
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"))
Class for arbitrary precision integers.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
an instruction to allocate memory on the stack
This class represents an incoming formal argument to a Function.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
InstListType::const_iterator const_iterator
Value handle with callbacks on RAUW and destruction.
A constant value that is initialized with an expression using other constant values.
static Constant * getPtrToInt(Constant *C, Type *Ty, bool OnlyIfReduced=false)
This is the shared class of boolean and integer constants.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
static ConstantInt * getTrue(LLVMContext &Context)
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
@ MultipleOfFunctionAlign
The function pointer alignment is a multiple of the function alignment.
@ Independent
The function pointer alignment is independent of the function alignment.
bool erase(const KeyT &Val)
bool isPointerIntoBucketsArray(const void *Ptr) const
isPointerIntoBucketsArray - Return true if the specified pointer points somewhere into the DenseMap's...
const void * getPointerIntoBucketsArray() const
getPointerIntoBucketsArray() - Return an opaque pointer into the buckets array.
Module * getParent()
Get the module that this global value is contained inside of...
DenseMap< const Value *, ValueName * > ValueNames
ValueHandlesTy ValueHandles
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
An instruction for reading from memory.
A Module instance is used to store all the information related to an LLVM module.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void setValue(const ValueTy &V)
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
Create a StringMapEntry for the specified key construct the value using InitiVals.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
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.
static constexpr size_t npos
Value handle that tracks a Value across RAUW.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
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 isStructTy() const
True if this is an instance of StructType.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isVoidTy() const
Return true if this is 'void'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
User * getUser() const
Returns the User that contains this Use.
unsigned getOperandNo() const
Return the operand # of this use in its User.
bool isDroppable() const
A droppable user is a user for which uses can be dropped without affecting correctness and should be ...
This is the common base class of value handles.
void RemoveFromUseList()
Remove this ValueHandle from its current use list.
Value * getValPtr() const
static void ValueIsDeleted(Value *V)
static void ValueIsRAUWd(Value *Old, Value *New)
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
static constexpr uint64_t MaximumAlignment
user_iterator_impl< const User > const_user_iterator
user_iterator user_begin()
const Value * DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) const
Translate PHI node to its predecessor from the given basic block.
Value(Type *Ty, unsigned scid)
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.
void reverseUseList()
Reverse the use-list.
void assertModuleIsMaterializedImpl() const
bool hasNUndroppableUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
bool hasOneUser() const
Return true if there is exactly one user of this value.
const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
void setName(const Twine &Name)
Change the name of the value.
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
std::string getNameOrAsOperand() const
bool hasOneUse() const
Return true if there is exactly one use of this value.
~Value()
Value's destructor should be virtual by design, but that would require that Value and all of its subc...
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
const Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {}) const
Strip off pointer casts and inbounds GEPs.
iterator_range< user_iterator > users()
static void dropDroppableUse(Use &U)
Remove the droppable use U.
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
unsigned getValueID() const
Return an ID for the concrete type of this object.
bool isUsedInBasicBlock(const BasicBlock *BB) const
Check if this value is used in the specified basic block.
bool materialized_use_empty() const
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.
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
bool hasNUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
void dropDroppableUsesIn(User &Usr)
Remove every use of this value in User that can safely be removed.
Use * getSingleUndroppableUse()
Return true if there is exactly one use of this value that cannot be dropped.
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 hasNUses(unsigned N) const
Return true if this Value has exactly N uses.
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 setValueName(ValueName *VN)
User * getUniqueUndroppableUser()
Return true if there is exactly one unique user of this value that cannot be dropped (that user can h...
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
bool isSwiftError() const
Return true if this value is a swifterror value.
void deleteValue()
Delete a pointer to a generic Value.
ValueName * getValueName() const
const Value * stripPointerCastsSameRepresentation() const
Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the ...
void dropDroppableUses(llvm::function_ref< bool(const Use *)> ShouldDrop=[](const Use *) { return true;})
Remove every uses that can safely be removed.
void replaceUsesOutsideBlock(Value *V, BasicBlock *BB)
replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V"...
LLVMContext & getContext() const
All values hold a context through their type.
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
unsigned getNumUses() const
This method computes the number of uses of this Value.
iterator_range< use_iterator > uses()
uint64_t getPointerDereferenceableBytes(const DataLayout &DL, bool &CanBeNull, bool &CanBeFreed) const
Returns the number of bytes known to be dereferenceable for the pointer value.
void clearMetadata()
Erase all metadata attached to this Value.
StringRef getName() const
Return a constant reference to the value's name.
void replaceNonMetadataUsesWith(Value *V)
Change non-metadata uses of this to point to a new Value.
void takeName(Value *V)
Transfer the name from V to this value.
bool hasNUndroppableUses(unsigned N) const
Return true if there this value.
const Value * stripPointerCastsForAliasAnalysis() const
Strip off pointer casts, all-zero GEPs, single-argument phi nodes and invariant group info.
An efficient, type-erasing, non-owning reference to a callable.
A raw_ostream that writes to an std::string.
std::string & str()
Returns the string's reference.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
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 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.
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V)
Finds the debug info intrinsics describing a value.
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.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
constexpr unsigned BitWidth
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Used to keep track of an operand bundle.
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.