Go to the documentation of this file.
53 #include <type_traits>
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);
117 void MetadataAsValue::handleChangedMetadata(
Metadata *MD) {
123 Store.erase(this->MD);
128 auto *&Entry =
Store[MD];
140 void MetadataAsValue::track() {
145 void 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)
209 MDUsers.push_back(UserWithID->first.get<
Metadata *>());
213 void 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");
224 void ReplaceableMetadataImpl::dropRef(
void *Ref) {
225 bool WasErased = UseMap.erase(Ref);
227 assert(WasErased &&
"Expected to drop a reference");
230 void 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");
242 assert((OwnerAndIndex.first || *
static_cast<Metadata **
>(Ref) == &MD) &&
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()) {
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);
369 bool 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");
426 assert(MD &&
"Expected valid metadata");
437 assert(To &&
"Expected valid value");
438 assert(
From != To &&
"Expected changed value");
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"
524 void *MDNode::operator
new(
size_t Size,
unsigned NumOps,
529 char *Mem =
reinterpret_cast<char *
>(::operator
new(AllocSize + Size));
530 Header *
H =
new (Mem + AllocSize -
sizeof(Header)) Header(NumOps);
531 return reinterpret_cast<void *
>(
H + 1);
534 void 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"
569 MDNode::Header::Header(
unsigned NumOps) {
570 NumOperands = NumOps;
576 MDNode::Header::~Header() {
579 (
void)
O->~MDOperand();
583 if (
auto *
N = dyn_cast_or_null<MDNode>(
Op))
584 return !
N->isResolved();
588 void MDNode::countUnresolvedOperands() {
594 void MDNode::makeUniqued() {
600 Op.reset(
Op.get(),
this);
604 countUnresolvedOperands();
606 dropReplaceableUses();
613 void MDNode::makeDistinct() {
618 dropReplaceableUses();
630 dropReplaceableUses();
635 void MDNode::dropReplaceableUses() {
639 if (
Context.hasReplaceableUses())
640 Context.takeReplaceableUses()->resolveAllUses();
653 decrementUnresolvedOperandCount();
656 void MDNode::decrementUnresolvedOperandCount() {
667 dropReplaceableUses();
680 auto *
N = dyn_cast_or_null<MDNode>(
Op);
685 "Expected all forward declarations to be resolved");
686 if (!
N->isResolved())
695 MDNode *MDNode::replaceWithPermanentImpl() {
699 return replaceWithDistinctImpl();
701 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
704 #include "llvm/IR/Metadata.def"
709 return replaceWithDistinctImpl();
710 return replaceWithUniquedImpl();
713 MDNode *MDNode::replaceWithUniquedImpl() {
715 MDNode *UniquedNode = uniquify();
717 if (UniquedNode ==
this) {
728 MDNode *MDNode::replaceWithDistinctImpl() {
733 void MDTuple::recalculateHash() {
734 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
740 if (
Context.hasReplaceableUses()) {
741 Context.getReplaceableUses()->resolveAllUses(
false);
742 (void)
Context.takeReplaceableUses();
746 void MDNode::handleChangedOperand(
void *Ref,
Metadata *New) {
763 if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
774 resolveAfterOperandChange(Old, New);
786 if (
Context.hasReplaceableUses())
796 void MDNode::deleteAsSubclass() {
800 #define HANDLE_MDNODE_LEAF(CLASS) \
802 delete cast<CLASS>(this); \
804 #include "llvm/IR/Metadata.def"
808 template <
class T,
class InfoT>
817 template <
class NodeTy>
struct MDNode::HasCachedHash {
820 template <
class U, U Val>
struct SFINAE {};
824 template <
class U>
static No &
check(...);
826 static const bool value =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(
Yes);
829 MDNode *MDNode::uniquify() {
836 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
837 case CLASS##Kind: { \
838 CLASS *SubclassThis = cast<CLASS>(this); \
839 std::integral_constant<bool, HasCachedHash<CLASS>::value> \
840 ShouldRecalculateHash; \
841 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
842 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
844 #include "llvm/IR/Metadata.def"
848 void MDNode::eraseFromStore() {
852 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
854 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
856 #include "llvm/IR/Metadata.def"
861 StorageType Storage,
bool ShouldCreate) {
864 MDTupleInfo::KeyTy
Key(MDs);
869 Hash =
Key.getHash();
871 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
880 assert(
N->isTemporary() &&
"Expected temporary node");
881 N->replaceAllUsesWith(
nullptr);
882 N->deleteAsSubclass();
886 assert(!
Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
895 #define HANDLE_MDNODE_LEAF(CLASS) \
896 case CLASS##Kind: { \
897 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \
898 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
901 #include "llvm/IR/Metadata.def"
933 if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
934 if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
935 for (
unsigned I = 1,
E = Ops.
size();
I !=
E; ++
I)
936 if (Ops[
I] !=
N->getOperand(
I))
951 MDs.
insert(
B->op_begin(),
B->op_end());
980 for (
const MDOperand &MDOp : A->operands())
981 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
986 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
993 for (
const MDOperand &MDOp : A->operands())
994 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
999 return MDs.
empty() ? nullptr
1007 APFloat AVal = mdconst::extract<ConstantFP>(A->getOperand(0))->getValueAPF();
1008 APFloat BVal = mdconst::extract<ConstantFP>(
B->getOperand(0))->getValueAPF();
1015 return A.getUpper() ==
B.getLower() || A.getLower() ==
B.getUpper();
1025 unsigned Size = EndPoints.size();
1026 APInt LB = EndPoints[Size - 2]->getValue();
1027 APInt LE = EndPoints[Size - 1]->getValue();
1032 EndPoints[Size - 2] =
1034 EndPoints[Size - 1] =
1043 if (!EndPoints.empty())
1047 EndPoints.push_back(
Low);
1048 EndPoints.push_back(
High);
1067 int AN = A->getNumOperands() / 2;
1068 int BN =
B->getNumOperands() / 2;
1069 while (AI < AN && BI < BN) {
1070 ConstantInt *ALow = mdconst::extract<ConstantInt>(A->getOperand(2 * AI));
1071 ConstantInt *BLow = mdconst::extract<ConstantInt>(
B->getOperand(2 * BI));
1075 mdconst::extract<ConstantInt>(A->getOperand(2 * AI + 1)));
1079 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1084 addRange(EndPoints, mdconst::extract<ConstantInt>(A->getOperand(2 * AI)),
1085 mdconst::extract<ConstantInt>(A->getOperand(2 * AI + 1)));
1089 addRange(EndPoints, mdconst::extract<ConstantInt>(
B->getOperand(2 * BI)),
1090 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1096 unsigned Size = EndPoints.size();
1101 for (
unsigned i = 0;
i < Size - 2; ++
i) {
1102 EndPoints[
i] = EndPoints[
i + 2];
1104 EndPoints.
resize(Size - 2);
1110 if (EndPoints.size() == 2) {
1111 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());
1117 MDs.
reserve(EndPoints.size());
1118 for (
auto *
I : EndPoints)
1127 ConstantInt *AVal = mdconst::extract<ConstantInt>(A->getOperand(0));
1128 ConstantInt *BVal = mdconst::extract<ConstantInt>(
B->getOperand(0));
1142 NamedMDNode::NamedMDNode(
const Twine &
N)
1145 NamedMDNode::~NamedMDNode() {
1151 return (
unsigned)
getNMDOps(Operands).size();
1157 return cast_or_null<MDNode>(
N);
1178 for (
const auto &A : Attachments)
1185 for (
const auto &A : Attachments)
1187 Result.push_back(A.Node);
1192 for (
const auto &A : Attachments)
1193 Result.emplace_back(A.MDKind, A.Node);
1197 if (Result.size() > 1)
1216 if (Attachments.size() == 1 && Attachments.back().MDKind ==
ID) {
1217 Attachments.pop_back();
1221 auto OldSize = Attachments.size();
1224 return OldSize != Attachments.size();
1231 assert(!
Info.empty() &&
"bit out of sync with hash table");
1232 return Info.lookup(KindID);
1239 assert(!
Info.empty() &&
"bit out of sync with hash table");
1257 "bit out of sync with hash table");
1259 assert(!
Info.empty() &&
"Shouldn't have called this");
1265 assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1273 Info.set(KindID, Node);
1279 "bit out of sync with hash table");
1299 assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1315 bool Changed =
Store.erase(KindID);
1325 "bit out of sync with hash table");
1344 if (KnownIDs.
empty()) {
1354 auto &
Info = MetadataStore[
this];
1355 assert(!
Info.empty() &&
"bit out of sync with hash table");
1357 return !KnownSet.
count(
I.MDKind);
1371 if (KindID == LLVMContext::MD_dbg) {
1382 auto *Existing =
getMetadata(LLVMContext::MD_annotation);
1384 bool AppendName =
true;
1386 auto *Tuple = cast<MDTuple>(Existing);
1387 for (
auto &
N : Tuple->operands()) {
1388 if (cast<MDString>(
N.get())->getString() ==
Name)
1390 Names.push_back(
N.get());
1403 Result.TBAAStruct =
getMetadata(LLVMContext::MD_tbaa_struct);
1404 Result.Scope =
getMetadata(LLVMContext::MD_alias_scope);
1405 Result.NoAlias =
getMetadata(LLVMContext::MD_noalias);
1411 setMetadata(LLVMContext::MD_tbaa_struct,
N.TBAAStruct);
1416 MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
1418 if (KindID == LLVMContext::MD_dbg)
1423 void Instruction::getAllMetadataImpl(
1430 std::make_pair((
unsigned)LLVMContext::MD_dbg, DbgLoc.
getAsMDNode()));
1439 "Looking for branch weights on something besides branch or select");
1441 auto *ProfileData =
getMetadata(LLVMContext::MD_prof);
1442 if (!ProfileData || ProfileData->getNumOperands() != 3)
1445 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
1446 if (!ProfDataName || !ProfDataName->getString().equals(
"branch_weights"))
1449 auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
1450 auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
1451 if (!CITrue || !CIFalse)
1454 TrueVal = CITrue->getValue().getZExtValue();
1455 FalseVal = CIFalse->getValue().getZExtValue();
1464 getOpcode() == Instruction::IndirectBr ||
1466 "Looking for branch weights on something besides branch");
1469 auto *ProfileData =
getMetadata(LLVMContext::MD_prof);
1473 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
1477 if (ProfDataName->getString().equals(
"branch_weights")) {
1479 for (
unsigned i = 1;
i < ProfileData->getNumOperands();
i++) {
1480 auto *V = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(
i));
1483 TotalVal += V->getValue().getZExtValue();
1486 }
else if (ProfDataName->getString().equals(
"VP") &&
1487 ProfileData->getNumOperands() > 3) {
1488 TotalVal = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2))
1498 Other->getAllMetadata(MDs);
1499 for (
auto &MD : MDs) {
1501 if (Offset != 0 && MD.first == LLVMContext::MD_type) {
1502 auto *OffsetConst = cast<ConstantInt>(
1503 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1504 Metadata *TypeId = MD.second->getOperand(1);
1506 OffsetConst->getType(), OffsetConst->getValue() + Offset));
1514 auto *Attachment = MD.second;
1515 if (Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1519 auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1520 GV = GVE->getVariable();
1521 E = GVE->getExpression();
1525 OrigElements =
E->getElements();
1526 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1527 Elements[0] = dwarf::DW_OP_plus_uconst;
1528 Elements[1] = Offset;
1539 LLVMContext::MD_type,
1559 cast<ConstantAsMetadata>(MD->getOperand(0))->getValue())
1561 assert(Val <= 2 &&
"unknown vcall visibility!");
1564 return VCallVisibility::VCallVisibilityPublic;
1572 return cast_or_null<DISubprogram>(
getMetadata(LLVMContext::MD_dbg));
1578 return CU->getDebugInfoForProfiling();
1593 GVs.push_back(cast<DIGlobalVariableExpression>(MD));
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
LLVMContextImpl *const pImpl
Function object to check whether the second component of a std::pair compares less than the second co...
This is an optimization pass for GlobalISel generic memory operations.
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
unsigned getNumOperands() const
void getDebugInfo(SmallVectorImpl< DIGlobalVariableExpression * > &GVs) const
Fill the vector with all debug info attachements.
void setOperand(unsigned I, Metadata *New)
Set an operand.
const APInt & getValue() const
Return the constant as an APInt value reference.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static T * getUniqued(DenseSet< T *, InfoT > &Store, const typename InfoT::KeyTy &Key)
void set(unsigned ID, MDNode *MD)
Set an attachment to a particular node.
DISubprogram * getSubprogram() const
Get the attached subprogram.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
MDNode * getAsMDNode() const
Return this as a bar MDNode.
bool erase(unsigned ID)
Remove attachments with the given ID.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
void setOperand(unsigned I, MDNode *New)
ArrayRef< T > getArrayRef() const
The instances of the Type class are immutable: once they are created, they are never changed.
OutputIt copy(R &&Range, OutputIt Out)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void dropAllReferences()
Remove all uses and clear node vector.
DenseMap< Value *, ValueAsMetadata * > ValuesAsMetadata
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2=None)
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...
bool remove_if(UnaryPredicate P)
Remove items from the set vector based on a predicate function.
void dropUnknownNonDebugMetadata()
T get() const
Returns the value of the specified pointer type.
bool empty() const
empty - Check if the array is empty.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM ID Predecessors according to mbb< bb27, 0x8b0a7c0 > Note ADDri is not a two address instruction its result reg1037 is an operand of the PHI node in bb76 and its operand reg1039 is the result of the PHI node We should treat it as a two address code and make sure the ADDri is scheduled after any node that reads reg1039 Use info(i.e. register scavenger) to assign it a free register to allow reuse the collector could move the objects and invalidate the derived pointer This is bad enough in the first but safe points can crop up unpredictably **array_addr i32 n y store obj * new
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
op_range operands() const
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
SmallPtrSet< MachineInstr *, 2 > Uses
LLVM Basic Block Representation.
bool is() const
Test if the Union currently holds the type matching T.
void storeDistinctInContext()
unsigned getNumOperands() const
Return number of MDNode operands.
void addOperand(MDNode *M)
This is the shared class of boolean and integer constants.
static Type * getMetadataTy(LLVMContext &C)
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool extractProfTotalWeight(uint64_t &TotalVal) const
Retrieve total raw weight values of a branch.
@ Ref
The access may reference the value stored in memory.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Function object to check whether the first component of a std::pair compares less than the first comp...
(vector float) vec_cmpeq(*A, *B) C
StringRef getName() const
void setVCallVisibilityMetadata(VCallVisibility Visibility)
mutable_op_range mutable_operands()
MDNode * lookup(unsigned ID) const
Returns the first attachment with the given ID or nullptr if no such attachment exists.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
MDOperand * mutable_begin()
void eraseFromParent()
Drop all references and remove the node from parent module.
ConstantRange unionWith(const ConstantRange &CR, PreferredRangeType Type=Smallest) const
Return the range that results from the union of this range with another range.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
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.
AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
Analysis containing CSE Info
bool empty() const
Determine if the SetVector is empty or not.
bool extractProfMetadata(uint64_t &TrueVal, uint64_t &FalseVal) const
Retrieve the raw weight values of a conditional branch or select.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
mir Rename Register Operands
TypedTrackingMDRef< MDNode > TrackingMDNodeRef
const MDOperand & getOperand(unsigned I) const
MDString * createString(StringRef Str)
Return the given string as metadata.
void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
void resolveCycles()
Resolve cycles.
DenseMap< const Value *, MDAttachments > ValueMetadata
Collection of metadata used in this context.
Implements a dense probed hash-table based set.
void setSubprogram(DISubprogram *SP)
Set the attached subprogram.
bool slt(const APInt &RHS) const
Signed less than comparison.
void resolve()
Resolve a unique, unresolved node.
This is an important base class in LLVM.
static MDNode * intersect(MDNode *A, MDNode *B)
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
void addAnnotationMetadata(StringRef Annotation)
Adds an !annotation metadata node with Annotation to this instruction.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
bool isDebugInfoForProfiling() const
Returns true if we should emit debug info for profiling.
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
This is an important class for using LLVM in a threaded context.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
static MDString * get(LLVMContext &Context, StringRef Str)
MDNode * getOperand(unsigned i) const
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumUnresolved() const
void clearMetadata()
Erase all metadata attached to this Value.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Class for arbitrary precision integers.
bool insert(const value_type &X)
Insert a new element into the SetVector.
void insert(unsigned ID, MDNode &MD)
Adds an attachment to a particular node.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringMap< MDString, BumpPtrAllocator > MDStringCache
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static const Function * getParent(const Value *V)
LLVMContext & getContext() const
All values hold a context through their type.
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
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
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
void stable_sort(R &&Range)
static IntegerType * getInt64Ty(LLVMContext &C)
Module * getParent()
Get the module that holds this named metadata collection.
void addTypeMetadata(unsigned Offset, Metadata *TypeID)
bool isResolved() const
Check if node is fully resolved.
void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
void sort(IteratorTy Start, IteratorTy End)
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
A pair of DIGlobalVariable and DIExpression.
This class represents a range of values.
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
DenseMap< Metadata *, MetadataAsValue * > MetadataAsValues
Tracking metadata reference.
Optional< APInt > getAllocSize(const CallBase *CB, const TargetLibraryInfo *TLI, std::function< const Value *(const Value *)> Mapper)
Return the size of the requested allocation.
void getAll(SmallVectorImpl< std::pair< unsigned, MDNode * >> &Result) const
Appends all attachments for the global to Result, sorting by attachment ID.
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
This is a simple wrapper around an MDNode which provides a higher-level interface by hiding the detai...
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
VCallVisibility getVCallVisibility() const
size_t size() const
size - Get the array size.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
A SetVector that performs no allocations if smaller than a certain size.
TempMDNode clone() const
Create a (temporary) clone of this.
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
std::vector< MDNode * > DistinctMDNodes
BlockVerifier::State From
TypeID
Definitions of all of the base types for the Type system.
StringRef getString() const
void clearOperands()
Drop all references to this node's operands.
bool contains(ConstPtrType Ptr) const
void reserve(size_type N)
bool hasMetadata() const
Return true if this value has any metadata attached to it.
op_iterator op_begin() const
void get(unsigned ID, SmallVectorImpl< MDNode * > &Result) const
Appends all attachments with the given ID to Result in insertion order.
LLVM Value Representation.
void setNumUnresolved(unsigned N)
Tracking metadata reference owned by Metadata.
Optional< std::vector< StOtherPiece > > Other
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.