65 :
Value(Ty, MetadataAsValueVal), MD(MD) {
93 if (!
N ||
N->getNumOperands() != 1)
96 if (!
N->getOperand(0))
109 auto *&Entry = Context.pImpl->MetadataAsValues[MD];
118 auto &
Store = Context.pImpl->MetadataAsValues;
119 return Store.lookup(MD);
122void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
125 auto &
Store = Context.pImpl->MetadataAsValues;
128 Store.erase(this->MD);
133 auto *&Entry =
Store[MD];
145void MetadataAsValue::track() {
150void MetadataAsValue::untrack() {
165 auto OldMD =
static_cast<Metadata **
>(Old);
176void DebugValueUser::trackDebugValue(
size_t Idx) {
177 assert(Idx < 3 &&
"Invalid debug value index.");
183void DebugValueUser::trackDebugValues() {
189void DebugValueUser::untrackDebugValue(
size_t Idx) {
190 assert(Idx < 3 &&
"Invalid debug value index.");
196void DebugValueUser::untrackDebugValues() {
203 assert(DebugValueUser::operator==(
X) &&
"Expected values to match");
207 X.DebugValues.fill(
nullptr);
211 assert(
Ref &&
"Expected live reference");
213 "Reference without owner must be direct");
214 if (
auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {
219 assert(!PH->Use &&
"Placeholders can only be used once");
228 assert(
Ref &&
"Expected live reference");
229 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD))
236 assert(
Ref &&
"Expected live reference");
237 assert(New &&
"Expected live reference");
239 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {
240 R->moveRef(
Ref, New, MD);
244 "Unexpected move of an MDOperand");
246 "Expected un-replaceable metadata, since we didn't move a reference");
251 return ReplaceableMetadataImpl::isReplaceable(MD);
256 for (
auto Pair : UseMap) {
264 MDUsersWithID.
push_back(&UseMap[Pair.first]);
266 llvm::sort(MDUsersWithID, [](
auto UserA,
auto UserB) {
267 return UserA->second < UserB->second;
270 for (
auto *UserWithID : MDUsersWithID)
278 for (
auto Pair : UseMap) {
284 DVRUsersWithID.
push_back(&UseMap[Pair.first]);
291 llvm::sort(DVRUsersWithID, [](
auto UserA,
auto UserB) {
292 return UserA->second > UserB->second;
295 for (
auto UserWithID : DVRUsersWithID)
300void ReplaceableMetadataImpl::addRef(
void *
Ref, OwnerTy
Owner) {
302 UseMap.insert(std::make_pair(
Ref, std::make_pair(
Owner, NextIndex)))
305 assert(WasInserted &&
"Expected to add a reference");
308 assert(NextIndex != 0 &&
"Unexpected overflow");
311void ReplaceableMetadataImpl::dropRef(
void *
Ref) {
312 bool WasErased = UseMap.erase(
Ref);
314 assert(WasErased &&
"Expected to drop a reference");
317void ReplaceableMetadataImpl::moveRef(
void *
Ref,
void *New,
319 auto I = UseMap.find(
Ref);
320 assert(
I != UseMap.end() &&
"Expected to move a reference");
321 auto OwnerAndIndex =
I->second;
323 bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;
325 assert(WasInserted &&
"Expected to add a reference");
330 "Reference without owner must be direct");
331 assert((OwnerAndIndex.first || *
static_cast<Metadata **
>(New) == &MD) &&
332 "Reference without owner must be direct");
336 if (!
C.isUsedByMetadata()) {
341 auto &
Store = Context.pImpl->ValuesAsMetadata;
345 std::pair<void *, std::pair<MetadataTracking::OwnerTy, uint64_t>>;
350 for (
const auto &Pair :
Uses) {
366 OwnerMD->handleChangedOperand(
377 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
380 return L.second.second < R.second.second;
382 for (
const auto &Pair :
Uses) {
385 if (!UseMap.count(Pair.first))
395 UseMap.erase(Pair.first);
406 DVU->handleChangedValue(Pair.first, MD);
413#define HANDLE_METADATA_LEAF(CLASS) \
414 case Metadata::CLASS##Kind: \
415 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
417#include "llvm/IR/Metadata.def"
422 assert(UseMap.empty() &&
"Expected all uses to be replaced");
435 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
438 return L.second.second < R.second.second;
441 for (
const auto &Pair :
Uses) {
442 auto Owner = Pair.second.first;
452 if (OwnerMD->isResolved())
454 OwnerMD->decrementUnresolvedOperandCount();
463 return !
N->isResolved() ||
N->isAlwaysReplaceable()
464 ?
N->Context.getOrCreateReplaceableUses()
474 return !
N->isResolved() ||
N->isAlwaysReplaceable()
475 ?
N->Context.getReplaceableUses()
483bool ReplaceableMetadataImpl::isReplaceable(
const Metadata &MD) {
485 return !
N->isResolved() ||
N->isAlwaysReplaceable();
490 assert(V &&
"Expected value");
492 if (
auto *Fn =
A->getParent())
493 return Fn->getSubprogram();
498 if (
auto *Fn = BB->getParent())
499 return Fn->getSubprogram();
507 assert(V &&
"Unexpected null Value");
509 auto &Context = V->getContext();
510 auto *&Entry = Context.pImpl->ValuesAsMetadata[V];
513 "Expected constant or function-local value");
514 assert(!V->IsUsedByMD &&
"Expected this to be the only metadata use");
515 V->IsUsedByMD =
true;
526 assert(V &&
"Unexpected null Value");
527 return V->getContext().pImpl->ValuesAsMetadata.lookup(V);
531 assert(V &&
"Expected valid value");
533 auto &
Store = V->getType()->getContext().pImpl->ValuesAsMetadata;
540 assert(MD &&
"Expected valid metadata");
550 assert(From &&
"Expected valid value");
551 assert(To &&
"Expected valid value");
552 assert(From != To &&
"Expected changed value");
556 auto &
Store = Context.pImpl->ValuesAsMetadata;
557 auto I =
Store.find(From);
567 assert(MD &&
"Expected valid metadata");
592 auto *&Entry =
Store[To];
612 auto &
Store = Context.pImpl->MDStringCache;
613 auto I =
Store.try_emplace(Str);
614 auto &MapEntry =
I.first->getValue();
617 MapEntry.Entry = &*
I.first;
622 auto &
Store = Context.pImpl->MDStringCache;
626 return &
I->getValue();
630 assert(Entry &&
"Expected to find string map entry");
631 return Entry->first();
640#define HANDLE_MDNODE_LEAF(CLASS) \
642 alignof(uint64_t) >= alignof(CLASS), \
643 "Alignment is insufficient after objects prepended to " #CLASS);
644#include "llvm/IR/Metadata.def"
649 static_assert(
sizeof(Header) ==
sizeof(size_t) + 2 *
sizeof(
uint32_t),
650 "MDNode header fields poorly packed");
653 char *Mem =
reinterpret_cast<char *
>(::operator
new(AllocSize +
Size));
654 Header *
H =
new (Mem + AllocSize -
sizeof(Header)) Header(
NumOps,
Storage);
655 return reinterpret_cast<void *
>(
H + 1);
658void MDNode::operator
delete(
void *
N) {
659 Header *
H =
reinterpret_cast<Header *
>(
N) - 1;
660 void *Mem =
H->getAllocation();
662 ::operator
delete(Mem);
668 getHeader().MetadataPrintID = Context.pImpl->allocateMetadataPrintID();
681 countUnresolvedOperands();
688#define HANDLE_MDNODE_LEAF(CLASS) \
690 return cast<CLASS>(this)->cloneImpl();
691#include "llvm/IR/Metadata.def"
695MDNode::Header::Header(
size_t NumOps, StorageType Storage) {
696 IsLarge = isLarge(
NumOps);
697 IsResizable = isResizable(
Storage);
698 SmallSize = getSmallSize(
NumOps, IsResizable, IsLarge);
701 new (getLargePtr()) LargeStorageVector();
711MDNode::Header::~Header() {
713 getLarge().~LargeStorageVector();
716 MDOperand *
O =
reinterpret_cast<MDOperand *
>(
this);
717 for (MDOperand *
E = O - SmallSize;
O !=
E; --
O)
718 (O - 1)->~MDOperand();
721void *MDNode::Header::getSmallPtr() {
722 static_assert(
alignof(MDOperand) <=
alignof(Header),
723 "MDOperand too strongly aligned");
724 return reinterpret_cast<char *
>(
const_cast<Header *
>(
this)) -
725 sizeof(MDOperand) * SmallSize;
728void MDNode::Header::resize(
size_t NumOps) {
729 assert(IsResizable &&
"Node is not resizable");
734 getLarge().resize(
NumOps);
735 else if (
NumOps <= SmallSize)
738 resizeSmallToLarge(
NumOps);
741void MDNode::Header::resizeSmall(
size_t NumOps) {
742 assert(!IsLarge &&
"Expected a small MDNode");
743 assert(
NumOps <= SmallSize &&
"NumOps too large for small resize");
748 int NumNew = (int)
NumOps - (
int)ExistingOps.
size();
749 MDOperand *
O = ExistingOps.
end();
750 for (
int I = 0,
E = NumNew;
I <
E; ++
I)
752 for (
int I = 0,
E = NumNew;
I >
E; --
I)
758void MDNode::Header::resizeSmallToLarge(
size_t NumOps) {
759 assert(!IsLarge &&
"Expected a small MDNode");
760 assert(
NumOps > SmallSize &&
"Expected NumOps to be larger than allocation");
761 LargeStorageVector NewOps;
765 new (getLargePtr()) LargeStorageVector(std::move(NewOps));
771 return !
N->isResolved();
775void MDNode::countUnresolvedOperands() {
781void MDNode::makeUniqued() {
785 assert(WasTracked &&
"Temporary node not tracked");
790 Op.reset(
Op.get(),
this);
794 countUnresolvedOperands();
796 dropReplaceableUses();
803void MDNode::makeDistinct() {
808 dropReplaceableUses();
820 dropReplaceableUses();
825void MDNode::dropReplaceableUses() {
829 if (Context.hasReplaceableUses())
830 Context.takeReplaceableUses()->resolveAllUses();
843 decrementUnresolvedOperandCount();
846void MDNode::decrementUnresolvedOperandCount() {
857 dropReplaceableUses();
875 "Expected all forward declarations to be resolved");
876 if (!
N->isResolved())
885MDNode *MDNode::replaceWithPermanentImpl() {
889 return replaceWithDistinctImpl();
891#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
894#include "llvm/IR/Metadata.def"
899 return replaceWithDistinctImpl();
900 return replaceWithUniquedImpl();
903MDNode *MDNode::replaceWithUniquedImpl() {
905 MDNode *UniquedNode = uniquify();
907 if (UniquedNode ==
this) {
918MDNode *MDNode::replaceWithDistinctImpl() {
923void MDTuple::recalculateHash() {
924 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
930 if (Context.hasReplaceableUses()) {
931 Context.getReplaceableUses()->resolveAllUses(
false);
932 (void)Context.takeReplaceableUses();
936void MDNode::handleChangedOperand(
void *
Ref,
Metadata *New) {
964 resolveAfterOperandChange(Old, New);
976 if (Context.hasReplaceableUses())
977 Context.getReplaceableUses()->replaceAllUsesWith(
Uniqued);
986void MDNode::deleteAsSubclass() {
989 assert(WasTracked &&
"Temporary node not tracked");
995#define HANDLE_MDNODE_LEAF(CLASS) \
997 delete cast<CLASS>(this); \
999#include "llvm/IR/Metadata.def"
1003template <
class T,
class InfoT>
1012template <
class NodeTy>
struct MDNode::HasCachedHash {
1015 template <
class U>
static std::false_type
check(...);
1020MDNode *MDNode::uniquify() {
1027#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1028 case CLASS##Kind: { \
1029 CLASS *SubclassThis = cast<CLASS>(this); \
1030 dispatchRecalculateHash(SubclassThis); \
1031 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
1033#include "llvm/IR/Metadata.def"
1037void MDNode::eraseFromStore() {
1041#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
1043 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
1045#include "llvm/IR/Metadata.def"
1053 MDTupleInfo::KeyTy
Key(MDs);
1058 Hash =
Key.getHash();
1060 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
1064 MDTuple(Context,
Storage, Hash, MDs),
1065 Storage, Context.pImpl->MDTuples);
1069 assert(
N->isTemporary() &&
"Expected temporary node");
1070 N->replaceAllUsesWith(
nullptr);
1071 N->deleteAsSubclass();
1075 assert(!Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
1079 assert(WasTracked &&
"Temporary node not tracked");
1089#define HANDLE_MDNODE_LEAF(CLASS) \
1090 case CLASS##Kind: { \
1091 dispatchResetHash(cast<CLASS>(this)); \
1094#include "llvm/IR/Metadata.def"
1127 if (
N->getNumOperands() ==
Ops.size() &&
N ==
N->getOperand(0)) {
1128 for (
unsigned I = 1,
E =
Ops.size();
I !=
E; ++
I)
1129 if (
Ops[
I] !=
N->getOperand(
I))
1144 MDs.
insert(
B->op_begin(),
B->op_end());
1192 return MDs.
empty() ? nullptr
1213 assert(
A &&
B && AInstr && BInstr &&
"Caller should guarantee");
1218 assert(
A->getNumOperands() >= 2 &&
B->getNumOperands() >= 2 &&
1219 "!prof annotations should have no less than 2 operands");
1223 assert(AMDS !=
nullptr && BMDS !=
nullptr &&
1224 "first operand should be a non-null MDString");
1233 assert(AInstrWeight && BInstrWeight &&
"verified by LLVM verifier");
1236 MDHelper.createConstant(ConstantInt::get(
1251 switch (
I.getOpcode()) {
1252 case Instruction::Invoke:
1253 case Instruction::CondBr:
1254 case Instruction::Switch:
1255 case Instruction::Call:
1256 case Instruction::IndirectBr:
1257 case Instruction::Select:
1258 case Instruction::CallBr:
1264 if (AInstr && !IsLegal(*AInstr))
1266 if (BInstr && !IsLegal(*BInstr))
1274 "Caller should guarantee");
1276 "Caller should guarantee");
1284 return mergeDirectCallProfMetadata(
A,
B, AInstr, BInstr);
1295 return A.getUpper() ==
B.getLower() ||
A.getLower() ==
B.getUpper();
1306 const APInt &LB = EndPoints[
Size - 2]->getValue();
1307 const APInt &LE = EndPoints[
Size - 1]->getValue();
1312 EndPoints[
Size - 2] =
1314 EndPoints[
Size - 1] =
1323 if (!EndPoints.
empty())
1338 auto AddUniqueCallees = [&AB, &MergedCallees](
const MDNode *
N) {
1340 if (MergedCallees.
insert(MD).second)
1344 AddUniqueCallees(
A);
1345 AddUniqueCallees(
B);
1356 return const_cast<MDNode *
>(
A);
1357 if (
A->getNumOperands() != 2 ||
B->getNumOperands() != 2)
1366 if (!NameA || !NameB)
1370 return CIA->isOne() ?
const_cast<MDNode *
>(
A) :
const_cast<MDNode *
>(
B);
1382 bool MergedContainsPointer = CIA->isOne() || CIB->isOne();
1405 unsigned AN =
A->getNumOperands() / 2;
1406 unsigned BN =
B->getNumOperands() / 2;
1407 while (AI < AN && BI < BN) {
1440 for (
unsigned i = 0; i <
Size - 2; ++i) {
1441 EndPoints[i] = EndPoints[i + 2];
1449 if (EndPoints.
size() == 2) {
1451 if (
Range.isFullSet())
1457 for (
auto *
I : EndPoints)
1476 AVal->
getType(), Intersect)));
1487 for (
unsigned I = 0, E =
A->getNumOperands() / 2;
I != E; ++
I) {
1493 for (
unsigned I = 0, E =
B->getNumOperands() / 2;
I != E; ++
I) {
1508 ConstantInt::get(
A->getContext(), CR.getLower())));
1510 ConstantInt::get(
A->getContext(), CR.getUpper())));
1569NamedMDNode::NamedMDNode(
const Twine &
N)
1578 return (
unsigned)
getNMDOps(Operands).size();
1604unsigned &Value::getMetadataIndex() {
1606 return I->MetadataIndex;
1610unsigned Value::getMetadataIndex()
const {
1611 return const_cast<Value *
>(
this)->getMetadataIndex();
1621 unsigned Idx = getMetadataIndex();
1624 if (
A.MDKind == KindID)
1637 if (
A.MDKind == KindID)
1642 std::reverse(MDs.
begin(), MDs.
end());
1653 unsigned Idx = getMetadataIndex();
1656 MDs.emplace_back(
A.MDKind,
A.Node);
1661 if (MDs.
size() > 1) {
1662 std::reverse(MDs.
begin(), MDs.
end());
1670 if (getMetadataIndex() != 0)
1677 if (!
Node && getMetadataIndex() == 0)
1684 unsigned &Idx = getMetadataIndex();
1685 unsigned NewIdx = Ctx.pImpl->MetadataRecycleHead;
1687 NewIdx = Ctx.pImpl->Metadatas.size();
1690 Ctx.pImpl->Metadatas.resize(NewIdx + 1);
1692 Ctx.pImpl->MetadataRecycleHead = Ctx.pImpl->Metadatas[NewIdx].Next;
1694 Ctx.pImpl->MetadataRecycleSize -= 1;
1697 Ctx.pImpl->Metadatas[NewIdx] =
1710 return MDKind == KindID;
1716 unsigned *Idx = &getMetadataIndex();
1720 if (Pred(
A.MDKind,
A.Node)) {
1722 unsigned FreeIdx = *Idx;
1724 A.Next = Ctx.pImpl->MetadataRecycleHead;
1725 Ctx.pImpl->MetadataRecycleHead = FreeIdx;
1727 Ctx.pImpl->MetadataRecycleSize += 1;
1740 if (!
Node && MetadataIndex == 0)
1747 unsigned KindID = Ctx.getMDKindID(Kind);
1748 if (KindID == LLVMContext::MD_dbg)
1754 if (DbgLoc && Pred(LLVMContext::MD_dbg, DbgLoc.getAsMDNode()))
1767 KnownSet.
insert(LLVMContext::MD_DIAssignID);
1770 return !KnownSet.
count(MDKind);
1774void Instruction::updateDIAssignIDMapping(
DIAssignID *ID) {
1779 if (ID == CurrentID)
1783 auto InstrsIt = IDToInstrs.find(CurrentID);
1784 assert(InstrsIt != IDToInstrs.end() &&
1785 "Expect existing attachment to be mapped");
1787 auto &InstVec = InstrsIt->second;
1789 assert(InstIt != InstVec.end() &&
1790 "Expect instruction to be mapped to attachment");
1794 if (InstVec.size() == 1)
1795 IDToInstrs.erase(InstrsIt);
1797 InstVec.erase(InstIt);
1802 IDToInstrs[ID].push_back(
this);
1810 if (KindID == LLVMContext::MD_dbg) {
1816 if (KindID == LLVMContext::MD_DIAssignID) {
1821 "Temporary DIAssignIDs are invalid");
1830 if (
auto *Existing =
getMetadata(LLVMContext::MD_annotation)) {
1834 for (
auto &
N : Tuple->operands()) {
1840 if (
any_of(MDAnnotationTuple->operands(), [&AnnotationsSet](
auto &
Op) {
1841 return AnnotationsSet.contains(cast<MDString>(Op)->getString());
1860 if (
auto *Existing =
getMetadata(LLVMContext::MD_annotation)) {
1862 for (
auto &
N : Tuple->operands()) {
1879 unsigned Idx = MetadataIndex;
1884 case LLVMContext::MD_tbaa:
1885 Result.TBAA =
A.Node;
1887 case LLVMContext::MD_tbaa_struct:
1888 Result.TBAAStruct =
A.Node;
1890 case LLVMContext::MD_alias_scope:
1891 Result.Scope =
A.Node;
1893 case LLVMContext::MD_noalias:
1894 Result.NoAlias =
A.Node;
1896 case LLVMContext::MD_noalias_addrspace:
1897 Result.NoAliasAddrSpace =
A.Node;
1908 setMetadata(LLVMContext::MD_tbaa_struct,
N.TBAAStruct);
1911 setMetadata(LLVMContext::MD_noalias_addrspace,
N.NoAliasAddrSpace);
1919void Instruction::getAllMetadataImpl(
1926 std::make_pair((
unsigned)LLVMContext::MD_dbg, DbgLoc.
getAsMDNode()));
1936 getOpcode() == Instruction::IndirectBr ||
1938 "Looking for branch weights on something besides branch");
1940 return ::extractProfTotalWeight(*
this, TotalVal);
1945 Other->getAllMetadata(MDs);
1946 for (
auto &MD : MDs) {
1948 if (
Offset != 0 && MD.first == LLVMContext::MD_type) {
1951 Metadata *TypeId = MD.second->getOperand(1);
1953 OffsetConst->getType(), OffsetConst->getValue() +
Offset));
1961 auto *Attachment = MD.second;
1962 if (
Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1967 GV = GVE->getVariable();
1968 E = GVE->getExpression();
1972 OrigElements = E->getElements();
1973 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1974 Elements[0] = dwarf::DW_OP_plus_uconst;
1976 llvm::copy(OrigElements, Elements.begin() + 2);
1986 LLVMContext::MD_type,
2008 assert(Val <= 2 &&
"unknown vcall visibility!");
2025 return CU->getDebugInfoForProfiling();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
static const Function * getParent(const Value *V)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static ManagedStatic< DebugCounterOwner > Owner
This file defines the DenseSet and SmallDenseSet classes.
Module.h This file contains the declarations for the Module class.
static constexpr Value * getValue(Ty &ValueOrUse)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
This file contains the declarations for profiling metadata utility functions.
Remove Loads Into Fake Uses
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallSet class.
This file defines the SmallString class.
This file defines the SmallVector class.
Class for arbitrary precision integers.
bool slt(const APInt &RHS) const
Signed less than comparison.
This is a simple wrapper around an MDNode which provides a higher-level interface by hiding the detai...
Annotations lets you mark points and ranges inside source code, for tests:
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
LLVM Basic Block Representation.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
This class represents a function call, abstracting a target machine's calling convention.
This is the shared class of boolean and integer constants.
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.
This class represents a list of constant ranges.
LLVM_ABI ConstantRangeList intersectWith(const ConstantRangeList &CRL) const
Return the range list that results from the intersection of this ConstantRangeList with another Const...
This class represents a range of values.
LLVM_ABI ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
This is an important base class in LLVM.
A pair of DIGlobalVariable and DIExpression.
Subprogram description. Uses SubclassData1.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LLVM_ABI MDNode * getAsMDNode() const
Return this as a bar MDNode.
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
LLVM_ABI void handleChangedValue(void *Old, Metadata *NewDebugValue)
To be called by ReplaceableMetadataImpl::replaceAllUsesWith, where Old is a pointer to one of the poi...
std::array< Metadata *, 3 > DebugValues
void resetDebugValue(size_t Idx, Metadata *DebugValue)
LLVM_ABI DbgVariableRecord * getUser()
Implements a dense probed hash-table based set.
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool shouldEmitDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
LLVM_ABI void addTypeMetadata(unsigned Offset, Metadata *TypeID)
unsigned MetadataIndex
Index of first metadata attachment in context, or zero.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
GlobalObject(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace=0)
LLVM_ABI void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
LLVM_ABI VCallVisibility getVCallVisibility() const
LLVM_ABI bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this GlobalObject.
LLVM_ABI void setVCallVisibilityMetadata(VCallVisibility Visibility)
LLVM_ABI void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const
Fill the vector with all debug info attachements.
LLVM_ABI void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
LLVM_ABI void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
LLVM_ABI bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
LLVM_ABI void addAnnotationMetadata(StringRef Annotation)
Adds an !annotation metadata node with Annotation to this instruction.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM_ABI void setNoSanitizeMetadata()
Sets the nosanitize metadata on this instruction.
LLVM_ABI void dropUnknownNonDebugMetadata(ArrayRef< unsigned > KnownIDs={})
Drop all unknown metadata except for debug locations.
LLVM_ABI AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
LLVM_ABI void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)
Erase all metadata that matches the predicate.
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
SmallVector< MDAttachment, 0 > Metadatas
Collection of metadata attachments in this context.
DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs
Map DIAssignID -> Instructions with that attachment.
std::vector< MDNode * > DistinctMDNodes
DenseSet< MDNode * > TemporaryMDNodes
This is an important class for using LLVM in a threaded context.
LLVM_ABI unsigned getMDKindID(StringRef Name) const
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
LLVMContextImpl *const pImpl
LLVM_ABI MDString * createString(StringRef Str)
Return the given string as metadata.
static LLVM_ABI MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
LLVM_ABI void resolveCycles()
Resolve cycles.
static LLVM_ABI CaptureComponents toCaptureComponents(const MDNode *MD)
Convert !captures metadata to CaptureComponents. MD may be nullptr.
mutable_op_range mutable_operands()
static LLVM_ABI MDNode * getMergedCalleeTypeMetadata(const MDNode *A, const MDNode *B)
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
static LLVM_ABI MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
static LLVM_ABI void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
LLVM_ABI void resolve()
Resolve a unique, unresolved node.
const MDOperand & getOperand(unsigned I) const
static LLVM_ABI MDNode * getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B)
LLVM_ABI void storeDistinctInContext()
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static LLVM_ABI MDNode * getMergedProfMetadata(MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)
Merge !prof metadata from two instructions.
static LLVM_ABI MDNode * getMergedAllocTokenMetadata(const MDNode *A, const MDNode *B)
static LLVM_ABI MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
void setNumUnresolved(unsigned N)
unsigned getNumOperands() const
Return number of MDNode operands.
MDOperand * mutable_begin()
LLVM_ABI MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
LLVM_ABI TempMDNode clone() const
Create a (temporary) clone of this.
static LLVM_ABI MDNode * getMostGenericRange(MDNode *A, MDNode *B)
LLVM_ABI void setOperand(unsigned I, Metadata *New)
Set an operand.
bool isResolved() const
Check if node is fully resolved.
op_iterator op_begin() const
static LLVM_ABI MDNode * intersect(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * getMostGenericNoFPClass(MDNode *A, MDNode *B)
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
LLVMContext & getContext() const
static LLVM_ABI MDNode * fromCaptureComponents(LLVMContext &Ctx, CaptureComponents CC)
Convert CaptureComponents to !captures metadata.
LLVM_ABI void dropAllReferences()
static LLVM_ABI MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
unsigned getNumUnresolved() const
Tracking metadata reference owned by Metadata.
LLVM_ABI StringRef getString() const
static LLVM_ABI MDString * getIfExists(LLVMContext &Context, StringRef Str)
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
LLVM_ABI void setOperand(unsigned I, MDNode *New)
LLVM_ABI StringRef getName() const
void dropAllReferences()
Remove all uses and clear node vector.
LLVM_ABI void eraseFromParent()
Drop all references and remove the node from parent module.
LLVM_ABI MDNode * getOperand(unsigned i) const
LLVM_ABI unsigned getNumOperands() const
LLVM_ABI void clearOperands()
Drop all references to this node's operands.
Module * getParent()
Get the module that holds this named metadata collection.
LLVM_ABI void addOperand(MDNode *M)
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
ArrayRef< value_type > getArrayRef() const
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
constexpr size_t size() const
Get the string size.
A switch()-like statement whose cases are string literals.
StringSwitch & Case(StringLiteral S, T Value)
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI Type * getMetadataTy(LLVMContext &C)
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
LLVM_ABI 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.
LLVM_ABI void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
LLVM_ABI MDNode * getMetadataImpl(unsigned KindID) const LLVM_READONLY
Get metadata for the given kind, if any.
LLVM_ABI bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
LLVM_ABI MDNode * getMetadata(StringRef Kind) const LLVM_READONLY
Get the current metadata attachments for the given kind, if any.
LLVM_ABI void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)
Erase all metadata attachments matching the given predicate.
LLVM_ABI void clearMetadata()
Erase all metadata attached to this Value.
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
bool capturesReadProvenanceOnly(CaptureComponents CC)
void stable_sort(R &&Range)
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
bool capturesAddressIsNullOnly(CaptureComponents CC)
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
LLVM_ABI unsigned getBranchWeightOffset(const MDNode *ProfileData)
Return the offset to the first branch weight data.
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
bool capturesAddress(CaptureComponents CC)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Store
The extracted value is stored (ExtractElement only).
constexpr from_range_t from_range
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present<X> - Functionally identical to dyn_cast, except that a null (or none in the case ...
auto cast_or_null(const Y &Val)
auto dyn_cast_or_null(const Y &Val)
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
bool capturesFullProvenance(CaptureComponents CC)
void sort(IteratorTy Start, IteratorTy End)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
CaptureComponents
Components of the pointer that may be captured.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
@ Ref
The access may reference the value stored in memory.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
OutputIt copy(R &&Range, OutputIt Out)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool capturesAll(CaptureComponents CC)
std::enable_if_t< std::is_unsigned_v< T >, T > SaturatingAdd(T X, T Y, bool *ResultOverflowed=nullptr)
Add two unsigned integers, X and Y, of type T.
bool capturesNothing(CaptureComponents CC)
static constexpr bool value
static std::false_type check(...)
static std::true_type check(SameType< void(U::*)(unsigned), &U::setHash > *)
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Single metadata attachment, forms linked list ended by index 0.
static LLVM_ABI const char * BranchWeights
Function object to check whether the first component of a container supported by std::get (like std::...