57 #include <type_traits>
64 :
Value(Ty, MetadataAsValueVal), MD(MD) {
92 if (!
N ||
N->getNumOperands() != 1)
95 if (!
N->getOperand(0))
99 if (
auto *
C = dyn_cast<ConstantAsMetadata>(
N->getOperand(0)))
118 return Store.lookup(MD);
121 void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
127 Store.erase(this->MD);
132 auto *&Entry =
Store[MD];
144 void MetadataAsValue::track() {
149 void MetadataAsValue::untrack() {
155 assert(Ref &&
"Expected live reference");
156 assert((Owner || *static_cast<Metadata **>(Ref) == &MD) &&
157 "Reference without owner must be direct");
158 if (
auto *R = ReplaceableMetadataImpl::getOrCreate(MD)) {
159 R->addRef(Ref, Owner);
162 if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD)) {
163 assert(!PH->Use &&
"Placeholders can only be used once");
164 assert(!Owner &&
"Unexpected callback to owner");
165 PH->Use =
static_cast<Metadata **
>(Ref);
172 assert(Ref &&
"Expected live reference");
173 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD))
175 else if (
auto *PH = dyn_cast<DistinctMDOperandPlaceholder>(&MD))
180 assert(Ref &&
"Expected live reference");
181 assert(New &&
"Expected live reference");
182 assert(Ref != New &&
"Expected change");
183 if (
auto *R = ReplaceableMetadataImpl::getIfExists(MD)) {
184 R->moveRef(Ref, New, MD);
187 assert(!isa<DistinctMDOperandPlaceholder>(MD) &&
188 "Unexpected move of an MDOperand");
190 "Expected un-replaceable metadata, since we didn't move a reference");
195 return ReplaceableMetadataImpl::isReplaceable(MD);
198 void ReplaceableMetadataImpl::addRef(
void *Ref, OwnerTy Owner) {
200 UseMap.insert(std::make_pair(Ref, std::make_pair(Owner, NextIndex)))
203 assert(WasInserted &&
"Expected to add a reference");
206 assert(NextIndex != 0 &&
"Unexpected overflow");
209 void ReplaceableMetadataImpl::dropRef(
void *Ref) {
210 bool WasErased = UseMap.erase(Ref);
212 assert(WasErased &&
"Expected to drop a reference");
215 void ReplaceableMetadataImpl::moveRef(
void *Ref,
void *New,
217 auto I = UseMap.find(Ref);
218 assert(
I != UseMap.end() &&
"Expected to move a reference");
219 auto OwnerAndIndex =
I->second;
221 bool WasInserted = UseMap.insert(std::make_pair(New, OwnerAndIndex)).second;
223 assert(WasInserted &&
"Expected to add a reference");
227 assert((OwnerAndIndex.first || *static_cast<Metadata **>(Ref) == &MD) &&
228 "Reference without owner must be direct");
229 assert((OwnerAndIndex.first || *static_cast<Metadata **>(New) == &MD) &&
230 "Reference without owner must be direct");
238 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
240 std::sort(Uses.begin(), Uses.end(), [](
const UseTy &
L,
const UseTy &R) {
241 return L.second.second < R.second.second;
243 for (
const auto &Pair : Uses) {
246 if (!UseMap.count(Pair.first))
249 OwnerTy Owner = Pair.second.first;
256 UseMap.erase(Pair.first);
269 #define HANDLE_METADATA_LEAF(CLASS) \
270 case Metadata::CLASS##Kind: \
271 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
273 #include "llvm/IR/Metadata.def"
278 assert(UseMap.empty() &&
"Expected all uses to be replaced");
291 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
293 std::sort(Uses.begin(), Uses.end(), [](
const UseTy &
L,
const UseTy &R) {
294 return L.second.second < R.second.second;
297 for (
const auto &Pair : Uses) {
298 auto Owner = Pair.second.first;
308 if (OwnerMD->isResolved())
310 OwnerMD->decrementUnresolvedOperandCount();
315 if (
auto *
N = dyn_cast<MDNode>(&MD))
316 return N->isResolved() ?
nullptr :
N->Context.getOrCreateReplaceableUses();
321 if (
auto *
N = dyn_cast<MDNode>(&MD))
322 return N->isResolved() ?
nullptr :
N->Context.getReplaceableUses();
326 bool ReplaceableMetadataImpl::isReplaceable(
const Metadata &MD) {
327 if (
auto *
N = dyn_cast<MDNode>(&MD))
328 return !
N->isResolved();
333 assert(V &&
"Expected value");
334 if (
auto *
A = dyn_cast<Argument>(V))
335 return A->getParent();
337 return BB->getParent();
342 assert(V &&
"Unexpected null Value");
347 assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
348 "Expected constant or function-local value");
351 if (
auto *
C = dyn_cast<Constant>(V))
361 assert(V &&
"Unexpected null Value");
366 assert(V &&
"Expected valid value");
375 assert(MD &&
"Expected valid metadata");
385 assert(From &&
"Expected valid value");
386 assert(To &&
"Expected valid value");
387 assert(From != To &&
"Expected changed value");
391 auto &
Store = Context.pImpl->ValuesAsMetadata;
392 auto I =
Store.find(From);
402 assert(MD &&
"Expected valid metadata");
406 if (isa<LocalAsMetadata>(MD)) {
407 if (
auto *
C = dyn_cast<Constant>(To)) {
420 }
else if (!isa<Constant>(To)) {
427 auto *&Entry =
Store[To];
448 auto I =
Store.try_emplace(Str);
449 auto &MapEntry =
I.first->getValue();
452 MapEntry.Entry = &*
I.first;
457 assert(Entry &&
"Expected to find string map entry");
458 return Entry->first();
467 #define HANDLE_MDNODE_LEAF(CLASS) \
469 alignof(uint64_t) >= alignof(CLASS), \
470 "Alignment is insufficient after objects prepended to " #CLASS);
471 #include "llvm/IR/Metadata.def"
473 void *MDNode::operator
new(
size_t Size,
unsigned NumOps) {
474 size_t OpSize = NumOps *
sizeof(
MDOperand);
477 OpSize =
alignTo(OpSize,
alignof(uint64_t));
478 void *
Ptr =
reinterpret_cast<char *
>(::operator
new(OpSize +
Size)) + OpSize;
485 void MDNode::operator
delete(
void *Mem) {
487 size_t OpSize = N->NumOperands *
sizeof(
MDOperand);
488 OpSize =
alignTo(OpSize,
alignof(uint64_t));
491 for (
MDOperand *
E = O - N->NumOperands; O !=
E; --O)
493 ::operator
delete(
reinterpret_cast<char *
>(Mem) - OpSize);
498 :
Metadata(ID, Storage), NumOperands(Ops1.size() + Ops2.size()),
499 NumUnresolved(0), Context(Context) {
511 countUnresolvedOperands();
518 #define HANDLE_MDNODE_LEAF(CLASS) \
520 return cast<CLASS>(this)->cloneImpl();
521 #include "llvm/IR/Metadata.def"
526 if (
auto *
N = dyn_cast_or_null<MDNode>(Op))
527 return !
N->isResolved();
531 void MDNode::countUnresolvedOperands() {
532 assert(NumUnresolved == 0 &&
"Expected unresolved ops to be uncounted");
537 void MDNode::makeUniqued() {
543 Op.reset(
Op.get(),
this);
547 countUnresolvedOperands();
548 if (!NumUnresolved) {
549 dropReplaceableUses();
556 void MDNode::makeDistinct() {
561 dropReplaceableUses();
568 void MDNode::resolve() {
573 dropReplaceableUses();
578 void MDNode::dropReplaceableUses() {
579 assert(!NumUnresolved &&
"Unexpected unresolved operand");
582 if (Context.hasReplaceableUses())
583 Context.takeReplaceableUses()->resolveAllUses();
588 assert(NumUnresolved != 0 &&
"Expected unresolved operands");
596 decrementUnresolvedOperandCount();
599 void MDNode::decrementUnresolvedOperandCount() {
609 dropReplaceableUses();
622 auto *
N = dyn_cast_or_null<MDNode>(
Op);
627 "Expected all forward declarations to be resolved");
628 if (!
N->isResolved())
640 MDNode *MDNode::replaceWithPermanentImpl() {
644 return replaceWithDistinctImpl();
646 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
649 #include "llvm/IR/Metadata.def"
654 return replaceWithDistinctImpl();
655 return replaceWithUniquedImpl();
658 MDNode *MDNode::replaceWithUniquedImpl() {
660 MDNode *UniquedNode = uniquify();
662 if (UniquedNode ==
this) {
673 MDNode *MDNode::replaceWithDistinctImpl() {
678 void MDTuple::recalculateHash() {
679 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
683 for (
unsigned I = 0,
E = NumOperands;
I !=
E; ++
I)
685 if (Context.hasReplaceableUses()) {
686 Context.getReplaceableUses()->resolveAllUses(
false);
687 (void)Context.takeReplaceableUses();
691 void MDNode::handleChangedOperand(
void *Ref,
Metadata *New) {
708 if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
719 resolveAfterOperandChange(Old, New);
731 if (Context.hasReplaceableUses())
732 Context.getReplaceableUses()->replaceAllUsesWith(
Uniqued);
741 void MDNode::deleteAsSubclass() {
745 #define HANDLE_MDNODE_LEAF(CLASS) \
747 delete cast<CLASS>(this); \
749 #include "llvm/IR/Metadata.def"
753 template <
class T,
class InfoT>
762 template <
class NodeTy>
struct MDNode::HasCachedHash {
765 template <
class U, U Val>
struct SFINAE {};
768 static Yes &check(
SFINAE<
void (U::*)(
unsigned), &U::setHash> *);
769 template <
class U>
static No &check(...);
771 static const bool value =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(
Yes);
774 MDNode *MDNode::uniquify() {
781 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
782 case CLASS##Kind: { \
783 CLASS *SubclassThis = cast<CLASS>(this); \
784 std::integral_constant<bool, HasCachedHash<CLASS>::value> \
785 ShouldRecalculateHash; \
786 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
787 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
789 #include "llvm/IR/Metadata.def"
793 void MDNode::eraseFromStore() {
797 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
799 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
801 #include "llvm/IR/Metadata.def"
806 StorageType Storage,
bool ShouldCreate) {
809 MDTupleInfo::KeyTy Key(MDs);
814 Hash = Key.getHash();
816 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
826 N->deleteAsSubclass();
830 assert(!Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
831 assert(!NumUnresolved &&
"Unexpected unresolved nodes");
839 #define HANDLE_MDNODE_LEAF(CLASS) \
840 case CLASS##Kind: { \
841 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \
842 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
845 #include "llvm/IR/Metadata.def"
877 if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
878 if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
879 for (
unsigned I = 1,
E = Ops.
size();
I !=
E; ++
I)
880 if (Ops[
I] !=
N->getOperand(
I))
945 APInt LB = EndPoints[Size - 2]->getValue();
946 APInt LE = EndPoints[Size - 1]->getValue();
951 EndPoints[Size - 2] =
953 EndPoints[Size - 1] =
962 if (!EndPoints.
empty())
988 while (AI < AN && BI < BN) {
994 mdconst::extract<ConstantInt>(A->
getOperand(2 * AI + 1)));
998 mdconst::extract<ConstantInt>(B->
getOperand(2 * BI + 1)));
1004 mdconst::extract<ConstantInt>(A->
getOperand(2 * AI + 1)));
1009 mdconst::extract<ConstantInt>(B->
getOperand(2 * BI + 1)));
1020 for (
unsigned i = 0; i < Size - 2; ++i) {
1021 EndPoints[i] = EndPoints[i + 2];
1023 EndPoints.
resize(Size - 2);
1029 if (EndPoints.
size() == 2) {
1030 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());
1037 for (
auto *
I : EndPoints)
1061 NamedMDNode::NamedMDNode(
const Twine &
N)
1064 NamedMDNode::~NamedMDNode() {
1070 return (
unsigned)
getNMDOps(Operands).size();
1076 return cast_or_null<MDNode>(
N);
1096 for (
auto &
I : Attachments)
1097 if (
I.first == ID) {
1098 I.second.reset(&MD);
1101 Attachments.emplace_back(std::piecewise_construct, std::make_tuple(ID),
1102 std::make_tuple(&MD));
1110 if (Attachments.back().first ==
ID) {
1111 Attachments.pop_back();
1115 for (
auto I = Attachments.begin(),
E = std::prev(Attachments.end());
I !=
E;
1117 if (
I->first == ID) {
1118 *
I = std::move(Attachments.back());
1119 Attachments.pop_back();
1125 for (
const auto &
I : Attachments)
1133 Result.append(Attachments.begin(), Attachments.end());
1136 if (Result.size() > 1)
1146 for (
auto A : Attachments)
1152 auto Follower = Attachments.
begin();
1153 for (
auto Leader = Attachments.
begin(),
E = Attachments.
end(); Leader !=
E;
1155 if (Leader->MDKind != ID) {
1156 if (Follower != Leader)
1157 *Follower = std::move(*Leader);
1161 Attachments.
resize(Follower - Attachments.
begin());
1166 for (
auto &
A : Attachments)
1167 Result.emplace_back(
A.MDKind,
A.Node);
1172 Result.begin(), Result.end(),
1173 [](
const std::pair<unsigned, MDNode *> &
A,
1174 const std::pair<unsigned, MDNode *> &
B) {
return A.first <
B.first; });
1184 return getMetadataImpl(
getContext().getMDKindID(Kind));
1188 if (!hasMetadataHashEntry())
1195 if (KnownSet.
empty()) {
1197 InstructionMetadata.erase(
this);
1198 setHasMetadataHashEntry(
false);
1202 auto &Info = InstructionMetadata[
this];
1203 Info.remove_if([&KnownSet](
const std::pair<unsigned, TrackingMDNodeRef> &
I) {
1204 return !KnownSet.
count(I.first);
1209 InstructionMetadata.erase(
this);
1210 setHasMetadataHashEntry(
false);
1227 assert(!Info.empty() == hasMetadataHashEntry() &&
1228 "HasMetadata bit is wonked");
1230 setHasMetadataHashEntry(
true);
1231 Info.set(KindID, *Node);
1236 assert((hasMetadataHashEntry() ==
1237 (
getContext().pImpl->InstructionMetadata.count(
this) > 0)) &&
1238 "HasMetadata bit out of date!");
1239 if (!hasMetadataHashEntry())
1250 setHasMetadataHashEntry(
false);
1259 MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
1264 if (!hasMetadataHashEntry())
1267 assert(!Info.empty() &&
"bit out of sync with hash table");
1269 return Info.lookup(KindID);
1272 void Instruction::getAllMetadataImpl(
1280 if (!hasMetadataHashEntry())
1284 assert(hasMetadataHashEntry() &&
1285 getContext().pImpl->InstructionMetadata.count(
this) &&
1286 "Shouldn't have called this");
1288 assert(!Info.empty() &&
"Shouldn't have called this");
1289 Info.getAll(Result);
1292 void Instruction::getAllMetadataOtherThanDebugLocImpl(
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);
1304 uint64_t &FalseVal)
const {
1307 "Looking for branch weights on something besides branch or select");
1310 if (!ProfileData || ProfileData->getNumOperands() != 3)
1314 if (!ProfDataName || !ProfDataName->getString().equals(
"branch_weights"))
1317 auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
1318 auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
1319 if (!CITrue || !CIFalse)
1322 TrueVal = CITrue->getValue().getZExtValue();
1323 FalseVal = CIFalse->getValue().getZExtValue();
1334 "Looking for branch weights on something besides branch");
1345 if (ProfDataName->getString().equals(
"branch_weights")) {
1347 for (
unsigned i = 1; i < ProfileData->getNumOperands(); i++) {
1348 auto *V = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(i));
1351 TotalVal += V->getValue().getZExtValue();
1354 }
else if (ProfDataName->getString().equals(
"VP") &&
1355 ProfileData->getNumOperands() > 3) {
1356 TotalVal = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2))
1364 void Instruction::clearMetadataHashEntries() {
1365 assert(hasMetadataHashEntry() &&
"Caller should check");
1367 setHasMetadataHashEntry(
false);
1384 setHasMetadataHashEntry(
true);
1399 Store.erase(KindID);
1418 setHasMetadataHashEntry(
false);
1434 assert(MDs.
size() <= 1 &&
"Expected at most one metadata attachment");
1447 for (
auto &MD : MDs) {
1450 auto *OffsetConst = cast<ConstantInt>(
1451 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1452 Metadata *TypeId = MD.second->getOperand(1);
1454 OffsetConst->getType(), OffsetConst->getValue() +
Offset));
1462 auto *Attachment = MD.second;
1463 if (Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1467 auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1468 GV = GVE->getVariable();
1469 E = GVE->getExpression();
1473 OrigElements = E->getElements();
1474 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1475 Elements[0] = dwarf::DW_OP_plus_uconst;
1477 std::copy(OrigElements.
begin(), OrigElements.
end(), Elements.begin() + 2);
1499 return cast_or_null<DISubprogram>(
getMetadata(LLVMContext::MD_dbg));
1505 return CU->getDebugInfoForProfiling();
1520 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.
bool isDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
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.
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
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
This file implements a class to represent arbitrary precision integral constant values and operations...
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)
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.
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...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
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.
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.
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.
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.
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
MDNode * getAsMDNode() const
Return this as a bar MDNode.
llvm_unreachable("Unknown RegBank!")
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
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.
void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End, const Comparator &Comp=Comparator())
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.
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 slt(const APInt &RHS) const
Signed less than comparison.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.