40 "use-dereferenceable-at-point-semantics", cl::Hidden, cl::init(
false),
41 cl::desc(
"Deref attributes and metadata infer facts at definition only"));
47 assert(Ty &&
"Value defined with a null type: Error!");
49 "Cannot have values with typed pointer types");
53Value::Value(
Type *ty,
unsigned scid)
54 : SubclassID(scid), HasValueHandle(0), SubclassOptionalData(0),
55 SubclassData(0), NumUserOperands(0), IsUsedByMD(
false), HasName(
false),
57 static_assert(ConstantFirstVal == 0,
"!(SubclassID < ConstantFirstVal)");
62 if (SubclassID >= InstructionVal)
63 OpCode = SubclassID - InstructionVal;
64 if (OpCode == Instruction::Call || OpCode == Instruction::Invoke ||
65 OpCode == Instruction::CallBr)
66 assert((VTy->isFirstClassType() || VTy->isVoidTy() || VTy->isStructTy()) &&
67 "invalid CallBase type!");
68 else if (SubclassID != BasicBlockVal &&
69 ( SubclassID > ConstantLastVal))
70 assert((VTy->isFirstClassType() || VTy->isVoidTy()) &&
71 "Cannot create non-first-class values except for constants!");
72 static_assert(
sizeof(
Value) == 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
79 ValueHandleBase::ValueIsDeleted(
this);
80 if (isUsedByMetadata())
81 ValueAsMetadata::handleDeletion(
this);
97 if (!materialized_use_empty()) {
98 dbgs() <<
"While deleting: " << *VTy <<
" %" <<
getName() <<
"\n";
99 for (
auto *U :
users())
100 dbgs() <<
"Use still stuck around after Def is destroyed:" << *
U <<
"\n";
103 assert(materialized_use_empty() &&
"Uses remain when a value is destroyed!");
110void Value::deleteValue() {
111 switch (getValueID()) {
112#define HANDLE_VALUE(Name) \
113 case Value::Name##Val: \
114 delete static_cast<Name *>(this); \
116#define HANDLE_MEMORY_VALUE(Name) \
117 case Value::Name##Val: \
118 static_cast<DerivedUser *>(this)->DeleteValue( \
119 static_cast<DerivedUser *>(this)); \
121#define HANDLE_CONSTANT(Name) \
122 case Value::Name##Val: \
123 llvm_unreachable("constants should be destroyed with destroyConstant"); \
125#define HANDLE_INSTRUCTION(Name)
126#include "llvm/IR/Value.def"
128#define HANDLE_INST(N, OPC, CLASS) \
129 case Value::InstructionVal + Instruction::OPC: \
130 delete static_cast<CLASS *>(this); \
132#define HANDLE_USER_INST(N, OPC, CLASS)
133#include "llvm/IR/Instruction.def"
140void Value::destroyValueName() {
146 setValueName(
nullptr);
149bool Value::hasNUses(
unsigned N)
const {
153bool Value::hasNUsesOrMore(
unsigned N)
const {
157bool Value::hasOneUser()
const {
162 return std::equal(++user_begin(), user_end(), user_begin());
167Use *Value::getSingleUndroppableUse() {
170 if (!
U.getUser()->isDroppable()) {
179User *Value::getUniqueUndroppableUser() {
181 for (
auto *U :
users()) {
182 if (!
U->isDroppable()) {
183 if (Result && Result != U)
191bool Value::hasNUndroppableUses(
unsigned int N)
const {
195bool Value::hasNUndroppableUsesOrMore(
unsigned int N)
const {
199void Value::dropDroppableUses(
203 if (
U.getUser()->isDroppable() && ShouldDrop(&U))
205 for (
Use *U : ToBeEdited)
206 dropDroppableUse(*U);
209void Value::dropDroppableUsesIn(
User &Usr) {
212 if (UsrOp.get() ==
this)
213 dropDroppableUse(UsrOp);
217void Value::dropDroppableUse(
Use &U) {
219 if (
auto *Assume = dyn_cast<AssumeInst>(
U.getUser())) {
220 unsigned OpNo =
U.getOperandNo();
222 U.set(ConstantInt::getTrue(
Assume->getContext()));
224 U.set(UndefValue::get(
U.get()->getType()));
226 BOI.
Tag =
Assume->getContext().pImpl->getOrInsertBundleTag(
"ignore");
234bool Value::isUsedInBasicBlock(
const BasicBlock *BB)
const {
242 const_user_iterator UI = user_begin(), UE = user_end();
243 for (; BI != BE && UI != UE; ++BI, ++UI) {
248 const auto *
User = dyn_cast<Instruction>(*UI);
249 if (
User &&
User->getParent() == BB)
255unsigned Value::getNumUses()
const {
256 return (
unsigned)std::distance(use_begin(), use_end());
264 ST = PP->getValueSymbolTable();
265 }
else if (
BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
267 ST =
P->getValueSymbolTable();
268 }
else if (
GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
269 if (
Module *
P = GV->getParent())
270 ST = &
P->getValueSymbolTable();
271 }
else if (
Argument *
A = dyn_cast<Argument>(V)) {
273 ST =
P->getValueSymbolTable();
275 assert(isa<Constant>(V) &&
"Unknown value type!");
282 if (!HasName)
return nullptr;
287 "No name entry found!");
296 "HasName bit out of sync!");
315 return getValueName()->getKey();
318void Value::setNameImpl(
const Twine &NewName) {
320 !getContext().shouldDiscardValueNames() || isa<GlobalValue>(
this);
324 if (!NeedNewName && !hasName())
333 assert(!NameRef.
contains(0) &&
"Null bytes are not allowed in names");
339 assert(!
getType()->isVoidTy() &&
"Cannot assign a name to void values!");
351 if (!NameRef.
empty()) {
355 setValueName(ValueName::create(NameRef,
Allocator));
356 getValueName()->setValue(
this);
365 ST->removeValueName(getValueName());
374 setValueName(
ST->createValueName(NameRef,
this));
377void Value::setName(
const Twine &NewName) {
378 setNameImpl(NewName);
379 if (
Function *
F = dyn_cast<Function>(
this))
380 F->updateAfterNameChange();
383void Value::takeName(
Value *V) {
384 assert(V !=
this &&
"Illegal call to this->takeName(this)!");
392 if (
V->hasName())
V->setName(
"");
398 ST->removeValueName(getValueName());
405 if (!
V->hasName())
return;
419 assert(!Failure &&
"V has a name, so it should have a ST!"); (void)Failure;
425 setValueName(
V->getValueName());
426 V->setValueName(
nullptr);
427 getValueName()->setValue(
this);
435 VST->removeValueName(
V->getValueName());
436 setValueName(
V->getValueName());
437 V->setValueName(
nullptr);
438 getValueName()->setValue(
this);
441 ST->reinsertValue(
this);
445std::string Value::getNameOrAsOperand()
const {
451 printAsOperand(
OS,
false);
456void Value::assertModuleIsMaterializedImpl()
const {
458 const GlobalValue *GV = dyn_cast<GlobalValue>(
this);
471 if (!Cache.
insert(Expr).second)
477 auto *
CE = dyn_cast<ConstantExpr>(O);
490 auto *
C = dyn_cast<Constant>(V);
494 auto *
CE = dyn_cast<ConstantExpr>(Expr);
503void Value::doRAUW(
Value *New, ReplaceMetadataUses ReplaceMetaUses) {
504 assert(New &&
"Value::replaceAllUsesWith(<null>) is invalid!");
506 "this->replaceAllUsesWith(expr(this)) is NOT valid!");
508 "replaceAllUses of value with new value of different type!");
512 ValueHandleBase::ValueIsRAUWd(
this, New);
513 if (ReplaceMetaUses == ReplaceMetadataUses::Yes && isUsedByMetadata())
514 ValueAsMetadata::handleRAUW(
this, New);
516 while (!materialized_use_empty()) {
520 if (
auto *
C = dyn_cast<Constant>(
U.getUser())) {
521 if (!isa<GlobalValue>(
C)) {
522 C->handleOperandChange(
this, New);
530 if (
BasicBlock *BB = dyn_cast<BasicBlock>(
this))
534void Value::replaceAllUsesWith(
Value *New) {
535 doRAUW(New, ReplaceMetadataUses::Yes);
538void Value::replaceNonMetadataUsesWith(
Value *New) {
539 doRAUW(New, ReplaceMetadataUses::No);
542void Value::replaceUsesWithIf(
Value *New,
544 assert(New &&
"Value::replaceUsesWithIf(<null>) is invalid!");
546 "replaceUses of value with new value of different type!");
552 if (!ShouldReplace(U))
556 if (
auto *
C = dyn_cast<Constant>(
U.getUser())) {
557 if (!isa<GlobalValue>(
C)) {
566 while (!Consts.
empty()) {
579 for (
auto *DVI : DbgUsers) {
580 if (DVI->getParent() != BB)
581 DVI->replaceVariableLocationOp(V, New);
583 for (
auto *DVR : DPUsers) {
586 DVR->replaceVariableLocationOp(V, New);
593 assert(New &&
"Value::replaceUsesOutsideBlock(<null>, BB) is invalid!");
595 "this->replaceUsesOutsideBlock(expr(this), BB) is NOT valid!");
597 "replaceUses of value with new value of different type!");
598 assert(BB &&
"Basic block that may contain a use of 'New' must be defined\n");
601 replaceUsesWithIf(New, [BB](
Use &U) {
602 auto *
I = dyn_cast<Instruction>(
U.getUser());
604 return !
I ||
I->getParent() != BB;
610enum PointerStripKind {
612 PSK_ZeroIndicesAndAliases,
613 PSK_ZeroIndicesSameRepresentation,
614 PSK_ForAliasAnalysis,
615 PSK_InBoundsConstantIndices,
619template <Po
interStripKind StripKind>
static void NoopCallback(
const Value *) {}
621template <Po
interStripKind StripKind>
622static const Value *stripPointerCastsAndOffsets(
625 if (!
V->getType()->isPointerTy())
635 if (
auto *
GEP = dyn_cast<GEPOperator>(V)) {
637 case PSK_ZeroIndices:
638 case PSK_ZeroIndicesAndAliases:
639 case PSK_ZeroIndicesSameRepresentation:
640 case PSK_ForAliasAnalysis:
641 if (!
GEP->hasAllZeroIndices())
644 case PSK_InBoundsConstantIndices:
645 if (!
GEP->hasAllConstantIndices())
649 if (!
GEP->isInBounds())
653 V =
GEP->getPointerOperand();
654 }
else if (Operator::getOpcode(V) == Instruction::BitCast) {
655 Value *NewV = cast<Operator>(V)->getOperand(0);
659 }
else if (StripKind != PSK_ZeroIndicesSameRepresentation &&
660 Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
663 V = cast<Operator>(V)->getOperand(0);
664 }
else if (StripKind == PSK_ZeroIndicesAndAliases && isa<GlobalAlias>(V)) {
665 V = cast<GlobalAlias>(V)->getAliasee();
666 }
else if (StripKind == PSK_ForAliasAnalysis && isa<PHINode>(V) &&
667 cast<PHINode>(V)->getNumIncomingValues() == 1) {
668 V = cast<PHINode>(V)->getIncomingValue(0);
670 if (
const auto *Call = dyn_cast<CallBase>(V)) {
671 if (
const Value *RV =
Call->getReturnedArgOperand()) {
678 if (StripKind == PSK_ForAliasAnalysis &&
679 (
Call->getIntrinsicID() == Intrinsic::launder_invariant_group ||
680 Call->getIntrinsicID() == Intrinsic::strip_invariant_group)) {
681 V =
Call->getArgOperand(0);
687 assert(
V->getType()->isPointerTy() &&
"Unexpected operand type!");
688 }
while (Visited.
insert(V).second);
694const Value *Value::stripPointerCasts()
const {
695 return stripPointerCastsAndOffsets<PSK_ZeroIndices>(
this);
698const Value *Value::stripPointerCastsAndAliases()
const {
699 return stripPointerCastsAndOffsets<PSK_ZeroIndicesAndAliases>(
this);
702const Value *Value::stripPointerCastsSameRepresentation()
const {
703 return stripPointerCastsAndOffsets<PSK_ZeroIndicesSameRepresentation>(
this);
706const Value *Value::stripInBoundsConstantOffsets()
const {
707 return stripPointerCastsAndOffsets<PSK_InBoundsConstantIndices>(
this);
710const Value *Value::stripPointerCastsForAliasAnalysis()
const {
711 return stripPointerCastsAndOffsets<PSK_ForAliasAnalysis>(
this);
714const Value *Value::stripAndAccumulateConstantOffsets(
716 bool AllowInvariantGroup,
718 if (!
getType()->isPtrOrPtrVectorTy())
723 "The offset bit width does not match the DL specification.");
731 if (
auto *
GEP = dyn_cast<GEPOperator>(V)) {
733 if (!AllowNonInbounds && !
GEP->isInBounds())
742 APInt GEPOffset(
DL.getIndexTypeSizeInBits(
V->getType()), 0);
743 if (!
GEP->accumulateConstantOffset(
DL, GEPOffset, ExternalAnalysis))
749 if (GEPOffset.getSignificantBits() >
BitWidth)
755 if (!ExternalAnalysis) {
758 bool Overflow =
false;
766 V =
GEP->getPointerOperand();
767 }
else if (Operator::getOpcode(V) == Instruction::BitCast ||
768 Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
769 V = cast<Operator>(V)->getOperand(0);
770 }
else if (
auto *GA = dyn_cast<GlobalAlias>(V)) {
771 if (!GA->isInterposable())
772 V = GA->getAliasee();
773 }
else if (
const auto *Call = dyn_cast<CallBase>(V)) {
774 if (
const Value *RV =
Call->getReturnedArgOperand())
776 if (AllowInvariantGroup &&
Call->isLaunderOrStripInvariantGroup())
777 V =
Call->getArgOperand(0);
779 assert(
V->getType()->isPtrOrPtrVectorTy() &&
"Unexpected operand type!");
780 }
while (Visited.
insert(V).second);
787 return stripPointerCastsAndOffsets<PSK_InBounds>(
this, Func);
790bool Value::canBeFreed()
const {
795 if (isa<Constant>(
this))
800 if (
auto *
A = dyn_cast<Argument>(
this)) {
801 if (
A->hasPointeeInMemoryValueAttr())
809 if (
F->doesNotFreeMemory() &&
F->hasNoSync())
814 if (
auto *
I = dyn_cast<Instruction>(
this))
815 F =
I->getFunction();
816 if (
auto *
A = dyn_cast<Argument>(
this))
831 const auto &GCName =
F->getGC();
832 if (GCName ==
"statepoint-example") {
833 auto *PT = cast<PointerType>(this->
getType());
834 if (PT->getAddressSpace() != 1)
844 for (
auto &Fn : *
F->getParent())
845 if (Fn.getIntrinsicID() == Intrinsic::experimental_gc_statepoint)
854 bool &CanBeFreed)
const {
860 if (
const Argument *
A = dyn_cast<Argument>(
this)) {
861 DerefBytes =
A->getDereferenceableBytes();
862 if (DerefBytes == 0) {
864 if (
Type *ArgMemTy =
A->getPointeeInMemoryValueType()) {
865 if (ArgMemTy->isSized()) {
867 DerefBytes =
DL.getTypeStoreSize(ArgMemTy).getKnownMinValue();
872 if (DerefBytes == 0) {
873 DerefBytes =
A->getDereferenceableOrNullBytes();
876 }
else if (
const auto *Call = dyn_cast<CallBase>(
this)) {
877 DerefBytes =
Call->getRetDereferenceableBytes();
878 if (DerefBytes == 0) {
879 DerefBytes =
Call->getRetDereferenceableOrNullBytes();
882 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(
this)) {
883 if (
MDNode *MD = LI->getMetadata(LLVMContext::MD_dereferenceable)) {
884 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
887 if (DerefBytes == 0) {
889 LI->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
890 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
895 }
else if (
auto *IP = dyn_cast<IntToPtrInst>(
this)) {
896 if (
MDNode *MD = IP->getMetadata(LLVMContext::MD_dereferenceable)) {
897 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
900 if (DerefBytes == 0) {
902 IP->getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
903 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
908 }
else if (
auto *AI = dyn_cast<AllocaInst>(
this)) {
909 if (!AI->isArrayAllocation()) {
911 DL.getTypeStoreSize(AI->getAllocatedType()).getKnownMinValue();
915 }
else if (
auto *GV = dyn_cast<GlobalVariable>(
this)) {
919 DerefBytes =
DL.getTypeStoreSize(GV->
getValueType()).getFixedValue();
929 if (
auto *GO = dyn_cast<GlobalObject>(
this)) {
930 if (isa<Function>(GO)) {
931 Align FunctionPtrAlign =
DL.getFunctionPtrAlign().valueOrOne();
932 switch (
DL.getFunctionPtrAlignType()) {
933 case DataLayout::FunctionPtrAlignType::Independent:
934 return FunctionPtrAlign;
935 case DataLayout::FunctionPtrAlignType::MultipleOfFunctionAlign:
936 return std::max(FunctionPtrAlign, GO->getAlign().valueOrOne());
942 if (
auto *GVar = dyn_cast<GlobalVariable>(GO)) {
943 Type *ObjectType = GVar->getValueType();
948 if (GVar->isStrongDefinitionForLinker())
949 return DL.getPreferredAlign(GVar);
951 return DL.getABITypeAlign(ObjectType);
955 return Alignment.valueOrOne();
956 }
else if (
const Argument *
A = dyn_cast<Argument>(
this)) {
958 if (!Alignment &&
A->hasStructRetAttr()) {
960 Type *EltTy =
A->getParamStructRetType();
962 return DL.getABITypeAlign(EltTy);
965 }
else if (
const AllocaInst *AI = dyn_cast<AllocaInst>(
this)) {
966 return AI->getAlign();
967 }
else if (
const auto *Call = dyn_cast<CallBase>(
this)) {
969 if (!Alignment &&
Call->getCalledFunction())
970 Alignment =
Call->getCalledFunction()->getAttributes().getRetAlignment();
972 }
else if (
const LoadInst *LI = dyn_cast<LoadInst>(
this)) {
973 if (
MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
974 ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
977 }
else if (
auto *CstPtr = dyn_cast<Constant>(
this)) {
980 CstPtr = CstPtr->stripPointerCasts();
981 if (
auto *CstInt = dyn_cast_or_null<ConstantInt>(ConstantExpr::getPtrToInt(
984 size_t TrailingZeros = CstInt->getValue().countr_zero();
987 return Align(TrailingZeros < Value::MaxAlignmentExponent
989 : Value::MaximumAlignment);
995static std::optional<int64_t>
999 for (
unsigned i = 1; i !=
Idx; ++i, ++GTI)
1004 for (
unsigned i =
Idx, e =
GEP->getNumOperands(); i != e; ++i, ++GTI) {
1007 return std::nullopt;
1020 if (
Size.isScalable())
1021 return std::nullopt;
1028std::optional<int64_t> Value::getPointerOffsetFrom(
const Value *
Other,
1031 const Value *Ptr2 =
this;
1039 return Offset2.getSExtValue() - Offset1.getSExtValue();
1041 const GEPOperator *GEP1 = dyn_cast<GEPOperator>(Ptr1);
1042 const GEPOperator *GEP2 = dyn_cast<GEPOperator>(Ptr2);
1051 return std::nullopt;
1061 if (!IOffset1 || !IOffset2)
1062 return std::nullopt;
1063 return *IOffset2 - *IOffset1 + Offset2.getSExtValue() -
1064 Offset1.getSExtValue();
1069 auto *PN = dyn_cast<PHINode>(
this);
1070 if (PN && PN->getParent() == CurBB)
1071 return PN->getIncomingValueForBlock(PredBB);
1075LLVMContext &Value::getContext()
const {
return VTy->getContext(); }
1077void Value::reverseUseList() {
1078 if (!UseList || !UseList->Next)
1082 Use *Head = UseList;
1083 Use *Current = UseList->Next;
1084 Head->Next =
nullptr;
1086 Use *Next = Current->Next;
1087 Current->Next = Head;
1088 Head->Prev = &Current->Next;
1093 Head->Prev = &UseList;
1096bool Value::isSwiftError()
const {
1097 auto *Arg = dyn_cast<Argument>(
this);
1099 return Arg->hasSwiftErrorAttr();
1100 auto *Alloca = dyn_cast<AllocaInst>(
this);
1103 return Alloca->isSwiftError();
1111 assert(List &&
"Handle list is null?");
1118 Next->setPrevPtr(&Next);
1119 assert(getValPtr() == Next->getValPtr() &&
"Added to wrong list?");
1123void ValueHandleBase::AddToExistingUseListAfter(
ValueHandleBase *List) {
1124 assert(List &&
"Must insert after existing node");
1130 Next->setPrevPtr(&Next);
1133void ValueHandleBase::AddToUseList() {
1134 assert(getValPtr() &&
"Null pointer doesn't have a use list!");
1138 if (getValPtr()->HasValueHandle) {
1142 assert(Entry &&
"Value doesn't have any handles?");
1143 AddToExistingUseList(&Entry);
1156 assert(!Entry &&
"Value really did already have handles?");
1157 AddToExistingUseList(&Entry);
1158 getValPtr()->HasValueHandle =
true;
1163 Handles.
size() == 1) {
1169 E = Handles.
end();
I !=
E; ++
I) {
1170 assert(
I->second &&
I->first ==
I->second->getValPtr() &&
1171 "List invariant broken!");
1172 I->second->setPrevPtr(&
I->second);
1176void ValueHandleBase::RemoveFromUseList() {
1177 assert(getValPtr() && getValPtr()->HasValueHandle &&
1178 "Pointer doesn't have a use list!");
1182 assert(*PrevPtr ==
this &&
"List invariant broken");
1186 assert(Next->getPrevPtr() == &Next &&
"List invariant broken");
1187 Next->setPrevPtr(PrevPtr);
1197 Handles.
erase(getValPtr());
1198 getValPtr()->HasValueHandle =
false;
1202void ValueHandleBase::ValueIsDeleted(
Value *V) {
1203 assert(
V->HasValueHandle &&
"Should only be called if ValueHandles present");
1209 assert(Entry &&
"Value bit set but no entries exist");
1221 Iterator.RemoveFromUseList();
1222 Iterator.AddToExistingUseListAfter(Entry);
1223 assert(
Entry->Next == &Iterator &&
"Loop invariant broken.");
1225 switch (
Entry->getKind()) {
1232 Entry->operator=(
nullptr);
1242 if (
V->HasValueHandle) {
1244 dbgs() <<
"While deleting: " << *
V->getType() <<
" %" <<
V->getName()
1255void ValueHandleBase::ValueIsRAUWd(
Value *Old,
Value *New) {
1256 assert(Old->HasValueHandle &&
"Should only be called if ValueHandles present");
1257 assert(Old != New &&
"Changing value into itself!");
1259 "replaceAllUses of value with new value of different type!");
1266 assert(Entry &&
"Value bit set but no entries exist");
1273 Iterator.RemoveFromUseList();
1274 Iterator.AddToExistingUseListAfter(Entry);
1275 assert(
Entry->Next == &Iterator &&
"Loop invariant broken.");
1277 switch (
Entry->getKind()) {
1296 if (Old->HasValueHandle)
1298 switch (
Entry->getKind()) {
1300 dbgs() <<
"After RAUW from " << *Old->
getType() <<
" %"
1301 << Old->
getName() <<
" to " << *
New->getType() <<
" %"
1302 <<
New->getName() <<
"\n";
1304 "A weak tracking value handle still pointed to the old value!\n");
1312void CallbackVH::anchor() {}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Given that RA is a live propagate it s liveness to any other values it uses(according to Uses). void DeadArgumentEliminationPass
This file defines the DenseMap class.
std::optional< std::vector< StOtherPiece > > Other
Module.h This file contains the declarations for the Module class.
static StringRef getName(Value *V)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static std::optional< int64_t > getOffsetFromIndex(const GEPOperator *GEP, unsigned Idx, const DataLayout &DL)
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"))
This file defines the SmallString class.
static SymbolRef::Type getType(const Symbol *Sym)
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.
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.
InstListType::const_iterator const_iterator
const Function * getParent() const
Return the enclosing method, or null if none.
Value handle with callbacks on RAUW and destruction.
A constant value that is initialized with an expression using other constant values.
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...
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...
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Per-instruction record of debug-info.
const BasicBlock * getParent() const
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.
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
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.
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.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - 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.
Class to represent struct types.
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 isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
A Use represents the edge between a Value definition and its users.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
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.
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.
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.
LLVMContext & getContext() const
All values hold a context through their type.
StringRef getName() const
Return a constant reference to the value's name.
An efficient, type-erasing, non-owning reference to a callable.
StructType * getStructTypeOrNull() const
TypeSize getSequentialElementStride(const DataLayout &DL) const
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ CE
Windows NT (Windows on ARM)
@ Assume
Do not drop type tests (default).
NodeAddr< FuncNode * > Func
This is an optimization pass for GlobalISel generic memory operations.
void findDbgUsers(SmallVectorImpl< DbgVariableIntrinsic * > &DbgInsts, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords=nullptr)
Finds the debug info intrinsics describing a value.
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.
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.
bool isPointerTy(const Type *T)
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.
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.