32 :
Value(Ty, MetadataAsValueVal), MD(MD) {
36 MetadataAsValue::~MetadataAsValue() {
60 if (!
N ||
N->getNumOperands() != 1)
63 if (!
N->getOperand(0))
67 if (
auto *
C = dyn_cast<ConstantAsMetadata>(
N->getOperand(0)))
86 return Store.lookup(MD);
89 void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
95 Store.erase(this->MD);
100 auto *&Entry =
Store[MD];
112 void MetadataAsValue::track() {
117 void MetadataAsValue::untrack() {
123 assert(Ref &&
"Expected live reference");
124 assert((Owner || *static_cast<Metadata **>(Ref) == &MD) &&
125 "Reference without owner must be direct");
126 if (
auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {
127 R->addRef(Ref, Owner);
130 if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD)) {
131 assert(!PH->Use &&
"Placeholders can only be used once");
132 assert(!Owner &&
"Unexpected callback to owner");
133 PH->Use =
static_cast<Metadata **
>(Ref);
140 assert(Ref &&
"Expected live reference");
141 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD))
143 else if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD))
148 assert(Ref &&
"Expected live reference");
149 assert(New &&
"Expected live reference");
150 assert(Ref != New &&
"Expected change");
151 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {
152 R->moveRef(Ref, New, MD);
155 assert(!isa<DistinctMDOperandPlaceholder>(MD) &&
156 "Unexpected move of an MDOperand");
158 "Expected un-replaceable metadata, since we didn't move a reference");
163 return ReplaceableMetadataImpl::isReplaceable(MD);
166 void ReplaceableMetadataImpl::addRef(
void *Ref, OwnerTy Owner) {
168 UseMap.insert(std::make_pair(Ref, std::make_pair(Owner, NextIndex)))
171 assert(WasInserted &&
"Expected to add a reference");
174 assert(NextIndex != 0 &&
"Unexpected overflow");
177 void ReplaceableMetadataImpl::dropRef(
void *Ref) {
178 bool WasErased = UseMap.erase(Ref);
180 assert(WasErased &&
"Expected to drop a reference");
183 void ReplaceableMetadataImpl::moveRef(
void *Ref,
void *New,
185 auto I = UseMap.find(Ref);
186 assert(
I != UseMap.end() &&
"Expected to move a reference");
187 auto OwnerAndIndex =
I->second;
189 bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;
191 assert(WasInserted &&
"Expected to add a reference");
195 assert((OwnerAndIndex.first || *static_cast<Metadata **>(Ref) == &MD) &&
196 "Reference without owner must be direct");
197 assert((OwnerAndIndex.first || *static_cast<Metadata **>(New) == &MD) &&
198 "Reference without owner must be direct");
206 typedef std::pair<void *, std::pair<OwnerTy, uint64_t>> UseTy;
208 std::sort(Uses.begin(), Uses.end(), [](
const UseTy &
L,
const UseTy &R) {
209 return L.second.second < R.second.second;
211 for (
const auto &Pair : Uses) {
214 if (!UseMap.count(Pair.first))
217 OwnerTy Owner = Pair.second.first;
224 UseMap.erase(Pair.first);
237 #define HANDLE_METADATA_LEAF(CLASS) \
238 case Metadata::CLASS##Kind: \
239 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
241 #include "llvm/IR/Metadata.def"
246 assert(UseMap.empty() &&
"Expected all uses to be replaced");
259 typedef std::pair<void *, std::pair<OwnerTy, uint64_t>> UseTy;
261 std::sort(Uses.begin(), Uses.end(), [](
const UseTy &
L,
const UseTy &R) {
262 return L.second.second < R.second.second;
265 for (
const auto &Pair : Uses) {
266 auto Owner = Pair.second.first;
276 if (OwnerMD->isResolved())
278 OwnerMD->decrementUnresolvedOperandCount();
283 if (
auto *
N = dyn_cast<MDNode>(&MD))
284 return N->isResolved() ?
nullptr :
N->Context.getOrCreateReplaceableUses();
289 if (
auto *
N = dyn_cast<MDNode>(&MD))
290 return N->isResolved() ?
nullptr :
N->Context.getReplaceableUses();
294 bool ReplaceableMetadataImpl::isReplaceable(
const Metadata &MD) {
295 if (
auto *
N = dyn_cast<MDNode>(&MD))
296 return !
N->isResolved();
301 assert(V &&
"Expected value");
302 if (
auto *
A = dyn_cast<Argument>(V))
303 return A->getParent();
305 return BB->getParent();
310 assert(V &&
"Unexpected null Value");
315 assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
316 "Expected constant or function-local value");
319 if (
auto *
C = dyn_cast<Constant>(V))
329 assert(V &&
"Unexpected null Value");
334 assert(V &&
"Expected valid value");
343 assert(MD &&
"Expected valid metadata");
353 assert(From &&
"Expected valid value");
354 assert(To &&
"Expected valid value");
355 assert(From != To &&
"Expected changed value");
359 auto &
Store = Context.pImpl->ValuesAsMetadata;
360 auto I =
Store.find(From);
370 assert(MD &&
"Expected valid metadata");
374 if (isa<LocalAsMetadata>(MD)) {
375 if (
auto *
C = dyn_cast<Constant>(To)) {
388 }
else if (!isa<Constant>(To)) {
395 auto *&Entry =
Store[To];
416 auto I =
Store.try_emplace(Str);
417 auto &MapEntry =
I.first->getValue();
420 MapEntry.Entry = &*
I.first;
425 assert(Entry &&
"Expected to find string map entry");
426 return Entry->first();
435 #define HANDLE_MDNODE_LEAF(CLASS) \
437 alignof(uint64_t) >= alignof(CLASS), \
438 "Alignment is insufficient after objects prepended to " #CLASS);
439 #include "llvm/IR/Metadata.def"
441 void *MDNode::operator
new(
size_t Size,
unsigned NumOps) {
442 size_t OpSize = NumOps *
sizeof(
MDOperand);
445 OpSize =
alignTo(OpSize,
alignof(uint64_t));
446 void *
Ptr =
reinterpret_cast<char *
>(::operator
new(OpSize + Size)) + OpSize;
453 void MDNode::operator
delete(
void *Mem) {
455 size_t OpSize = N->NumOperands *
sizeof(
MDOperand);
456 OpSize =
alignTo(OpSize,
alignof(uint64_t));
459 for (
MDOperand *
E = O - N->NumOperands; O !=
E; --O)
461 ::operator
delete(
reinterpret_cast<char *
>(Mem) - OpSize);
466 :
Metadata(ID, Storage), NumOperands(Ops1.size() + Ops2.size()),
467 NumUnresolved(0), Context(Context) {
479 countUnresolvedOperands();
486 #define HANDLE_MDNODE_LEAF(CLASS) \
488 return cast<CLASS>(this)->cloneImpl();
489 #include "llvm/IR/Metadata.def"
494 if (
auto *
N = dyn_cast_or_null<MDNode>(Op))
495 return !
N->isResolved();
499 void MDNode::countUnresolvedOperands() {
500 assert(NumUnresolved == 0 &&
"Expected unresolved ops to be uncounted");
505 void MDNode::makeUniqued() {
511 Op.reset(
Op.get(),
this);
515 countUnresolvedOperands();
516 if (!NumUnresolved) {
517 dropReplaceableUses();
524 void MDNode::makeDistinct() {
529 dropReplaceableUses();
536 void MDNode::resolve() {
541 dropReplaceableUses();
546 void MDNode::dropReplaceableUses() {
547 assert(!NumUnresolved &&
"Unexpected unresolved operand");
550 if (Context.hasReplaceableUses())
551 Context.takeReplaceableUses()->resolveAllUses();
556 assert(NumUnresolved != 0 &&
"Expected unresolved operands");
564 decrementUnresolvedOperandCount();
567 void MDNode::decrementUnresolvedOperandCount() {
577 dropReplaceableUses();
590 auto *
N = dyn_cast_or_null<MDNode>(
Op);
595 "Expected all forward declarations to be resolved");
596 if (!
N->isResolved())
608 MDNode *MDNode::replaceWithPermanentImpl() {
612 return replaceWithDistinctImpl();
614 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
617 #include "llvm/IR/Metadata.def"
622 return replaceWithDistinctImpl();
623 return replaceWithUniquedImpl();
626 MDNode *MDNode::replaceWithUniquedImpl() {
628 MDNode *UniquedNode = uniquify();
630 if (UniquedNode ==
this) {
641 MDNode *MDNode::replaceWithDistinctImpl() {
646 void MDTuple::recalculateHash() {
647 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
651 for (
unsigned I = 0,
E = NumOperands;
I !=
E; ++
I)
653 if (Context.hasReplaceableUses()) {
654 Context.getReplaceableUses()->resolveAllUses(
false);
655 (void)Context.takeReplaceableUses();
659 void MDNode::handleChangedOperand(
void *Ref,
Metadata *New) {
676 if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
687 resolveAfterOperandChange(Old, New);
699 if (Context.hasReplaceableUses())
700 Context.getReplaceableUses()->replaceAllUsesWith(
Uniqued);
709 void MDNode::deleteAsSubclass() {
713 #define HANDLE_MDNODE_LEAF(CLASS) \
715 delete cast<CLASS>(this); \
717 #include "llvm/IR/Metadata.def"
721 template <
class T,
class InfoT>
730 template <
class NodeTy>
struct MDNode::HasCachedHash {
733 template <
class U, U Val>
struct SFINAE {};
736 static Yes &check(
SFINAE<
void (U::*)(
unsigned), &U::setHash> *);
737 template <
class U>
static No &check(...);
739 static const bool value =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(Yes);
742 MDNode *MDNode::uniquify() {
749 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
750 case CLASS##Kind: { \
751 CLASS *SubclassThis = cast<CLASS>(this); \
752 std::integral_constant<bool, HasCachedHash<CLASS>::value> \
753 ShouldRecalculateHash; \
754 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
755 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
757 #include "llvm/IR/Metadata.def"
761 void MDNode::eraseFromStore() {
765 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
767 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
769 #include "llvm/IR/Metadata.def"
774 StorageType Storage,
bool ShouldCreate) {
777 MDTupleInfo::KeyTy Key(MDs);
782 Hash = Key.getHash();
784 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
794 N->deleteAsSubclass();
798 assert(!Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
799 assert(!NumUnresolved &&
"Unexpected unresolved nodes");
807 #define HANDLE_MDNODE_LEAF(CLASS) \
808 case CLASS##Kind: { \
809 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \
810 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
813 #include "llvm/IR/Metadata.def"
845 if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
846 if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
847 for (
unsigned I = 1,
E = Ops.
size();
I !=
E; ++
I)
848 if (Ops[
I] !=
N->getOperand(
I))
912 unsigned Size = EndPoints.
size();
913 APInt LB = EndPoints[Size - 2]->getValue();
914 APInt LE = EndPoints[Size - 1]->getValue();
919 EndPoints[Size - 2] =
921 EndPoints[Size - 1] =
930 if (!EndPoints.
empty())
956 while (AI < AN && BI < BN) {
962 mdconst::extract<ConstantInt>(A->
getOperand(2 * AI + 1)));
966 mdconst::extract<ConstantInt>(B->
getOperand(2 * BI + 1)));
972 mdconst::extract<ConstantInt>(A->
getOperand(2 * AI + 1)));
977 mdconst::extract<ConstantInt>(B->
getOperand(2 * BI + 1)));
983 unsigned Size = EndPoints.
size();
988 for (
unsigned i = 0;
i < Size - 2; ++
i) {
989 EndPoints[
i] = EndPoints[
i + 2];
991 EndPoints.
resize(Size - 2);
997 if (EndPoints.
size() == 2) {
998 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());
1005 for (
auto *
I : EndPoints)
1029 NamedMDNode::NamedMDNode(
const Twine &
N)
1030 :
Name(N.str()), Parent(nullptr),
1033 NamedMDNode::~NamedMDNode() {
1039 return (
unsigned)
getNMDOps(Operands).size();
1045 return cast_or_null<MDNode>(
N);
1065 for (
auto &
I : Attachments)
1066 if (
I.first == ID) {
1067 I.second.reset(&MD);
1070 Attachments.emplace_back(std::piecewise_construct, std::make_tuple(ID),
1071 std::make_tuple(&MD));
1079 if (Attachments.back().first ==
ID) {
1080 Attachments.pop_back();
1084 for (
auto I = Attachments.begin(),
E = std::prev(Attachments.end());
I !=
E;
1086 if (
I->first == ID) {
1087 *
I = std::move(Attachments.back());
1088 Attachments.pop_back();
1094 for (
const auto &
I : Attachments)
1102 Result.append(Attachments.begin(), Attachments.end());
1105 if (Result.size() > 1)
1115 for (
auto A : Attachments)
1121 auto Follower = Attachments.
begin();
1122 for (
auto Leader = Attachments.
begin(),
E = Attachments.
end(); Leader !=
E;
1124 if (Leader->MDKind != ID) {
1125 if (Follower != Leader)
1126 *Follower = std::move(*Leader);
1130 Attachments.
resize(Follower - Attachments.
begin());
1135 for (
auto &
A : Attachments)
1136 Result.emplace_back(
A.MDKind,
A.Node);
1141 Result.begin(), Result.end(),
1142 [](
const std::pair<unsigned, MDNode *> &
A,
1143 const std::pair<unsigned, MDNode *> &
B) {
return A.first <
B.first; });
1153 return getMetadataImpl(
getContext().getMDKindID(Kind));
1157 if (!hasMetadataHashEntry())
1164 if (KnownSet.
empty()) {
1166 InstructionMetadata.erase(
this);
1167 setHasMetadataHashEntry(
false);
1171 auto &Info = InstructionMetadata[
this];
1172 Info.remove_if([&KnownSet](
const std::pair<unsigned, TrackingMDNodeRef> &
I) {
1173 return !KnownSet.
count(I.first);
1178 InstructionMetadata.erase(
this);
1179 setHasMetadataHashEntry(
false);
1196 assert(!Info.empty() == hasMetadataHashEntry() &&
1197 "HasMetadata bit is wonked");
1199 setHasMetadataHashEntry(
true);
1200 Info.set(KindID, *Node);
1205 assert((hasMetadataHashEntry() ==
1206 (
getContext().pImpl->InstructionMetadata.count(
this) > 0)) &&
1207 "HasMetadata bit out of date!");
1208 if (!hasMetadataHashEntry())
1219 setHasMetadataHashEntry(
false);
1228 MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
1233 if (!hasMetadataHashEntry())
1236 assert(!Info.empty() &&
"bit out of sync with hash table");
1238 return Info.lookup(KindID);
1241 void Instruction::getAllMetadataImpl(
1249 if (!hasMetadataHashEntry())
1253 assert(hasMetadataHashEntry() &&
1254 getContext().pImpl->InstructionMetadata.count(
this) &&
1255 "Shouldn't have called this");
1257 assert(!Info.empty() &&
"Shouldn't have called this");
1258 Info.getAll(Result);
1261 void Instruction::getAllMetadataOtherThanDebugLocImpl(
1264 assert(hasMetadataHashEntry() &&
1265 getContext().pImpl->InstructionMetadata.count(
this) &&
1266 "Shouldn't have called this");
1268 assert(!Info.empty() &&
"Shouldn't have called this");
1269 Info.getAll(Result);
1273 uint64_t &FalseVal)
const {
1276 "Looking for branch weights on something besides branch or select");
1279 if (!ProfileData || ProfileData->getNumOperands() != 3)
1283 if (!ProfDataName || !ProfDataName->getString().equals(
"branch_weights"))
1286 auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
1287 auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
1288 if (!CITrue || !CIFalse)
1291 TrueVal = CITrue->getValue().getZExtValue();
1292 FalseVal = CIFalse->getValue().getZExtValue();
1303 "Looking for branch weights on something besides branch");
1311 if (!ProfDataName || !ProfDataName->getString().equals(
"branch_weights"))
1315 for (
unsigned i = 1;
i < ProfileData->getNumOperands();
i++) {
1316 auto *V = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(
i));
1319 TotalVal += V->getValue().getZExtValue();
1324 void Instruction::clearMetadataHashEntries() {
1325 assert(hasMetadataHashEntry() &&
"Caller should check");
1327 setHasMetadataHashEntry(
false);
1344 setHasMetadataHashEntry(
true);
1359 Store.erase(KindID);
1378 setHasMetadataHashEntry(
false);
1394 assert(MDs.
size() <= 1 &&
"Expected at most one metadata attachment");
1407 for (
auto &MD : MDs) {
1410 auto *OffsetConst = cast<ConstantInt>(
1411 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1412 Metadata *TypeId = MD.second->getOperand(1);
1414 OffsetConst->getType(), OffsetConst->getValue() +
Offset));
1422 auto *Attachment = MD.second;
1423 if (Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1427 auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1428 GV = GVE->getVariable();
1429 E = GVE->getExpression();
1433 OrigElements = E->getElements();
1434 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1435 Elements[0] = dwarf::DW_OP_plus;
1437 std::copy(OrigElements.
begin(), OrigElements.
end(), Elements.begin() + 2);
1459 return cast_or_null<DISubprogram>(
getMetadata(LLVMContext::MD_dbg));
1471 GVs.
push_back(cast<DIGlobalVariableExpression>(MD));
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Appends all attachments for the global to MDs, sorting by attachment ID.
void dropAllReferences()
Remove all uses and clear node vector.
StringRef getName() const
void push_back(const T &Elt)
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
Tracking metadata reference owned by Metadata.
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
StringMap< MDString, BumpPtrAllocator > MDStringCache
MDNode * Scope
The tag for alias scope specification (used with noalias).
MDNode * TBAA
The tag for type-based alias analysis.
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
Tracking metadata reference.
static MDString * get(LLVMContext &Context, StringRef Str)
void clearOperands()
Drop all references to this node's operands.
void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const
Fill the vector with all debug info attachements.
Implements a dense probed hash-table based set.
unsigned getNumOperands() const
Return number of MDNode operands.
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
void addOperand(MDNode *M)
void storeDistinctInContext()
op_iterator op_begin() const
uint64_t alignTo(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the next integer (mod 2**64) that is greater than or equal to Value and is a multiple of Alig...
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
static IntegerType * getInt64Ty(LLVMContext &C)
void get(unsigned ID, SmallVectorImpl< MDNode * > &Result)
Appends all attachments with the given ID to Result in insertion order.
void setOperand(unsigned I, Metadata *New)
Set an operand.
static Type * getMetadataTy(LLVMContext &C)
void reserve(size_type N)
void setOperand(unsigned I, MDNode *New)
op_iterator op_end() const
void set(unsigned ID, MDNode &MD)
Set an attachment to a particular node.
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
LLVM_NODISCARD bool empty() const
DenseMap< const Instruction *, MDAttachmentMap > InstructionMetadata
Collection of per-instruction metadata used in this context.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const APInt & getValue() const
Return the constant as an APInt value reference.
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
void eraseFromParent()
Drop all references and remove the node from parent module.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
TypeID
Definitions of all of the base types for the Type system.
std::vector< MDNode * > DistinctMDNodes
void resolveCycles()
Resolve cycles.
LLVM_NODISCARD bool empty() const
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
void dropUnknownNonDebugMetadata()
ConstantRange unionWith(const ConstantRange &CR) const
Return the range that results from the union of this range with another range.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
static MDNode * intersect(MDNode *A, MDNode *B)
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * >> &Result) const
Copy out all the attachments.
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)
bool hasMetadata() const
Check if this has any metadata.
ConstantRange intersectWith(const ConstantRange &CR) const
Return the range that results from the intersection of this range with another range.
void addTypeMetadata(unsigned Offset, Metadata *TypeID)
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
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.
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< iterator, bool > insert(const ValueT &V)
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
bool extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) const
Retrieve the raw weight values of a conditional branch or select.
A pair of DIGlobalVariable and DIExpression.
MDNode * getOperand(unsigned i) const
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
bool empty() const
empty - Check if the array is empty.
bool isEmptySet() const
Return true if this set contains no members.
TempMDNode clone() const
Create a (temporary) clone of this.
LLVMContext & getContext() const
All values hold a context through their type.
#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
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
StringRef getString() const
DenseMap< const GlobalObject *, MDGlobalAttachmentMap > GlobalObjectMetadata
Collection of per-GlobalObject metadata used in this context.
const MDOperand & getOperand(unsigned I) const
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.
bool slt(const APInt &RHS) const
Signed less than comparison.
T get() const
Returns the value of the specified pointer type.
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.
Type * getType() const
All values are typed, get the type of this value.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
MDNode * lookup(unsigned ID) const
Get a particular attachment (if any).
This class represents a range of values.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
const APInt & getLower() const
Return the lower value for this range.
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.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Class for arbitrary precision integers.
void erase(unsigned ID)
Remove an attachment.
void insert(unsigned ID, MDNode &MD)
DISubprogram * getSubprogram() const
Get the attached subprogram.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
void setMetadata(unsigned KindID, MDNode *MD)
Set a particular kind of metadata attachment.
MDNode * getAsMDNode() const
Return this as a bar MDNode.
MDOperand * mutable_begin()
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2=None)
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
op_range operands() const
LLVMContext & getContext() const
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
const APInt & getUpper() const
Return the upper value for this range.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * >> &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
void eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
LLVM Value Representation.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
static const Function * getParent(const Value *V)
unsigned getNumOperands() const
cmpResult compare(const APFloat &RHS) const
void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
std::string Hash(const Unit &U)
StringRef - Represent a constant reference to a string, i.e.
int is() const
Test if the Union currently holds the type matching T.
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
bool isResolved() const
Check if node is fully resolved.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
auto count_if(R &&Range, UnaryPredicate P) -> typename std::iterator_traits< decltype(std::begin(Range))>::difference_type
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
Module * getParent()
Get the module that holds this named metadata collection.
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.