60 :
Value(Ty, MetadataAsValueVal), MD(MD) {
87 auto *
N = dyn_cast<MDNode>(MD);
88 if (!
N ||
N->getNumOperands() != 1)
91 if (!
N->getOperand(0))
95 if (
auto *
C = dyn_cast<ConstantAsMetadata>(
N->getOperand(0)))
114 return Store.lookup(MD);
117void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
123 Store.erase(this->MD);
128 auto *&Entry = Store[MD];
140void MetadataAsValue::track() {
145void MetadataAsValue::untrack() {
151 assert(
Ref &&
"Expected live reference");
153 "Reference without owner must be direct");
154 if (
auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {
155 R->addRef(
Ref, Owner);
158 if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD)) {
159 assert(!PH->Use &&
"Placeholders can only be used once");
160 assert(!Owner &&
"Unexpected callback to owner");
168 assert(
Ref &&
"Expected live reference");
169 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD))
171 else if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD))
176 assert(
Ref &&
"Expected live reference");
177 assert(New &&
"Expected live reference");
179 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {
180 R->moveRef(
Ref, New, MD);
183 assert(!isa<DistinctMDOperandPlaceholder>(MD) &&
184 "Unexpected move of an MDOperand");
186 "Expected un-replaceable metadata, since we didn't move a reference");
191 return ReplaceableMetadataImpl::isReplaceable(MD);
196 for (
auto Pair : UseMap) {
197 OwnerTy Owner = Pair.second.first;
202 MDUsersWithID.
push_back(&UseMap[Pair.first]);
204 llvm::sort(MDUsersWithID, [](
auto UserA,
auto UserB) {
205 return UserA->second < UserB->second;
208 for (
auto *UserWithID : MDUsersWithID)
213void ReplaceableMetadataImpl::addRef(
void *
Ref, OwnerTy Owner) {
215 UseMap.insert(std::make_pair(
Ref, std::make_pair(Owner, NextIndex)))
218 assert(WasInserted &&
"Expected to add a reference");
221 assert(NextIndex != 0 &&
"Unexpected overflow");
224void ReplaceableMetadataImpl::dropRef(
void *
Ref) {
225 bool WasErased = UseMap.erase(
Ref);
227 assert(WasErased &&
"Expected to drop a reference");
230void ReplaceableMetadataImpl::moveRef(
void *
Ref,
void *New,
232 auto I = UseMap.find(
Ref);
233 assert(
I != UseMap.end() &&
"Expected to move a reference");
234 auto OwnerAndIndex =
I->second;
236 bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;
238 assert(WasInserted &&
"Expected to add a reference");
243 "Reference without owner must be direct");
244 assert((OwnerAndIndex.first || *
static_cast<Metadata **
>(New) == &MD) &&
245 "Reference without owner must be direct");
249 if (!
C.isUsedByMetadata()) {
255 auto I = Store.find(&
C);
258 std::pair<void *, std::pair<MetadataTracking::OwnerTy, uint64_t>>;
262 for (
const auto &Pair :
Uses) {
268 auto *OwnerMD = dyn_cast<MDNode>(Owner.
get<
Metadata *>());
271 if (isa<DINode>(OwnerMD)) {
272 OwnerMD->handleChangedOperand(
283 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
286 for (
const auto &Pair :
Uses) {
289 if (!UseMap.count(Pair.first))
292 OwnerTy Owner = Pair.second.first;
299 UseMap.erase(Pair.first);
312#define HANDLE_METADATA_LEAF(CLASS) \
313 case Metadata::CLASS##Kind: \
314 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
316#include "llvm/IR/Metadata.def"
321 assert(UseMap.empty() &&
"Expected all uses to be replaced");
334 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
337 return L.second.second < R.second.second;
340 for (
const auto &Pair :
Uses) {
341 auto Owner = Pair.second.first;
348 auto *OwnerMD = dyn_cast<MDNode>(Owner.get<
Metadata *>());
351 if (OwnerMD->isResolved())
353 OwnerMD->decrementUnresolvedOperandCount();
358 if (
auto *
N = dyn_cast<MDNode>(&MD))
359 return N->isResolved() ? nullptr :
N->Context.getOrCreateReplaceableUses();
360 return dyn_cast<ValueAsMetadata>(&MD);
364 if (
auto *
N = dyn_cast<MDNode>(&MD))
365 return N->isResolved() ? nullptr :
N->Context.getReplaceableUses();
366 return dyn_cast<ValueAsMetadata>(&MD);
369bool ReplaceableMetadataImpl::isReplaceable(
const Metadata &MD) {
370 if (
auto *
N = dyn_cast<MDNode>(&MD))
371 return !
N->isResolved();
372 return isa<ValueAsMetadata>(&MD);
376 assert(V &&
"Expected value");
377 if (
auto *
A = dyn_cast<Argument>(V)) {
378 if (
auto *Fn =
A->getParent())
379 return Fn->getSubprogram();
384 if (
auto *Fn = BB->getParent())
385 return Fn->getSubprogram();
393 assert(V &&
"Unexpected null Value");
398 assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
399 "Expected constant or function-local value");
402 if (
auto *
C = dyn_cast<Constant>(V))
412 assert(V &&
"Unexpected null Value");
417 assert(V &&
"Expected valid value");
420 auto I = Store.find(V);
421 if (
I == Store.end())
426 assert(MD &&
"Expected valid metadata");
437 assert(To &&
"Expected valid value");
438 assert(
From != To &&
"Expected changed value");
443 auto I = Store.find(
From);
444 if (
I == Store.end()) {
445 assert(!
From->IsUsedByMD &&
"Expected From not to be used by metadata");
450 assert(
From->IsUsedByMD &&
"Expected From to be used by metadata");
451 From->IsUsedByMD =
false;
453 assert(MD &&
"Expected valid metadata");
457 if (isa<LocalAsMetadata>(MD)) {
458 if (
auto *
C = dyn_cast<Constant>(To)) {
471 }
else if (!isa<Constant>(To)) {
478 auto *&Entry = Store[To];
499 auto I = Store.try_emplace(Str);
500 auto &MapEntry =
I.first->getValue();
503 MapEntry.Entry = &*
I.first;
508 assert(Entry &&
"Expected to find string map entry");
509 return Entry->first();
518#define HANDLE_MDNODE_LEAF(CLASS) \
520 alignof(uint64_t) >= alignof(CLASS), \
521 "Alignment is insufficient after objects prepended to " #CLASS);
522#include "llvm/IR/Metadata.def"
529 char *Mem =
reinterpret_cast<char *
>(::operator
new(AllocSize +
Size));
530 Header *
H =
new (Mem + AllocSize -
sizeof(Header)) Header(NumOps, Storage);
531 return reinterpret_cast<void *
>(
H + 1);
534void MDNode::operator
delete(
void *
N) {
535 Header *
H =
reinterpret_cast<Header *
>(
N) - 1;
536 void *Mem =
H->getAllocation();
538 ::operator
delete(Mem);
555 countUnresolvedOperands();
562#define HANDLE_MDNODE_LEAF(CLASS) \
564 return cast<CLASS>(this)->cloneImpl();
565#include "llvm/IR/Metadata.def"
569MDNode::Header::Header(
size_t NumOps, StorageType Storage) {
570 IsLarge = isLarge(NumOps);
571 IsResizable = isResizable(Storage);
572 SmallSize = getSmallSize(NumOps, IsResizable, IsLarge);
575 new (getLargePtr()) LargeStorageVector();
576 getLarge().resize(NumOps);
579 SmallNumOps = NumOps;
585MDNode::Header::~Header() {
587 getLarge().~LargeStorageVector();
595void *MDNode::Header::getSmallPtr() {
596 static_assert(
alignof(
MDOperand) <=
alignof(Header),
597 "MDOperand too strongly aligned");
598 return reinterpret_cast<char *
>(
const_cast<Header *
>(
this)) -
602void MDNode::Header::resize(
size_t NumOps) {
603 assert(IsResizable &&
"Node is not resizable");
604 if (operands().
size() == NumOps)
608 getLarge().resize(NumOps);
609 else if (NumOps <= SmallSize)
612 resizeSmallToLarge(NumOps);
615void MDNode::Header::resizeSmall(
size_t NumOps) {
616 assert(!IsLarge &&
"Expected a small MDNode");
617 assert(NumOps <= SmallSize &&
"NumOps too large for small resize");
620 assert(NumOps != ExistingOps.
size() &&
"Expected a different size");
622 int NumNew = (int)NumOps - (
int)ExistingOps.
size();
624 for (
int I = 0,
E = NumNew;
I <
E; ++
I)
626 for (
int I = 0,
E = NumNew;
I >
E; --
I)
628 SmallNumOps = NumOps;
629 assert(O == operands().end() &&
"Operands not (un)initialized until the end");
632void MDNode::Header::resizeSmallToLarge(
size_t NumOps) {
633 assert(!IsLarge &&
"Expected a small MDNode");
634 assert(NumOps > SmallSize &&
"Expected NumOps to be larger than allocation");
635 LargeStorageVector NewOps;
636 NewOps.resize(NumOps);
639 new (getLargePtr()) LargeStorageVector(std::move(NewOps));
644 if (
auto *
N = dyn_cast_or_null<MDNode>(Op))
645 return !
N->isResolved();
649void MDNode::countUnresolvedOperands() {
655void MDNode::makeUniqued() {
661 Op.reset(
Op.get(),
this);
665 countUnresolvedOperands();
667 dropReplaceableUses();
674void MDNode::makeDistinct() {
679 dropReplaceableUses();
691 dropReplaceableUses();
696void MDNode::dropReplaceableUses() {
700 if (
Context.hasReplaceableUses())
701 Context.takeReplaceableUses()->resolveAllUses();
714 decrementUnresolvedOperandCount();
717void MDNode::decrementUnresolvedOperandCount() {
728 dropReplaceableUses();
741 auto *
N = dyn_cast_or_null<MDNode>(Op);
746 "Expected all forward declarations to be resolved");
747 if (!
N->isResolved())
756MDNode *MDNode::replaceWithPermanentImpl() {
760 return replaceWithDistinctImpl();
762#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
765#include "llvm/IR/Metadata.def"
770 return replaceWithDistinctImpl();
771 return replaceWithUniquedImpl();
774MDNode *MDNode::replaceWithUniquedImpl() {
776 MDNode *UniquedNode = uniquify();
778 if (UniquedNode ==
this) {
789MDNode *MDNode::replaceWithDistinctImpl() {
794void MDTuple::recalculateHash() {
795 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
801 if (
Context.hasReplaceableUses()) {
802 Context.getReplaceableUses()->resolveAllUses(
false);
803 (void)
Context.takeReplaceableUses();
807void MDNode::handleChangedOperand(
void *
Ref,
Metadata *New) {
824 if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
835 resolveAfterOperandChange(Old, New);
847 if (
Context.hasReplaceableUses())
857void MDNode::deleteAsSubclass() {
861#define HANDLE_MDNODE_LEAF(CLASS) \
863 delete cast<CLASS>(this); \
865#include "llvm/IR/Metadata.def"
869template <
class T,
class InfoT>
878template <
class NodeTy>
struct MDNode::HasCachedHash {
881 template <
class U, U Val>
struct SFINAE {};
884 static Yes &
check(SFINAE<
void (U::*)(
unsigned), &U::setHash> *);
887 static const bool value =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(
Yes);
890MDNode *MDNode::uniquify() {
897#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
898 case CLASS##Kind: { \
899 CLASS *SubclassThis = cast<CLASS>(this); \
900 std::integral_constant<bool, HasCachedHash<CLASS>::value> \
901 ShouldRecalculateHash; \
902 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
903 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
905#include "llvm/IR/Metadata.def"
909void MDNode::eraseFromStore() {
913#define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
915 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
917#include "llvm/IR/Metadata.def"
922 StorageType Storage,
bool ShouldCreate) {
925 MDTupleInfo::KeyTy
Key(MDs);
930 Hash =
Key.getHash();
932 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
941 assert(
N->isTemporary() &&
"Expected temporary node");
942 N->replaceAllUsesWith(
nullptr);
943 N->deleteAsSubclass();
947 assert(!
Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
956#define HANDLE_MDNODE_LEAF(CLASS) \
957 case CLASS##Kind: { \
958 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \
959 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
962#include "llvm/IR/Metadata.def"
994 if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
995 if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
996 for (
unsigned I = 1,
E = Ops.
size();
I !=
E; ++
I)
997 if (Ops[
I] !=
N->getOperand(
I))
1012 MDs.
insert(
B->op_begin(),
B->op_end());
1042 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
1047 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
1055 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
1060 return MDs.
empty() ? nullptr
1068 APFloat AVal = mdconst::extract<ConstantFP>(
A->getOperand(0))->getValueAPF();
1069 APFloat BVal = mdconst::extract<ConstantFP>(
B->getOperand(0))->getValueAPF();
1076 return A.getUpper() ==
B.getLower() ||
A.getLower() ==
B.getUpper();
1087 APInt LB = EndPoints[
Size - 2]->getValue();
1088 APInt LE = EndPoints[
Size - 1]->getValue();
1093 EndPoints[
Size - 2] =
1095 EndPoints[
Size - 1] =
1104 if (!EndPoints.
empty())
1128 int AN =
A->getNumOperands() / 2;
1129 int BN =
B->getNumOperands() / 2;
1130 while (AI < AN && BI < BN) {
1131 ConstantInt *ALow = mdconst::extract<ConstantInt>(
A->getOperand(2 * AI));
1132 ConstantInt *BLow = mdconst::extract<ConstantInt>(
B->getOperand(2 * BI));
1136 mdconst::extract<ConstantInt>(
A->getOperand(2 * AI + 1)));
1140 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1145 addRange(EndPoints, mdconst::extract<ConstantInt>(
A->getOperand(2 * AI)),
1146 mdconst::extract<ConstantInt>(
A->getOperand(2 * AI + 1)));
1150 addRange(EndPoints, mdconst::extract<ConstantInt>(
B->getOperand(2 * BI)),
1151 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1162 for (
unsigned i = 0; i <
Size - 2; ++i) {
1163 EndPoints[i] = EndPoints[i + 2];
1171 if (EndPoints.
size() == 2) {
1172 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());
1173 if (Range.isFullSet())
1179 for (
auto *
I : EndPoints)
1188 ConstantInt *AVal = mdconst::extract<ConstantInt>(
A->getOperand(0));
1189 ConstantInt *BVal = mdconst::extract<ConstantInt>(
B->getOperand(0));
1203NamedMDNode::NamedMDNode(
const Twine &
N)
1212 return (
unsigned)
getNMDOps(Operands).size();
1218 return cast_or_null<MDNode>(
N);
1239 for (
const auto &
A : Attachments)
1246 for (
const auto &
A : Attachments)
1248 Result.push_back(
A.Node);
1253 for (
const auto &
A : Attachments)
1254 Result.emplace_back(
A.MDKind,
A.Node);
1258 if (Result.size() > 1)
1277 if (Attachments.size() == 1 && Attachments.back().MDKind ==
ID) {
1278 Attachments.pop_back();
1282 auto OldSize = Attachments.size();
1285 return OldSize != Attachments.size();
1292 assert(!
Info.empty() &&
"bit out of sync with hash table");
1293 return Info.lookup(KindID);
1300 assert(!
Info.empty() &&
"bit out of sync with hash table");
1318 "bit out of sync with hash table");
1320 assert(!
Info.empty() &&
"Shouldn't have called this");
1326 assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1334 Info.set(KindID, Node);
1340 "bit out of sync with hash table");
1360 assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1376 bool Changed = Store.erase(KindID);
1386 "bit out of sync with hash table");
1398 return getMetadataImpl(
getContext().getMDKindID(Kind));
1409 KnownSet.
insert(LLVMContext::MD_DIAssignID);
1412 auto &
Info = MetadataStore[
this];
1413 assert(!
Info.empty() &&
"bit out of sync with hash table");
1415 return !KnownSet.
count(
I.MDKind);
1424void Instruction::updateDIAssignIDMapping(
DIAssignID *
ID) {
1427 cast_or_null<DIAssignID>(
getMetadata(LLVMContext::MD_DIAssignID))) {
1429 if (
ID == CurrentID)
1433 auto InstrsIt = IDToInstrs.find(CurrentID);
1434 assert(InstrsIt != IDToInstrs.end() &&
1435 "Expect existing attachment to be mapped");
1437 auto &InstVec = InstrsIt->second;
1438 auto *InstIt = std::find(InstVec.begin(), InstVec.end(),
this);
1439 assert(InstIt != InstVec.end() &&
1440 "Expect instruction to be mapped to attachment");
1444 if (InstVec.size() == 1)
1445 IDToInstrs.erase(InstrsIt);
1447 InstVec.erase(InstIt);
1452 IDToInstrs[
ID].push_back(
this);
1460 if (KindID == LLVMContext::MD_dbg) {
1466 if (KindID == LLVMContext::MD_DIAssignID) {
1470 assert((!Node || !Node->isTemporary()) &&
1471 "Temporary DIAssignIDs are invalid");
1472 updateDIAssignIDMapping(cast_or_null<DIAssignID>(Node));
1481 auto *Existing =
getMetadata(LLVMContext::MD_annotation);
1483 bool AppendName =
true;
1485 auto *Tuple = cast<MDTuple>(Existing);
1486 for (
auto &
N : Tuple->operands()) {
1487 if (cast<MDString>(
N.get())->getString() ==
Name)
1505 Result.TBAA =
Info.lookup(LLVMContext::MD_tbaa);
1506 Result.TBAAStruct =
Info.lookup(LLVMContext::MD_tbaa_struct);
1507 Result.Scope =
Info.lookup(LLVMContext::MD_alias_scope);
1508 Result.NoAlias =
Info.lookup(LLVMContext::MD_noalias);
1515 setMetadata(LLVMContext::MD_tbaa_struct,
N.TBAAStruct);
1520MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
1522 if (KindID == LLVMContext::MD_dbg)
1527void Instruction::getAllMetadataImpl(
1534 std::make_pair((
unsigned)LLVMContext::MD_dbg, DbgLoc.
getAsMDNode()));
1543 getOpcode() == Instruction::IndirectBr ||
1545 "Looking for branch weights on something besides branch");
1547 return ::extractProfTotalWeight(*
this, TotalVal);
1552 Other->getAllMetadata(MDs);
1553 for (
auto &MD : MDs) {
1555 if (
Offset != 0 && MD.first == LLVMContext::MD_type) {
1556 auto *OffsetConst = cast<ConstantInt>(
1557 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1558 Metadata *TypeId = MD.second->getOperand(1);
1560 OffsetConst->getType(), OffsetConst->getValue() +
Offset));
1568 auto *Attachment = MD.second;
1569 if (
Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1573 auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1574 GV = GVE->getVariable();
1575 E = GVE->getExpression();
1579 OrigElements =
E->getElements();
1580 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1581 Elements[0] = dwarf::DW_OP_plus_uconst;
1583 llvm::copy(OrigElements, Elements.begin() + 2);
1593 LLVMContext::MD_type,
1613 cast<ConstantAsMetadata>(MD->getOperand(0))->getValue())
1615 assert(Val <= 2 &&
"unknown vcall visibility!");
1626 return cast_or_null<DISubprogram>(
getMetadata(LLVMContext::MD_dbg));
1632 return CU->getDebugInfoForProfiling();
1647 GVs.
push_back(cast<DIGlobalVariableExpression>(MD));
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...
SmallPtrSet< MachineInstr *, 2 > Uses
static const Function * getParent(const Value *V)
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Given that RA is a live value
This file defines the DenseSet and SmallDenseSet classes.
mir Rename Register Operands
Module.h This file contains the declarations for the Module class.
return ToRemove size() > 0
This file contains the declarations for profiling metadata utility functions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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 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...
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
LLVM Basic Block Representation.
This is the shared class of boolean and integer constants.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
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 range of values.
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.
MDNode * getAsMDNode() const
Return this as a bar MDNode.
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.
void addTypeMetadata(unsigned Offset, Metadata *TypeID)
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
VCallVisibility getVCallVisibility() const
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
void setVCallVisibilityMetadata(VCallVisibility Visibility)
void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const
Fill the vector with all debug info attachements.
void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
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.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void dropUnknownNonDebugMetadata()
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
StringMap< MDString, BumpPtrAllocator > MDStringCache
DenseMap< DIAssignID *, SmallVector< Instruction *, 1 > > AssignmentIDToInstrs
Map DIAssignID -> Instructions with that attachment.
std::vector< MDNode * > DistinctMDNodes
DenseMap< const Value *, MDAttachments > ValueMetadata
Collection of metadata used in this context.
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
This is an important class for using LLVM in a threaded context.
LLVMContextImpl *const pImpl
void insert(unsigned ID, MDNode &MD)
Adds an attachment to a particular node.
void get(unsigned ID, SmallVectorImpl< MDNode * > &Result) const
Appends all attachments with the given ID to Result in insertion order.
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * > > &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
void set(unsigned ID, MDNode *MD)
Set an attachment to a particular node.
MDNode * lookup(unsigned ID) const
Returns the first attachment with the given ID or nullptr if no such attachment exists.
bool erase(unsigned ID)
Remove attachments with the given ID.
MDString * createString(StringRef Str)
Return the given string as metadata.
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
void resolveCycles()
Resolve cycles.
mutable_op_range mutable_operands()
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
void resolve()
Resolve a unique, unresolved node.
const MDOperand & getOperand(unsigned I) const
void storeDistinctInContext()
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
void setNumUnresolved(unsigned N)
unsigned getNumOperands() const
Return number of MDNode operands.
MDOperand * mutable_begin()
TempMDNode clone() const
Create a (temporary) clone of this.
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
void setOperand(unsigned I, Metadata *New)
Set an operand.
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2=std::nullopt)
bool isResolved() const
Check if node is fully resolved.
op_iterator op_begin() const
static MDNode * intersect(MDNode *A, MDNode *B)
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
LLVMContext & getContext() const
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
unsigned getNumUnresolved() const
Tracking metadata reference owned by Metadata.
StringRef getString() const
static 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.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
void setOperand(unsigned I, MDNode *New)
StringRef getName() const
void dropAllReferences()
Remove all uses and clear node vector.
void eraseFromParent()
Drop all references and remove the node from parent module.
MDNode * getOperand(unsigned i) const
unsigned getNumOperands() const
void clearOperands()
Drop all references to this node's operands.
Module * getParent()
Get the module that holds this named metadata collection.
void addOperand(MDNode *M)
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
T get() const
Returns the value of the specified pointer type.
bool is() const
Test if the Union currently holds the type matching T.
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
ArrayRef< T > getArrayRef() const
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
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.
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.
StringRef - Represent a constant reference to a string, i.e.
Tracking metadata reference.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static Type * getMetadataTy(LLVMContext &C)
TypeID
Definitions of all of the base types for the Type system.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt64Ty(LLVMContext &C)
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasMetadata() const
Return true if this value has any metadata attached to it.
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
LLVMContext & getContext() const
All values hold a context through their type.
void clearMetadata()
Erase all metadata attached to this Value.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
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.
void stable_sort(R &&Range)
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
void sort(IteratorTy Start, IteratorTy End)
@ Ref
The access may reference the value stored in memory.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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...
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
static Yes & check(SFINAE< void(U::*)(unsigned), &U::setHash > *)
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Function object to check whether the first component of a std::pair compares less than the first comp...
Function object to check whether the second component of a std::pair compares less than the second co...