56 #include <type_traits> 63 :
Value(Ty, MetadataAsValueVal), MD(MD) {
68 getType()->getContext().pImpl->MetadataAsValues.erase(MD);
91 if (!
N ||
N->getNumOperands() != 1)
94 if (!
N->getOperand(0))
98 if (
auto *
C = dyn_cast<ConstantAsMetadata>(
N->getOperand(0)))
117 return Store.lookup(MD);
120 void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
126 Store.erase(this->MD);
133 replaceAllUsesWith(
Entry);
143 void MetadataAsValue::track() {
148 void MetadataAsValue::untrack() {
154 assert(
Ref &&
"Expected live reference");
155 assert((Owner || *static_cast<Metadata **>(
Ref) == &MD) &&
156 "Reference without owner must be direct");
157 if (
auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {
158 R->addRef(
Ref, Owner);
161 if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD)) {
162 assert(!PH->Use &&
"Placeholders can only be used once");
163 assert(!Owner &&
"Unexpected callback to owner");
171 assert(Ref &&
"Expected live reference");
172 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD))
174 else if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD))
179 assert(Ref &&
"Expected live reference");
180 assert(New &&
"Expected live reference");
181 assert(Ref != New &&
"Expected change");
182 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {
183 R->moveRef(Ref, New, MD);
186 assert(!isa<DistinctMDOperandPlaceholder>(MD) &&
187 "Unexpected move of an MDOperand");
188 assert(!isReplaceable(MD) &&
189 "Expected un-replaceable metadata, since we didn't move a reference");
194 return ReplaceableMetadataImpl::isReplaceable(MD);
197 void ReplaceableMetadataImpl::addRef(
void *
Ref,
OwnerTy Owner) {
199 UseMap.insert(std::make_pair(
Ref, std::make_pair(Owner, NextIndex)))
202 assert(WasInserted &&
"Expected to add a reference");
205 assert(NextIndex != 0 &&
"Unexpected overflow");
208 void ReplaceableMetadataImpl::dropRef(
void *
Ref) {
209 bool WasErased = UseMap.erase(Ref);
211 assert(WasErased &&
"Expected to drop a reference");
214 void ReplaceableMetadataImpl::moveRef(
void *
Ref,
void *New,
216 auto I = UseMap.find(
Ref);
217 assert(
I != UseMap.end() &&
"Expected to move a reference");
218 auto OwnerAndIndex =
I->second;
220 bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;
222 assert(WasInserted &&
"Expected to add a reference");
226 assert((OwnerAndIndex.first || *static_cast<Metadata **>(
Ref) == &MD) &&
227 "Reference without owner must be direct");
228 assert((OwnerAndIndex.first || *static_cast<Metadata **>(New) == &MD) &&
229 "Reference without owner must be direct");
237 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
239 llvm::sort(Uses, [](
const UseTy &L,
const UseTy &R) {
240 return L.second.second < R.second.second;
242 for (
const auto &Pair : Uses) {
245 if (!UseMap.count(Pair.first))
248 OwnerTy Owner = Pair.second.first;
255 UseMap.erase(Pair.first);
268 #define HANDLE_METADATA_LEAF(CLASS) \ 269 case Metadata::CLASS##Kind: \ 270 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \ 272 #include "llvm/IR/Metadata.def" 277 assert(UseMap.empty() &&
"Expected all uses to be replaced");
290 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
292 llvm::sort(Uses, [](
const UseTy &L,
const UseTy &R) {
293 return L.second.second < R.second.second;
296 for (
const auto &Pair : Uses) {
297 auto Owner = Pair.second.first;
307 if (OwnerMD->isResolved())
309 OwnerMD->decrementUnresolvedOperandCount();
314 if (
auto *
N = dyn_cast<MDNode>(&MD))
315 return N->isResolved() ? nullptr :
N->Context.getOrCreateReplaceableUses();
320 if (
auto *
N = dyn_cast<MDNode>(&MD))
321 return N->isResolved() ? nullptr :
N->Context.getReplaceableUses();
325 bool ReplaceableMetadataImpl::isReplaceable(
const Metadata &MD) {
326 if (
auto *
N = dyn_cast<MDNode>(&MD))
327 return !
N->isResolved();
332 assert(V &&
"Expected value");
333 if (
auto *A = dyn_cast<Argument>(V)) {
334 if (
auto *Fn = A->getParent())
335 return Fn->getSubprogram();
340 if (
auto *Fn = BB->getParent())
341 return Fn->getSubprogram();
349 assert(V &&
"Unexpected null Value");
354 assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
355 "Expected constant or function-local value");
358 if (
auto *
C = dyn_cast<Constant>(V))
368 assert(V &&
"Unexpected null Value");
373 assert(V &&
"Expected valid value");
382 assert(MD &&
"Expected valid metadata");
392 assert(From &&
"Expected valid value");
393 assert(To &&
"Expected valid value");
394 assert(From != To &&
"Expected changed value");
398 auto &
Store = Context.pImpl->ValuesAsMetadata;
399 auto I =
Store.find(From);
409 assert(MD &&
"Expected valid metadata");
413 if (isa<LocalAsMetadata>(MD)) {
414 if (
auto *
C = dyn_cast<Constant>(To)) {
427 }
else if (!isa<Constant>(To)) {
455 auto I =
Store.try_emplace(Str);
456 auto &MapEntry =
I.first->getValue();
459 MapEntry.Entry = &*
I.first;
464 assert(
Entry &&
"Expected to find string map entry");
465 return Entry->first();
474 #define HANDLE_MDNODE_LEAF(CLASS) \ 476 alignof(uint64_t) >= alignof(CLASS), \ 477 "Alignment is insufficient after objects prepended to " #CLASS); 478 #include "llvm/IR/Metadata.def" 480 void *MDNode::operator
new(
size_t Size,
unsigned NumOps) {
481 size_t OpSize = NumOps *
sizeof(
MDOperand);
484 OpSize =
alignTo(OpSize,
alignof(uint64_t));
485 void *Ptr =
reinterpret_cast<char *
>(::operator
new(OpSize +
Size)) + OpSize;
496 size_t OpSize = N->NumOperands *
sizeof(
MDOperand);
497 OpSize =
alignTo(OpSize,
alignof(uint64_t));
500 for (
MDOperand *
E = O - N->NumOperands; O !=
E; --O)
502 ::operator
delete(
reinterpret_cast<char *
>(Mem) - OpSize);
508 NumUnresolved(0), Context(Context) {
520 countUnresolvedOperands();
527 #define HANDLE_MDNODE_LEAF(CLASS) \ 529 return cast<CLASS>(this)->cloneImpl(); 530 #include "llvm/IR/Metadata.def" 535 if (
auto *
N = dyn_cast_or_null<MDNode>(Op))
536 return !
N->isResolved();
540 void MDNode::countUnresolvedOperands() {
541 assert(NumUnresolved == 0 &&
"Expected unresolved ops to be uncounted");
546 void MDNode::makeUniqued() {
552 Op.reset(
Op.get(),
this);
556 countUnresolvedOperands();
557 if (!NumUnresolved) {
558 dropReplaceableUses();
565 void MDNode::makeDistinct() {
570 dropReplaceableUses();
582 dropReplaceableUses();
587 void MDNode::dropReplaceableUses() {
588 assert(!NumUnresolved &&
"Unexpected unresolved operand");
597 assert(NumUnresolved != 0 &&
"Expected unresolved operands");
605 decrementUnresolvedOperandCount();
608 void MDNode::decrementUnresolvedOperandCount() {
618 dropReplaceableUses();
631 auto *
N = dyn_cast_or_null<MDNode>(
Op);
636 "Expected all forward declarations to be resolved");
637 if (!
N->isResolved())
649 MDNode *MDNode::replaceWithPermanentImpl() {
653 return replaceWithDistinctImpl();
655 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ 658 #include "llvm/IR/Metadata.def" 663 return replaceWithDistinctImpl();
664 return replaceWithUniquedImpl();
667 MDNode *MDNode::replaceWithUniquedImpl() {
669 MDNode *UniquedNode = uniquify();
671 if (UniquedNode ==
this) {
682 MDNode *MDNode::replaceWithDistinctImpl() {
687 void MDTuple::recalculateHash() {
688 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
692 for (
unsigned I = 0,
E = NumOperands;
I !=
E; ++
I)
700 void MDNode::handleChangedOperand(
void *
Ref,
Metadata *New) {
717 if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
728 resolveAfterOperandChange(Old, New);
750 void MDNode::deleteAsSubclass() {
754 #define HANDLE_MDNODE_LEAF(CLASS) \ 756 delete cast<CLASS>(this); \ 758 #include "llvm/IR/Metadata.def" 762 template <
class T,
class InfoT>
771 template <
class NodeTy>
struct MDNode::HasCachedHash {
774 template <
class U, U Val>
struct SFINAE {};
777 static Yes &check(
SFINAE<
void (U::*)(
unsigned), &U::setHash> *);
778 template <
class U>
static No &check(...);
780 static const bool value =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(
Yes);
783 MDNode *MDNode::uniquify() {
790 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ 791 case CLASS##Kind: { \ 792 CLASS *SubclassThis = cast<CLASS>(this); \ 793 std::integral_constant<bool, HasCachedHash<CLASS>::value> \ 794 ShouldRecalculateHash; \ 795 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \ 796 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \ 798 #include "llvm/IR/Metadata.def" 802 void MDNode::eraseFromStore() {
806 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \ 808 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \ 810 #include "llvm/IR/Metadata.def" 818 MDTupleInfo::KeyTy
Key(MDs);
823 Hash = Key.getHash();
825 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
835 N->deleteAsSubclass();
839 assert(!Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
840 assert(!NumUnresolved &&
"Unexpected unresolved nodes");
848 #define HANDLE_MDNODE_LEAF(CLASS) \ 849 case CLASS##Kind: { \ 850 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \ 851 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \ 854 #include "llvm/IR/Metadata.def" 886 if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
887 if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
888 for (
unsigned I = 1,
E = Ops.
size();
I !=
E; ++
I)
889 if (Ops[
I] !=
N->getOperand(
I))
954 APInt LB = EndPoints[Size - 2]->getValue();
955 APInt LE = EndPoints[Size - 1]->getValue();
960 EndPoints[Size - 2] =
962 EndPoints[Size - 1] =
971 if (!EndPoints.
empty())
997 while (AI < AN && BI < BN) {
1003 mdconst::extract<ConstantInt>(A->
getOperand(2 * AI + 1)));
1007 mdconst::extract<ConstantInt>(B->
getOperand(2 * BI + 1)));
1013 mdconst::extract<ConstantInt>(A->
getOperand(2 * AI + 1)));
1018 mdconst::extract<ConstantInt>(B->
getOperand(2 * BI + 1)));
1029 for (
unsigned i = 0; i < Size - 2; ++i) {
1030 EndPoints[i] = EndPoints[i + 2];
1032 EndPoints.
resize(Size - 2);
1038 if (EndPoints.
size() == 2) {
1039 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());
1046 for (
auto *
I : EndPoints)
1070 NamedMDNode::NamedMDNode(
const Twine &
N)
1085 return cast_or_null<MDNode>(
N);
1105 for (
auto &
I : Attachments)
1106 if (
I.first == ID) {
1107 I.second.reset(&MD);
1110 Attachments.emplace_back(std::piecewise_construct, std::make_tuple(ID),
1111 std::make_tuple(&MD));
1119 if (Attachments.back().first ==
ID) {
1120 Attachments.pop_back();
1124 for (
auto I = Attachments.begin(),
E = std::prev(Attachments.end());
I !=
E;
1126 if (
I->first == ID) {
1127 *
I = std::move(Attachments.back());
1128 Attachments.pop_back();
1136 for (
const auto &
I : Attachments)
1144 Result.append(Attachments.begin(), Attachments.end());
1147 if (Result.size() > 1)
1156 for (
const auto &A : Attachments)
1164 for (
const auto &A : Attachments)
1171 [
ID](
const Attachment &A) {
return A.MDKind ==
ID; });
1172 bool Changed =
I != Attachments.end();
1173 Attachments.erase(
I, Attachments.end());
1179 for (
const auto &A : Attachments)
1180 Result.emplace_back(A.MDKind, A.Node);
1188 if (!Node && !hasMetadata())
1194 return getMetadataImpl(
getContext().getMDKindID(Kind));
1198 if (!hasMetadataHashEntry())
1205 if (KnownSet.
empty()) {
1207 InstructionMetadata.erase(
this);
1208 setHasMetadataHashEntry(
false);
1212 auto &
Info = InstructionMetadata[
this];
1213 Info.remove_if([&KnownSet](
const std::pair<unsigned, TrackingMDNodeRef> &
I) {
1214 return !KnownSet.
count(I.first);
1219 InstructionMetadata.erase(
this);
1220 setHasMetadataHashEntry(
false);
1225 if (!Node && !hasMetadata())
1229 if (KindID == LLVMContext::MD_dbg) {
1237 assert(!
Info.empty() == hasMetadataHashEntry() &&
1238 "HasMetadata bit is wonked");
1240 setHasMetadataHashEntry(
true);
1241 Info.set(KindID, *Node);
1246 assert((hasMetadataHashEntry() ==
1247 (
getContext().pImpl->InstructionMetadata.count(
this) > 0)) &&
1248 "HasMetadata bit out of date!");
1249 if (!hasMetadataHashEntry())
1260 setHasMetadataHashEntry(
false);
1270 MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
1272 if (KindID == LLVMContext::MD_dbg)
1273 return DbgLoc.getAsMDNode();
1275 if (!hasMetadataHashEntry())
1278 assert(!
Info.empty() &&
"bit out of sync with hash table");
1280 return Info.lookup(KindID);
1283 void Instruction::getAllMetadataImpl(
1290 std::make_pair((
unsigned)LLVMContext::MD_dbg, DbgLoc.getAsMDNode()));
1291 if (!hasMetadataHashEntry())
1295 assert(hasMetadataHashEntry() &&
1296 getContext().pImpl->InstructionMetadata.count(
this) &&
1297 "Shouldn't have called this");
1299 assert(!Info.empty() &&
"Shouldn't have called this");
1300 Info.getAll(Result);
1303 void Instruction::getAllMetadataOtherThanDebugLocImpl(
1306 assert(hasMetadataHashEntry() &&
1307 getContext().pImpl->InstructionMetadata.count(
this) &&
1308 "Shouldn't have called this");
1310 assert(!Info.empty() &&
"Shouldn't have called this");
1311 Info.getAll(Result);
1315 uint64_t &FalseVal)
const {
1318 "Looking for branch weights on something besides branch or select");
1320 auto *ProfileData = getMetadata(LLVMContext::MD_prof);
1321 if (!ProfileData || ProfileData->getNumOperands() != 3)
1325 if (!ProfDataName || !ProfDataName->getString().equals(
"branch_weights"))
1328 auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
1329 auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
1330 if (!CITrue || !CIFalse)
1333 TrueVal = CITrue->getValue().getZExtValue();
1334 FalseVal = CIFalse->getValue().getZExtValue();
1345 "Looking for branch weights on something besides branch");
1348 auto *ProfileData = getMetadata(LLVMContext::MD_prof);
1356 if (ProfDataName->getString().equals(
"branch_weights")) {
1358 for (
unsigned i = 1; i < ProfileData->getNumOperands(); i++) {
1359 auto *V = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i));
1362 TotalVal += V->getValue().getZExtValue();
1365 }
else if (ProfDataName->getString().equals(
"VP") &&
1366 ProfileData->getNumOperands() > 3) {
1367 TotalVal = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2))
1375 void Instruction::clearMetadataHashEntries() {
1376 assert(hasMetadataHashEntry() &&
"Caller should check");
1378 setHasMetadataHashEntry(
false);
1390 getMetadata(
getContext().getMDKindID(Kind), MDs);
1395 setHasMetadataHashEntry(
true);
1401 addMetadata(
getContext().getMDKindID(Kind), MD);
1410 bool Changed =
Store.erase(KindID);
1430 setHasMetadataHashEntry(
false);
1434 eraseMetadata(KindID);
1436 addMetadata(KindID, *N);
1450 return getMetadata(
getContext().getMDKindID(Kind));
1456 for (
auto &MD : MDs) {
1458 if (Offset != 0 && MD.first == LLVMContext::MD_type) {
1459 auto *OffsetConst = cast<ConstantInt>(
1460 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1461 Metadata *TypeId = MD.second->getOperand(1);
1463 OffsetConst->getType(), OffsetConst->getValue() +
Offset));
1464 addMetadata(LLVMContext::MD_type,
1471 auto *Attachment = MD.second;
1472 if (Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1476 auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1477 GV = GVE->getVariable();
1478 E = GVE->getExpression();
1482 OrigElements = E->getElements();
1483 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1484 Elements[0] = dwarf::DW_OP_plus_uconst;
1490 addMetadata(MD.first, *Attachment);
1496 LLVMContext::MD_type,
1504 addMetadata(LLVMContext::MD_vcall_visibility,
1511 if (
MDNode *MD = getMetadata(LLVMContext::MD_vcall_visibility)) {
1512 uint64_t Val = cast<ConstantInt>(
1513 cast<ConstantAsMetadata>(MD->getOperand(0))->getValue())
1515 assert(Val <= 2 &&
"unknown vcall visibility!");
1518 return VCallVisibility::VCallVisibilityPublic;
1526 return cast_or_null<DISubprogram>(getMetadata(LLVMContext::MD_dbg));
1532 return CU->getDebugInfoForProfiling();
1539 addMetadata(LLVMContext::MD_dbg, *GV);
1545 getMetadata(LLVMContext::MD_dbg, MDs);
1547 GVs.
push_back(cast<DIGlobalVariableExpression>(MD));
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
Tracking metadata reference owned by Metadata.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
StringMap< MDString, BumpPtrAllocator > MDStringCache
MDNode * Scope
The tag for alias scope specification (used with noalias).
MDNode * getOperand(unsigned i) const
This class represents lattice values for constants.
const APInt & getUpper() const
Return the upper value for this range.
MDNode * TBAA
The tag for type-based alias analysis.
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static MDString * get(LLVMContext &Context, StringRef Str)
void clearOperands()
Drop all references to this node's operands.
Implements a dense probed hash-table based set.
std::unique_ptr< ReplaceableMetadataImpl > takeReplaceableUses()
Drop RAUW support.
void push_back(const T &Elt)
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
bool slt(const APInt &RHS) const
Signed less than comparison.
void addOperand(MDNode *M)
void storeDistinctInContext()
LLVMContext & getContext() const
All values hold a context through their type.
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
const MDOperand & getOperand(unsigned I) const
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
static IntegerType * getInt64Ty(LLVMContext &C)
void setOperand(unsigned I, Metadata *New)
Set an operand.
static Type * getMetadataTy(LLVMContext &C)
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode *>> &MDs) const
Appends all attachments for the global to MDs, sorting by attachment ID.
void reserve(size_type N)
void setOperand(unsigned I, MDNode *New)
T get() const
Returns the value of the specified pointer type.
op_iterator op_end() const
VCallVisibility getVCallVisibility() const
TempMDNode clone() const
Create a (temporary) clone of this.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
void set(unsigned ID, MDNode &MD)
Set an attachment to a particular node.
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
DenseMap< const Instruction *, MDAttachmentMap > InstructionMetadata
Collection of per-instruction metadata used in this context.
LLVM_NODISCARD bool empty() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isResolved() const
Check if node is fully resolved.
void eraseFromParent()
Drop all references and remove the node from parent module.
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
The access may reference the value stored in memory.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
TypeID
Definitions of all of the base types for the Type system.
unsigned getNumOperands() const
std::vector< MDNode * > DistinctMDNodes
mir Rename Register Operands
This file implements a class to represent arbitrary precision integral constant values and operations...
void resolveCycles()
Resolve cycles.
op_iterator op_begin() const
Type * getType() const
All values are typed, get the type of this value.
void dropUnknownNonDebugMetadata()
op_range operands() const
ConstantRange intersectWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the intersection of this range with another range.
LLVMContext & getContext() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
static MDNode * intersect(MDNode *A, MDNode *B)
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
MDNode * lookup(unsigned ID) const
Get a particular attachment (if any).
Analysis containing CSE Info
void resolve()
Resolve a unique, unresolved node.
void addVCallVisibilityMetadata(VCallVisibility Visibility)
StringRef getString() const
MDNode * lookup(unsigned ID) const
Returns the first attachment with the given ID or nullptr if no such attachment exists.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
bool isDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
void array_pod_sort(IteratorTy Start, IteratorTy End)
array_pod_sort - This sorts an array with the specified start and end extent.
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void addTypeMetadata(unsigned Offset, Metadata *TypeID)
void setAAMetadata(const AAMDNodes &N)
Sets the metadata on this instruction from the AAMDNodes structure.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
DISubprogram * getSubprogram() const
Get the attached subprogram.
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(const ValueT &V)
void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression *> &GVs) const
Fill the vector with all debug info attachements.
A pair of DIGlobalVariable and DIExpression.
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode *>> &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&... Args)
static wasm::ValType getType(const TargetRegisterClass *RC)
C setMetadata(LLVMContext::MD_range, MDNode::get(Context, LowAndHigh))
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
mutable_op_range mutable_operands()
LLVMContextImpl *const pImpl
void sort(IteratorTy Start, IteratorTy End)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
bool isEmptySet() const
Return true if this set contains no members.
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
bool hasReplaceableUses() const
Whether this contains RAUW support.
DenseMap< const GlobalObject *, MDGlobalAttachmentMap > GlobalObjectMetadata
Collection of per-GlobalObject metadata used in this context.
A SetVector that performs no allocations if smaller than a certain size.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
BlockVerifier::State From
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata *> Ops1, ArrayRef< Metadata *> Ops2=None)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
This class represents a range of values.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MDNode * NoAlias
The tag specifying the noalias scope.
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.
void get(unsigned ID, SmallVectorImpl< MDNode *> &Result) const
Appends all attachments with the given ID to Result in insertion order.
Class for arbitrary precision integers.
void insert(unsigned ID, MDNode &MD)
StringRef getName() const
void setMetadata(unsigned KindID, MDNode *MD)
Set a particular kind of metadata attachment.
MDOperand * mutable_begin()
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode *>> &Result) const
Copy out all the attachments.
LLVM_NODISCARD bool empty() const
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
const APInt & getLower() const
Return the lower value for this range.
int is() const
Test if the Union currently holds the type matching T.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
std::string str() const
Return the twine contents as a std::string.
ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void stable_sort(R &&Range)
LLVM Value Representation.
bool erase(unsigned ID)
Remove an attachment.
static const Function * getParent(const Value *V)
#define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
StringRef - Represent a constant reference to a string, i.e.
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
unsigned getNumOperands() const
Return number of MDNode operands.
bool extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) const
Retrieve the raw weight values of a conditional branch or select.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
MDNode * TBAAStruct
The tag for type-based alias analysis (tbaa struct).
OutputIt copy(R &&Range, OutputIt Out)
ReplaceableMetadataImpl * getReplaceableUses() const
Function object to check whether the first component of a std::pair compares less than the first comp...
bool empty() const
empty - Check if the array is empty.
cmpResult compare(const APFloat &RHS) const
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.