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 return L.second.second < R.second.second;
288 for (
const auto &Pair :
Uses) {
291 if (!UseMap.count(Pair.first))
294 OwnerTy Owner = Pair.second.first;
301 UseMap.erase(Pair.first);
314 #define HANDLE_METADATA_LEAF(CLASS) \
315 case Metadata::CLASS##Kind: \
316 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
318 #include "llvm/IR/Metadata.def"
323 assert(UseMap.empty() &&
"Expected all uses to be replaced");
336 using UseTy = std::pair<void *, std::pair<OwnerTy, uint64_t>>;
339 return L.second.second < R.second.second;
342 for (
const auto &Pair :
Uses) {
343 auto Owner = Pair.second.first;
350 auto *OwnerMD = dyn_cast<MDNode>(Owner.get<
Metadata *>());
353 if (OwnerMD->isResolved())
355 OwnerMD->decrementUnresolvedOperandCount();
360 if (
auto *
N = dyn_cast<MDNode>(&MD))
361 return N->isResolved() ? nullptr :
N->Context.getOrCreateReplaceableUses();
362 return dyn_cast<ValueAsMetadata>(&MD);
366 if (
auto *
N = dyn_cast<MDNode>(&MD))
367 return N->isResolved() ? nullptr :
N->Context.getReplaceableUses();
368 return dyn_cast<ValueAsMetadata>(&MD);
371 bool ReplaceableMetadataImpl::isReplaceable(
const Metadata &MD) {
372 if (
auto *
N = dyn_cast<MDNode>(&MD))
373 return !
N->isResolved();
374 return isa<ValueAsMetadata>(&MD);
378 assert(V &&
"Expected value");
379 if (
auto *A = dyn_cast<Argument>(V)) {
380 if (
auto *Fn = A->getParent())
381 return Fn->getSubprogram();
386 if (
auto *Fn =
BB->getParent())
387 return Fn->getSubprogram();
395 assert(V &&
"Unexpected null Value");
400 assert((isa<Constant>(V) || isa<Argument>(V) || isa<Instruction>(V)) &&
401 "Expected constant or function-local value");
404 if (
auto *
C = dyn_cast<Constant>(V))
414 assert(V &&
"Unexpected null Value");
419 assert(V &&
"Expected valid value");
428 assert(MD &&
"Expected valid metadata");
439 assert(To &&
"Expected valid value");
440 assert(
From != To &&
"Expected changed value");
447 assert(!
From->IsUsedByMD &&
"Expected From not to be used by metadata");
452 assert(
From->IsUsedByMD &&
"Expected From to be used by metadata");
453 From->IsUsedByMD =
false;
455 assert(MD &&
"Expected valid metadata");
459 if (isa<LocalAsMetadata>(MD)) {
460 if (
auto *
C = dyn_cast<Constant>(To)) {
473 }
else if (!isa<Constant>(To)) {
480 auto *&Entry =
Store[To];
501 auto I =
Store.try_emplace(Str);
502 auto &MapEntry =
I.first->getValue();
505 MapEntry.Entry = &*
I.first;
510 assert(Entry &&
"Expected to find string map entry");
511 return Entry->first();
520 #define HANDLE_MDNODE_LEAF(CLASS) \
522 alignof(uint64_t) >= alignof(CLASS), \
523 "Alignment is insufficient after objects prepended to " #CLASS);
524 #include "llvm/IR/Metadata.def"
526 void *MDNode::operator
new(
size_t Size,
unsigned NumOps,
531 char *Mem =
reinterpret_cast<char *
>(::operator
new(AllocSize + Size));
532 Header *
H =
new (Mem + AllocSize -
sizeof(Header)) Header(NumOps);
533 return reinterpret_cast<void *
>(
H + 1);
536 void MDNode::operator
delete(
void *
N) {
537 Header *
H =
reinterpret_cast<Header *
>(
N) - 1;
538 void *Mem =
H->getAllocation();
540 ::operator
delete(Mem);
557 countUnresolvedOperands();
564 #define HANDLE_MDNODE_LEAF(CLASS) \
566 return cast<CLASS>(this)->cloneImpl();
567 #include "llvm/IR/Metadata.def"
571 MDNode::Header::Header(
unsigned NumOps) {
572 NumOperands = NumOps;
578 MDNode::Header::~Header() {
581 (
void)
O->~MDOperand();
585 if (
auto *
N = dyn_cast_or_null<MDNode>(
Op))
586 return !
N->isResolved();
590 void MDNode::countUnresolvedOperands() {
596 void MDNode::makeUniqued() {
602 Op.reset(
Op.get(),
this);
606 countUnresolvedOperands();
608 dropReplaceableUses();
615 void MDNode::makeDistinct() {
620 dropReplaceableUses();
632 dropReplaceableUses();
637 void MDNode::dropReplaceableUses() {
641 if (
Context.hasReplaceableUses())
642 Context.takeReplaceableUses()->resolveAllUses();
655 decrementUnresolvedOperandCount();
658 void MDNode::decrementUnresolvedOperandCount() {
669 dropReplaceableUses();
682 auto *
N = dyn_cast_or_null<MDNode>(
Op);
687 "Expected all forward declarations to be resolved");
688 if (!
N->isResolved())
697 MDNode *MDNode::replaceWithPermanentImpl() {
701 return replaceWithDistinctImpl();
703 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
706 #include "llvm/IR/Metadata.def"
711 return replaceWithDistinctImpl();
712 return replaceWithUniquedImpl();
715 MDNode *MDNode::replaceWithUniquedImpl() {
717 MDNode *UniquedNode = uniquify();
719 if (UniquedNode ==
this) {
730 MDNode *MDNode::replaceWithDistinctImpl() {
735 void MDTuple::recalculateHash() {
736 setHash(MDTupleInfo::KeyTy::calculateHash(
this));
742 if (
Context.hasReplaceableUses()) {
743 Context.getReplaceableUses()->resolveAllUses(
false);
744 (void)
Context.takeReplaceableUses();
748 void MDNode::handleChangedOperand(
void *Ref,
Metadata *New) {
765 if (New ==
this || (!New && Old && isa<ConstantAsMetadata>(Old))) {
776 resolveAfterOperandChange(Old, New);
788 if (
Context.hasReplaceableUses())
798 void MDNode::deleteAsSubclass() {
802 #define HANDLE_MDNODE_LEAF(CLASS) \
804 delete cast<CLASS>(this); \
806 #include "llvm/IR/Metadata.def"
810 template <
class T,
class InfoT>
819 template <
class NodeTy>
struct MDNode::HasCachedHash {
822 template <
class U, U Val>
struct SFINAE {};
826 template <
class U>
static No &
check(...);
828 static const bool value =
sizeof(check<NodeTy>(
nullptr)) ==
sizeof(
Yes);
831 MDNode *MDNode::uniquify() {
838 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
839 case CLASS##Kind: { \
840 CLASS *SubclassThis = cast<CLASS>(this); \
841 std::integral_constant<bool, HasCachedHash<CLASS>::value> \
842 ShouldRecalculateHash; \
843 dispatchRecalculateHash(SubclassThis, ShouldRecalculateHash); \
844 return uniquifyImpl(SubclassThis, getContext().pImpl->CLASS##s); \
846 #include "llvm/IR/Metadata.def"
850 void MDNode::eraseFromStore() {
854 #define HANDLE_MDNODE_LEAF_UNIQUABLE(CLASS) \
856 getContext().pImpl->CLASS##s.erase(cast<CLASS>(this)); \
858 #include "llvm/IR/Metadata.def"
863 StorageType Storage,
bool ShouldCreate) {
866 MDTupleInfo::KeyTy
Key(MDs);
871 Hash =
Key.getHash();
873 assert(ShouldCreate &&
"Expected non-uniqued nodes to always be created");
882 assert(
N->isTemporary() &&
"Expected temporary node");
883 N->replaceAllUsesWith(
nullptr);
884 N->deleteAsSubclass();
888 assert(!
Context.hasReplaceableUses() &&
"Unexpected replaceable uses");
897 #define HANDLE_MDNODE_LEAF(CLASS) \
898 case CLASS##Kind: { \
899 std::integral_constant<bool, HasCachedHash<CLASS>::value> ShouldResetHash; \
900 dispatchResetHash(cast<CLASS>(this), ShouldResetHash); \
903 #include "llvm/IR/Metadata.def"
935 if (
MDNode *
N = dyn_cast_or_null<MDNode>(Ops[0]))
936 if (
N->getNumOperands() == Ops.
size() &&
N ==
N->getOperand(0)) {
937 for (
unsigned I = 1,
E = Ops.
size();
I !=
E; ++
I)
938 if (Ops[
I] !=
N->getOperand(
I))
953 MDs.
insert(
B->op_begin(),
B->op_end());
982 for (
const MDOperand &MDOp : A->operands())
983 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
988 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
995 for (
const MDOperand &MDOp : A->operands())
996 if (
const MDNode *NAMD = dyn_cast<MDNode>(MDOp))
1001 return MDs.
empty() ? nullptr
1009 APFloat AVal = mdconst::extract<ConstantFP>(A->getOperand(0))->getValueAPF();
1010 APFloat BVal = mdconst::extract<ConstantFP>(
B->getOperand(0))->getValueAPF();
1017 return A.getUpper() ==
B.getLower() || A.getLower() ==
B.getUpper();
1027 unsigned Size = EndPoints.size();
1028 APInt LB = EndPoints[Size - 2]->getValue();
1029 APInt LE = EndPoints[Size - 1]->getValue();
1034 EndPoints[Size - 2] =
1036 EndPoints[Size - 1] =
1045 if (!EndPoints.empty())
1049 EndPoints.push_back(
Low);
1050 EndPoints.push_back(
High);
1069 int AN = A->getNumOperands() / 2;
1070 int BN =
B->getNumOperands() / 2;
1071 while (AI < AN && BI < BN) {
1072 ConstantInt *ALow = mdconst::extract<ConstantInt>(A->getOperand(2 * AI));
1073 ConstantInt *BLow = mdconst::extract<ConstantInt>(
B->getOperand(2 * BI));
1077 mdconst::extract<ConstantInt>(A->getOperand(2 * AI + 1)));
1081 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1086 addRange(EndPoints, mdconst::extract<ConstantInt>(A->getOperand(2 * AI)),
1087 mdconst::extract<ConstantInt>(A->getOperand(2 * AI + 1)));
1091 addRange(EndPoints, mdconst::extract<ConstantInt>(
B->getOperand(2 * BI)),
1092 mdconst::extract<ConstantInt>(
B->getOperand(2 * BI + 1)));
1098 unsigned Size = EndPoints.size();
1103 for (
unsigned i = 0;
i < Size - 2; ++
i) {
1104 EndPoints[
i] = EndPoints[
i + 2];
1106 EndPoints.
resize(Size - 2);
1112 if (EndPoints.size() == 2) {
1113 ConstantRange Range(EndPoints[0]->getValue(), EndPoints[1]->getValue());
1119 MDs.
reserve(EndPoints.size());
1120 for (
auto *
I : EndPoints)
1129 ConstantInt *AVal = mdconst::extract<ConstantInt>(A->getOperand(0));
1130 ConstantInt *BVal = mdconst::extract<ConstantInt>(
B->getOperand(0));
1144 NamedMDNode::NamedMDNode(
const Twine &
N)
1147 NamedMDNode::~NamedMDNode() {
1153 return (
unsigned)
getNMDOps(Operands).size();
1159 return cast_or_null<MDNode>(
N);
1180 for (
const auto &A : Attachments)
1187 for (
const auto &A : Attachments)
1189 Result.push_back(A.Node);
1194 for (
const auto &A : Attachments)
1195 Result.emplace_back(A.MDKind, A.Node);
1199 if (Result.size() > 1)
1218 if (Attachments.size() == 1 && Attachments.back().MDKind ==
ID) {
1219 Attachments.pop_back();
1223 auto OldSize = Attachments.size();
1226 return OldSize != Attachments.size();
1233 assert(!
Info.empty() &&
"bit out of sync with hash table");
1234 return Info.lookup(KindID);
1241 assert(!
Info.empty() &&
"bit out of sync with hash table");
1259 "bit out of sync with hash table");
1261 assert(!
Info.empty() &&
"Shouldn't have called this");
1267 assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1275 Info.set(KindID, Node);
1281 "bit out of sync with hash table");
1301 assert(isa<Instruction>(
this) || isa<GlobalObject>(
this));
1317 bool Changed =
Store.erase(KindID);
1327 "bit out of sync with hash table");
1346 if (KnownIDs.
empty()) {
1356 auto &
Info = MetadataStore[
this];
1357 assert(!
Info.empty() &&
"bit out of sync with hash table");
1359 return !KnownSet.
count(
I.MDKind);
1373 if (KindID == LLVMContext::MD_dbg) {
1384 auto *Existing =
getMetadata(LLVMContext::MD_annotation);
1386 bool AppendName =
true;
1388 auto *Tuple = cast<MDTuple>(Existing);
1389 for (
auto &
N : Tuple->operands()) {
1390 if (cast<MDString>(
N.get())->getString() ==
Name)
1392 Names.push_back(
N.get());
1405 Result.TBAAStruct =
getMetadata(LLVMContext::MD_tbaa_struct);
1406 Result.Scope =
getMetadata(LLVMContext::MD_alias_scope);
1407 Result.NoAlias =
getMetadata(LLVMContext::MD_noalias);
1413 setMetadata(LLVMContext::MD_tbaa_struct,
N.TBAAStruct);
1418 MDNode *Instruction::getMetadataImpl(
unsigned KindID)
const {
1420 if (KindID == LLVMContext::MD_dbg)
1425 void Instruction::getAllMetadataImpl(
1432 std::make_pair((
unsigned)LLVMContext::MD_dbg, DbgLoc.
getAsMDNode()));
1441 "Looking for branch weights on something besides branch or select");
1443 auto *ProfileData =
getMetadata(LLVMContext::MD_prof);
1444 if (!ProfileData || ProfileData->getNumOperands() != 3)
1447 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
1448 if (!ProfDataName || !ProfDataName->getString().equals(
"branch_weights"))
1451 auto *CITrue = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(1));
1452 auto *CIFalse = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2));
1453 if (!CITrue || !CIFalse)
1456 TrueVal = CITrue->getValue().getZExtValue();
1457 FalseVal = CIFalse->getValue().getZExtValue();
1466 getOpcode() == Instruction::IndirectBr ||
1468 "Looking for branch weights on something besides branch");
1471 auto *ProfileData =
getMetadata(LLVMContext::MD_prof);
1475 auto *ProfDataName = dyn_cast<MDString>(ProfileData->getOperand(0));
1479 if (ProfDataName->getString().equals(
"branch_weights")) {
1481 for (
unsigned i = 1;
i < ProfileData->getNumOperands();
i++) {
1482 auto *V = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(
i));
1485 TotalVal += V->getValue().getZExtValue();
1488 }
else if (ProfDataName->getString().equals(
"VP") &&
1489 ProfileData->getNumOperands() > 3) {
1490 TotalVal = mdconst::dyn_extract<ConstantInt>(ProfileData->getOperand(2))
1500 Other->getAllMetadata(MDs);
1501 for (
auto &MD : MDs) {
1503 if (Offset != 0 && MD.first == LLVMContext::MD_type) {
1504 auto *OffsetConst = cast<ConstantInt>(
1505 cast<ConstantAsMetadata>(MD.second->getOperand(0))->getValue());
1506 Metadata *TypeId = MD.second->getOperand(1);
1508 OffsetConst->getType(), OffsetConst->getValue() + Offset));
1516 auto *Attachment = MD.second;
1517 if (Offset != 0 && MD.first == LLVMContext::MD_dbg) {
1521 auto *GVE = cast<DIGlobalVariableExpression>(Attachment);
1522 GV = GVE->getVariable();
1523 E = GVE->getExpression();
1527 OrigElements =
E->getElements();
1528 std::vector<uint64_t> Elements(OrigElements.
size() + 2);
1529 Elements[0] = dwarf::DW_OP_plus_uconst;
1530 Elements[1] = Offset;
1541 LLVMContext::MD_type,
1561 cast<ConstantAsMetadata>(MD->getOperand(0))->getValue())
1563 assert(Val <= 2 &&
"unknown vcall visibility!");
1566 return VCallVisibility::VCallVisibilityPublic;
1574 return cast_or_null<DISubprogram>(
getMetadata(LLVMContext::MD_dbg));
1580 return CU->getDebugInfoForProfiling();
1595 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
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.