44 assert(Ty &&
"Value defined with a null type: Error!");
46 "Cannot have values with typed pointer types");
51 : SubclassID(scid), HasValueHandle(0), SubclassOptionalData(0),
52 SubclassData(0), NumUserOperands(0), IsUsedByMD(
false), HasName(
false),
54 static_assert(ConstantFirstVal == 0,
"!(SubclassID < ConstantFirstVal)");
59 if (SubclassID >= InstructionVal)
60 OpCode = SubclassID - InstructionVal;
61 if (OpCode == Instruction::Call || OpCode == Instruction::Invoke ||
62 OpCode == Instruction::CallBr)
63 assert((VTy->isFirstClassType() || VTy->isVoidTy() || VTy->isStructTy()) &&
64 "invalid CallBase type!");
65 else if (SubclassID != BasicBlockVal &&
66 ( SubclassID > ConstantLastVal))
67 assert((VTy->isFirstClassType() || VTy->isVoidTy()) &&
68 "Cannot create non-first-class values except for constants!");
69 static_assert(
sizeof(Value) == 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
76 ValueHandleBase::ValueIsDeleted(
this);
77 if (isUsedByMetadata())
78 ValueAsMetadata::handleDeletion(
this);
90 if (!materialized_use_empty()) {
91 dbgs() <<
"While deleting: " << *VTy <<
" %" <<
getName() <<
"\n";
92 for (
auto *U :
users())
93 dbgs() <<
"Use still stuck around after Def is destroyed:" << *
U <<
"\n";
104void Value::deleteValue() {
105 switch (getValueID()) {
106#define HANDLE_VALUE(Name) \
107 case Value::Name##Val: \
108 delete static_cast<Name *>(this); \
110#define HANDLE_MEMORY_VALUE(Name) \
111 case Value::Name##Val: \
112 static_cast<DerivedUser *>(this)->DeleteValue( \
113 static_cast<DerivedUser *>(this)); \
115#define HANDLE_CONSTANT(Name) \
116 case Value::Name##Val: \
117 llvm_unreachable("constants should be destroyed with destroyConstant"); \
119#define HANDLE_INSTRUCTION(Name)
120#include "llvm/IR/Value.def"
122#define HANDLE_INST(N, OPC, CLASS) \
123 case addEnumValues(Value::InstructionVal, Instruction::OPC): \
124 delete static_cast<CLASS *>(this); \
126#define HANDLE_USER_INST(N, OPC, CLASS)
127#include "llvm/IR/Instruction.def"
134void Value::destroyValueName() {
140 setValueName(
nullptr);
143bool Value::hasNUses(
unsigned N)
const {
151bool Value::hasNUsesOrMore(
unsigned N)
const {
159bool Value::hasOneUser()
const {
164 return std::equal(++user_begin(), user_end(), user_begin());
169Use *Value::getSingleUndroppableUse() {
171 for (Use &U : uses()) {
172 if (!
U.getUser()->isDroppable()) {
181User *Value::getUniqueUndroppableUser() {
183 for (
auto *U :
users()) {
184 if (!
U->isDroppable()) {
185 if (Result && Result != U)
193bool Value::hasNUndroppableUses(
unsigned int N)
const {
197bool Value::hasNUndroppableUsesOrMore(
unsigned int N)
const {
201void Value::dropDroppableUses(
202 llvm::function_ref<
bool(
const Use *)> ShouldDrop) {
203 SmallVector<Use *, 8> ToBeEdited;
204 for (Use &U : uses())
205 if (
U.getUser()->isDroppable() && ShouldDrop(&U))
207 for (Use *U : ToBeEdited)
208 dropDroppableUse(*U);
211void Value::dropDroppableUsesIn(User &Usr) {
214 if (UsrOp.get() ==
this)
215 dropDroppableUse(UsrOp);
219void Value::dropDroppableUse(Use &U) {
221 unsigned OpNo =
U.getOperandNo();
223 U.set(ConstantInt::getTrue(
Assume->getContext()));
225 U.set(PoisonValue::get(
U.get()->getType()));
226 CallInst::BundleOpInfo &BOI =
Assume->getBundleOpInfoForOperand(OpNo);
227 BOI.
Tag =
Assume->getContext().pImpl->getOrInsertBundleTag(
"ignore");
235bool Value::isUsedInBasicBlock(
const BasicBlock *BB)
const {
236 assert(hasUseList() &&
"ConstantData has no use-list");
244 BasicBlock::const_iterator BI = BB->
begin(), BE = BB->
end();
245 const_user_iterator UI = user_begin(), UE = user_end();
246 for (; BI != BE && UI != UE; ++BI, ++UI) {
252 if (User &&
User->getParent() == BB)
258unsigned Value::getNumUses()
const {
262 return (
unsigned)std::distance(use_begin(), use_end());
268 if (BasicBlock *
P =
I->getParent())
269 if (Function *PP =
P->getParent())
270 ST = PP->getValueSymbolTable();
273 ST =
P->getValueSymbolTable();
275 if (
Module *
P = GV->getParent())
276 ST = &
P->getValueSymbolTable();
278 if (Function *
P =
A->getParent())
279 ST =
P->getValueSymbolTable();
281 assert(isa<Constant>(V) &&
"Unknown value type!");
288 if (!HasName)
return nullptr;
293 "No name entry found!");
298void Value::setValueName(ValueName *VN) {
302 "HasName bit out of sync!");
315StringRef Value::getName()
const {
320 return StringRef(
"", 0);
321 return getValueName()->getKey();
324void Value::setNameImpl(
const Twine &NewName) {
326 !
getContext().shouldDiscardValueNames() || isa<GlobalValue>(
this);
330 if (!NeedNewName && !hasName())
337 SmallString<256> NameData;
338 StringRef NameRef = NeedNewName ? NewName.
toStringRef(NameData) :
"";
339 assert(!NameRef.
contains(0) &&
"Null bytes are not allowed in names");
345 assert(!
getType()->isVoidTy() &&
"Cannot assign a name to void values!");
348 ValueSymbolTable *
ST;
354 if (!NameRef.
empty()) {
365 setValueName(NewValueName);
366 getValueName()->setValue(
this);
371 if (!NameRef.
empty())
372 NewValueName =
ST->createValueName(NameRef,
this);
378 ST->removeValueName(getValueName());
386 assert(NeedNewName && NewValueName !=
nullptr);
387 setValueName(NewValueName);
390void Value::setName(
const Twine &NewName) {
391 setNameImpl(NewName);
393 F->updateAfterNameChange();
396void Value::takeName(
Value *V) {
397 assert(V !=
this &&
"Illegal call to this->takeName(this)!");
398 ValueSymbolTable *
ST =
nullptr;
405 if (
V->hasName())
V->setName(
"");
411 ST->removeValueName(getValueName());
418 if (!
V->hasName())
return;
430 ValueSymbolTable *VST;
432 assert(!Failure &&
"V has a name, so it should have a ST!"); (void)Failure;
438 setValueName(
V->getValueName());
439 V->setValueName(
nullptr);
440 getValueName()->setValue(
this);
448 VST->removeValueName(
V->getValueName());
449 setValueName(
V->getValueName());
450 V->setValueName(
nullptr);
451 getValueName()->setValue(
this);
454 ST->reinsertValue(
this);
457std::string Value::getNameOrAsOperand()
const {
462 raw_string_ostream OS(BBName);
463 printAsOperand(OS,
false);
467void Value::assertModuleIsMaterializedImpl()
const {
480static bool contains(SmallPtrSetImpl<ConstantExpr *> &Cache, ConstantExpr *Expr,
482 if (!Cache.
insert(Expr).second)
509 SmallPtrSet<ConstantExpr *, 4> Cache;
514void Value::doRAUW(
Value *New, ReplaceMetadataUses ReplaceMetaUses) {
515 assert(hasUseList() &&
"Cannot replace constant data");
516 assert(New &&
"Value::replaceAllUsesWith(<null>) is invalid!");
518 "this->replaceAllUsesWith(expr(this)) is NOT valid!");
520 "replaceAllUses of value with new value of different type!");
524 ValueHandleBase::ValueIsRAUWd(
this, New);
525 if (ReplaceMetaUses == ReplaceMetadataUses::Yes && isUsedByMetadata())
526 ValueAsMetadata::handleRAUW(
this, New);
528 while (!materialized_use_empty()) {
533 if (!isa<GlobalValue>(
C)) {
534 C->handleOperandChange(
this, New);
545 BlockAddress::lookup(BB)->handleOperandChange(
this, New);
549void Value::replaceAllUsesWith(
Value *New) {
550 doRAUW(New, ReplaceMetadataUses::Yes);
553void Value::replaceNonMetadataUsesWith(
Value *New) {
554 doRAUW(New, ReplaceMetadataUses::No);
557bool Value::replaceUsesWithIf(
Value *New,
558 llvm::function_ref<
bool(Use &U)> ShouldReplace) {
559 assert(New &&
"Value::replaceUsesWithIf(<null>) is invalid!");
561 "replaceUses of value with new value of different type!");
563 SmallVector<TrackingVH<Constant>, 8> Consts;
564 SmallPtrSet<Constant *, 8> Visited;
568 if (!ShouldReplace(U))
575 if (!isa<GlobalValue>(
C)) {
584 while (!Consts.
empty()) {
596 SmallVector<DbgVariableRecord *> DPUsers;
598 for (
auto *DVR : DPUsers) {
599 DbgMarker *Marker = DVR->getMarker();
601 DVR->replaceVariableLocationOp(V, New);
607void Value::replaceUsesOutsideBlock(
Value *New, BasicBlock *BB) {
608 assert(New &&
"Value::replaceUsesOutsideBlock(<null>, BB) is invalid!");
610 "this->replaceUsesOutsideBlock(expr(this), BB) is NOT valid!");
612 "replaceUses of value with new value of different type!");
613 assert(BB &&
"Basic block that may contain a use of 'New' must be defined\n");
616 replaceUsesWithIf(New, [BB](Use &U) {
619 return !
I ||
I->getParent() != BB;
625enum PointerStripKind {
627 PSK_ZeroIndicesAndAliases,
628 PSK_ZeroIndicesSameRepresentation,
629 PSK_ForAliasAnalysis,
630 PSK_InBoundsConstantIndices,
637template <Po
interStripKind StripKind>
641 if (!
V->getType()->isPointerTy())
646 SmallPtrSet<const Value *, 4> Visited;
653 case PSK_ZeroIndices:
654 case PSK_ZeroIndicesAndAliases:
655 case PSK_ZeroIndicesSameRepresentation:
656 case PSK_ForAliasAnalysis:
657 if (!
GEP->hasAllZeroIndices())
660 case PSK_InBoundsConstantIndices:
661 if (!
GEP->hasAllConstantIndices())
665 if (!
GEP->isInBounds())
669 V =
GEP->getPointerOperand();
670 }
else if (Operator::getOpcode(V) == Instruction::BitCast) {
671 Value *NewV = cast<Operator>(V)->getOperand(0);
672 if (!NewV->getType()->isPointerTy())
675 }
else if (StripKind != PSK_ZeroIndicesSameRepresentation &&
676 Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
679 V = cast<Operator>(V)->getOperand(0);
680 }
else if (StripKind == PSK_ZeroIndicesAndAliases && isa<GlobalAlias>(V)) {
681 V = cast<GlobalAlias>(V)->getAliasee();
682 }
else if (StripKind == PSK_ForAliasAnalysis && isa<PHINode>(V) &&
683 cast<PHINode>(V)->getNumIncomingValues() == 1) {
684 V = cast<PHINode>(V)->getIncomingValue(0);
687 if (
const Value *RV =
Call->getReturnedArgOperand()) {
694 if (StripKind == PSK_ForAliasAnalysis &&
695 Call->getIntrinsicID() == Intrinsic::launder_invariant_group) {
696 V =
Call->getArgOperand(0);
702 assert(
V->getType()->isPointerTy() &&
"Unexpected operand type!");
703 }
while (Visited.
insert(V).second);
708const Value *Value::stripPointerCasts()
const {
712const Value *Value::stripPointerCastsAndAliases()
const {
716const Value *Value::stripPointerCastsSameRepresentation()
const {
720const Value *Value::stripInBoundsConstantOffsets()
const {
724const Value *Value::stripPointerCastsForAliasAnalysis()
const {
728const Value *Value::stripAndAccumulateConstantOffsets(
729 const DataLayout &
DL, APInt &Offset,
bool AllowNonInbounds,
730 bool AllowInvariantGroup,
731 function_ref<
bool(
Value &, APInt &)> ExternalAnalysis,
732 bool LookThroughIntToPtr)
const {
733 if (!
getType()->isPtrOrPtrVectorTy())
738 "The offset bit width does not match the DL specification.");
742 SmallPtrSet<const Value *, 4> Visited;
748 if (!AllowNonInbounds && !
GEP->isInBounds())
757 APInt GEPOffset(
DL.getIndexTypeSizeInBits(
V->getType()), 0);
758 if (!
GEP->accumulateConstantOffset(
DL, GEPOffset, ExternalAnalysis))
764 if (GEPOffset.getSignificantBits() >
BitWidth)
769 APInt GEPOffsetST = GEPOffset.sextOrTrunc(
BitWidth);
770 if (!ExternalAnalysis) {
773 bool Overflow =
false;
777 Offset = std::move(OldOffset);
781 V =
GEP->getPointerOperand();
782 }
else if (Operator::getOpcode(V) == Instruction::BitCast) {
783 const Value *Src = cast<Operator>(V)->getOperand(0);
784 if (!Src->getType()->isPtrOrPtrVectorTy())
787 }
else if (Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
788 V = cast<Operator>(V)->getOperand(0);
790 if (!GA->isInterposable())
791 V = GA->getAliasee();
793 if (
const Value *RV =
Call->getReturnedArgOperand())
795 if (AllowInvariantGroup &&
796 Call->getIntrinsicID() == Intrinsic::launder_invariant_group)
797 V =
Call->getArgOperand(0);
800 if (!AllowNonInbounds || !LookThroughIntToPtr || !Int2Ptr ||
801 Int2Ptr->getOpcode() != Instruction::IntToPtr ||
802 Int2Ptr->getOperand(0)->getType()->getScalarSizeInBits() !=
BitWidth)
815 V = Ptr2Int->getOperand(0);
817 assert(
V->getType()->isPtrOrPtrVectorTy() &&
"Unexpected operand type!");
818 }
while (Visited.
insert(V).second);
824Value::stripInBoundsOffsets(function_ref<
void(
const Value *)> Func)
const {
828bool Value::canBeFreed()
const {
833 if (isa<Constant>(
this))
839 if (isa<AllocaInst>(
this))
845 if (
A->hasPointeeInMemoryValueAttr())
851 const Function *
F =
A->getParent();
852 if (
F->doesNotFreeMemory())
858 if ((
A->hasNoFreeAttr() ||
A->onlyReadsMemory()) &&
A->hasNoAliasAttr())
863 if (
A->hasAttribute(Attribute::NoFreeObj))
868 ITP && ITP->hasMetadata(LLVMContext::MD_nofreeobj))
872 if (CB->hasRetAttr(Attribute::NoFreeObj))
875 const Function *
F =
nullptr;
877 F =
I->getFunction();
893 const auto &GCName =
F->getGC();
894 if (GCName ==
"statepoint-example") {
895 auto *PT = cast<PointerType>(this->
getType());
896 if (PT->getAddressSpace() != 1)
906 for (
auto &Fn : *
F->getParent())
907 if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
914uint64_t Value::getPointerDereferenceableBytes(
const DataLayout &
DL,
916 bool *CanBeFreed)
const {
921 bool CanNotBeFreed =
false;
923 DerefBytes =
A->getDereferenceableBytes();
924 if (DerefBytes == 0) {
926 if (
Type *ArgMemTy =
A->getPointeeInMemoryValueType()) {
927 if (ArgMemTy->isSized()) {
929 DerefBytes =
DL.getTypeStoreSize(ArgMemTy).getKnownMinValue();
934 if (DerefBytes == 0) {
935 DerefBytes =
A->getDereferenceableOrNullBytes();
939 DerefBytes =
Call->getRetDereferenceableBytes();
940 if (DerefBytes == 0) {
941 DerefBytes =
Call->getRetDereferenceableOrNullBytes();
945 if (MDNode *MD = LI->getMetadata(LLVMContext::MD_dereferenceable)) {
946 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
949 if (DerefBytes == 0) {
951 LI->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
952 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
958 if (MDNode *MD = IP->getMetadata(LLVMContext::MD_dereferenceable)) {
959 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
962 if (DerefBytes == 0) {
964 IP->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
965 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
971 if (std::optional<TypeSize>
Size = AI->getAllocationSize(
DL)) {
972 DerefBytes =
Size->getKnownMinValue();
974 CanNotBeFreed =
true;
980 DerefBytes =
DL.getTypeStoreSize(GV->
getValueType()).getFixedValue();
982 CanNotBeFreed =
true;
989 if (!CanNotBeFreed && DerefBytes != 0)
1000Align Value::getPointerAlignment(
const DataLayout &
DL)
const {
1003 Align FunctionPtrAlign =
DL.getFunctionPtrAlign().valueOrOne();
1004 switch (
DL.getFunctionPtrAlignType()) {
1005 case DataLayout::FunctionPtrAlignType::Independent:
1006 return FunctionPtrAlign;
1007 case DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign:
1008 return std::max(FunctionPtrAlign,
F->getAlign().valueOrOne());
1012 const MaybeAlign
Alignment(GVar->getAlign());
1014 Type *ObjectType = GVar->getValueType();
1015 if (ObjectType->isSized()) {
1019 if (GVar->isStrongDefinitionForLinker())
1020 return DL.getPreferredAlign(GVar);
1022 return DL.getABITypeAlign(ObjectType);
1027 const MaybeAlign
Alignment =
A->getParamAlign();
1028 if (!Alignment &&
A->hasStructRetAttr()) {
1030 Type *EltTy =
A->getParamStructRetType();
1031 if (EltTy->isSized())
1032 return DL.getABITypeAlign(EltTy);
1036 return AI->getAlign();
1039 if (!Alignment &&
Call->getCalledFunction())
1040 Alignment =
Call->getCalledFunction()->getAttributes().getRetAlignment();
1043 if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
1044 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
1049 if (
CE->getOpcode() == Instruction::IntToPtr &&
1050 isa<ConstantInt>(
CE->getOperand(0))) {
1051 ConstantInt *IntPtr = cast<ConstantInt>(
CE->getOperand(0));
1055 return Align(TrailingZeros < Value::MaxAlignmentExponent
1057 : Value::MaximumAlignment);
1063static std::optional<int64_t>
1067 for (
unsigned i = 1; i !=
Idx; ++i, ++GTI)
1072 for (
unsigned i = Idx, e =
GEP->getNumOperands(); i != e; ++i, ++GTI) {
1075 return std::nullopt;
1088 if (
Size.isScalable())
1089 return std::nullopt;
1096std::optional<int64_t> Value::getPointerOffsetFrom(
const Value *Other,
1097 const DataLayout &
DL)
const {
1099 const Value *Ptr2 =
this;
1100 APInt Offset1(
DL.getIndexTypeSizeInBits(Ptr1->getType()), 0);
1101 APInt Offset2(
DL.getIndexTypeSizeInBits(Ptr2->getType()), 0);
1102 Ptr1 = Ptr1->stripAndAccumulateConstantOffsets(
DL, Offset1,
true);
1103 Ptr2 = Ptr2->stripAndAccumulateConstantOffsets(
DL, Offset2,
true);
1107 return Offset2.getSExtValue() - Offset1.getSExtValue();
1119 return std::nullopt;
1129 if (!IOffset1 || !IOffset2)
1130 return std::nullopt;
1131 return *IOffset2 - *IOffset1 + Offset2.getSExtValue() -
1132 Offset1.getSExtValue();
1135const Value *Value::DoPHITranslation(
const BasicBlock *CurBB,
1136 const BasicBlock *PredBB)
const {
1138 if (PN && PN->getParent() == CurBB)
1139 return PN->getIncomingValueForBlock(PredBB);
1143void Value::reverseUseList() {
1144 if (!UseList || !UseList->Next)
1148 Use *Head = UseList;
1149 Use *Current = UseList->Next;
1150 Head->Next =
nullptr;
1153 Current->Next = Head;
1154 Head->Prev = &Current->Next;
1159 Head->Prev = &UseList;
1162bool Value::isSwiftError()
const {
1165 return Arg->hasSwiftErrorAttr();
1169 return Alloca->isSwiftError();
1176ValueHandleHead::ValueHandleHead(ValueHandleHead &&Other) noexcept
1177 : Head(
Other.Head) {
1178 if (ValueHandleBase *Ptr =
get())
1179 Ptr->setPrevPtr(&Head);
1182void ValueHandleBase::AddToExistingUseList(ValueHandleBase **List) {
1183 assert(List &&
"Handle list is null?");
1186 Next = ValueHandleHead::exchange(List,
this).getPointer();
1189 Next->setPrevPtr(&Next);
1190 assert(getValPtr() ==
Next->getValPtr() &&
"Added to wrong list?");
1194void ValueHandleBase::AddToExistingUseListAfter(ValueHandleBase *List) {
1195 assert(List &&
"Must insert after existing node");
1198 setPrevPtr(&
List->Next);
1201 Next->setPrevPtr(&Next);
1204void ValueHandleBase::AddToUseList() {
1205 assert(getValPtr() &&
"Null pointer doesn't have a use list!");
1207 LLVMContextImpl *pImpl = getValPtr()->getContext().pImpl;
1209 assert(getValPtr()->hasValueHandle() == (
Entry.get() !=
nullptr) &&
1210 "HasValueHandle and ValueHandles out of sync!");
1211 AddToExistingUseList(
Entry.getAddress());
1212 getValPtr()->HasValueHandle =
true;
1215void ValueHandleBase::RemoveFromUseList() {
1216 assert(getValPtr() && getValPtr()->HasValueHandle &&
1217 "Pointer doesn't have a use list!");
1220 ValueHandleBase **PrevPtr = getPrevPtr();
1221 auto [OldPtr, IsHead] = ValueHandleHead::exchange(PrevPtr, Next);
1222 assert(OldPtr ==
this &&
"List invariant broken");
1224 assert(
Next->getPrevPtr() == &Next &&
"List invariant broken");
1225 Next->setPrevPtr(PrevPtr);
1233 LLVMContextImpl *pImpl = getValPtr()->getContext().pImpl;
1235 getValPtr()->HasValueHandle =
false;
1239void ValueHandleBase::ValueIsDeleted(
Value *V) {
1240 assert(
V->HasValueHandle &&
"Should only be called if ValueHandles present");
1244 LLVMContextImpl *pImpl =
V->getContext().pImpl;
1246 assert(Entry &&
"Value bit set but no entries exist");
1259 Iterator.AddToExistingUseListAfter(Entry);
1260 assert(
Entry->Next == &Iterator &&
"Loop invariant broken.");
1262 switch (
Entry->getKind()) {
1269 Entry->operator=(
nullptr);
1273 static_cast<CallbackVH*
>(
Entry)->deleted();
1279 if (
V->HasValueHandle) {
1281 dbgs() <<
"While deleting: " << *
V->getType() <<
" %" <<
V->getName()
1292void ValueHandleBase::ValueIsRAUWd(
Value *Old,
Value *New) {
1293 assert(Old->HasValueHandle &&
"Should only be called if ValueHandles present");
1294 assert(Old != New &&
"Changing value into itself!");
1295 assert(Old->getType() ==
New->getType() &&
1296 "replaceAllUses of value with new value of different type!");
1300 LLVMContextImpl *pImpl = Old->getContext().pImpl;
1303 assert(Entry &&
"Value bit set but no entries exist");
1311 Iterator.AddToExistingUseListAfter(Entry);
1312 assert(
Entry->Next == &Iterator &&
"Loop invariant broken.");
1314 switch (
Entry->getKind()) {
1325 static_cast<CallbackVH*
>(
Entry)->allUsesReplacedWith(New);
1333 if (Old->HasValueHandle)
1335 switch (
Entry->getKind()) {
1337 dbgs() <<
"After RAUW from " << *Old->getType() <<
" %"
1338 << Old->getName() <<
" to " << *
New->getType() <<
" %"
1339 <<
New->getName() <<
"\n";
1341 "A weak tracking value handle still pointed to the old value!\n");
1349void CallbackVH::anchor() {}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
This file defines the DenseMap class.
Module.h This file contains the declarations for the Module class.
Machine Check Debug Module
static StringRef getName(Value *V)
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static std::optional< int64_t > getOffsetFromIndex(const GEPOperator *GEP, unsigned Idx, const DataLayout &DL)
static void NoopCallback(const Value *)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static Type * checkType(Type *Ty)
static bool getSymTab(Value *V, ValueSymbolTable *&ST)
static const Value * stripPointerCastsAndOffsets(const Value *V, function_ref< void(const Value *)> Func=NoopCallback< StripKind >)
static void replaceDbgUsesOutsideBlock(Value *V, Value *New, BasicBlock *BB)
Replace debug record uses of MetadataAsValue(ValueAsMetadata(V)) outside BB with New.
static bool isUnDroppableUser(const User *U)
This file defines the SmallString class.
static SymbolRef::Type getType(const Symbol *Sym)
unsigned countr_zero() const
Count the number of trailing zero bits.
LLVM_ABI void replaceSuccessorsPhiUsesWith(BasicBlock *Old, BasicBlock *New)
Update all phi nodes in this basic block's successors to refer to basic block New instead of basic bl...
iterator begin()
Instruction iterator methods.
const Function * getParent() const
Return the enclosing method, or null if none.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches,...
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const APInt & getValue() const
Return the constant as an APInt value reference.
LLVM_ABI const BasicBlock * getParent() const
bool erase(const KeyT &Val)
LLVM_ABI Type * getSourceElementType() const
bool hasExternalWeakLinkage() const
Module * getParent()
Get the module that this global value is contained inside of...
Type * getValueType() const
DenseMap< const Value *, ValueName * > ValueNames
ValueHandlesTy ValueHandles
LLVMContextImpl *const pImpl
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void push_back(const T &Elt)
static StringMapEntry * create(StringRef key, AllocatorTy &allocator, InitTy &&...initVals)
constexpr bool empty() const
Check if the string is empty.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
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.
bool isSized() const
Return true if it makes sense to take the size of this type.
LLVM_ABI bool isDroppable() const
A droppable user is a user for which uses can be dropped without affecting correctness and should be ...
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM_ABI Value(Type *Ty, unsigned scid)
LLVM_ABI ~Value()
Value's destructor should be virtual by design, but that would require that Value and all of its subc...
StructType * getStructTypeOrNull() const
TypeSize getSequentialElementStride(const DataLayout &DL) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ CE
Windows NT (Windows on ARM)
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
StringMapEntry< Value * > ValueName
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.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isPointerTy(const Type *T)
generic_gep_type_iterator<> gep_type_iterator
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
const IROptions & getIROptions(const LLVMContext &C)
gep_type_iterator gep_type_begin(const User *GEP)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
LLVM_ABI void findDbgUsers(Value *V, SmallVectorImpl< DbgVariableRecord * > &DbgVariableRecords)
Finds the debug info records describing a value.
StringMapEntry< uint32_t > * Tag
The operand bundle tag, interned by LLVMContextImpl::getOrInsertBundleTag.