Lines Matching defs:MD
32 MetadataAsValue::MetadataAsValue(Type *Ty, Metadata *MD)
33 : Value(Ty, MetadataAsValueVal), MD(MD) {
38 getType()->getContext().pImpl->MetadataAsValues.erase(MD);
54 Metadata *MD) {
55 if (!MD)
60 auto *N = dyn_cast<MDNode>(MD);
62 return MD;
72 return MD;
75 MetadataAsValue *MetadataAsValue::get(LLVMContext &Context, Metadata *MD) {
76 MD = canonicalizeMetadataForValue(Context, MD);
77 auto *&Entry = Context.pImpl->MetadataAsValues[MD];
79 Entry = new MetadataAsValue(Type::getMetadataTy(Context), MD);
84 Metadata *MD) {
85 MD = canonicalizeMetadataForValue(Context, MD);
87 return Store.lookup(MD);
90 void MetadataAsValue::handleChangedMetadata(Metadata *MD) {
92 MD = canonicalizeMetadataForValue(Context, MD);
96 Store.erase(this->MD);
98 this->MD = nullptr;
100 // Start tracking MD, or RAUW if necessary.
101 auto *&Entry = Store[MD];
108 this->MD = MD;
114 if (MD)
115 MetadataTracking::track(&MD, *MD, *this);
119 if (MD)
120 MetadataTracking::untrack(MD);
141 const Metadata &MD) {
151 (void)MD;
152 assert((OwnerAndIndex.first || *static_cast<Metadata **>(Ref) == &MD) &&
154 assert((OwnerAndIndex.first || *static_cast<Metadata **>(New) == &MD) &&
158 void ReplaceableMetadataImpl::replaceAllUsesWith(Metadata *MD) {
159 assert(!(MD && isa<MDNode>(MD) && cast<MDNode>(MD)->isTemporary()) &&
181 Ref = MD;
182 if (MD)
190 Owner.get<MetadataAsValue *>()->handleChangedMetadata(MD);
199 cast<CLASS>(OwnerMD)->handleChangedOperand(Pair.first, MD); \
285 ValueAsMetadata *MD = I->second;
286 assert(MD && "Expected valid metadata");
287 assert(MD->getValue() == V && "Expected valid mapping");
291 MD->replaceAllUsesWith(nullptr);
292 delete MD;
314 ValueAsMetadata *MD = I->second;
315 assert(MD && "Expected valid metadata");
316 assert(MD->getValue() == From && "Expected valid mapping");
319 if (isa<LocalAsMetadata>(MD)) {
322 MD->replaceAllUsesWith(ConstantAsMetadata::get(C));
323 delete MD;
329 MD->replaceAllUsesWith(nullptr);
330 delete MD;
335 MD->replaceAllUsesWith(nullptr);
336 delete MD;
343 MD->replaceAllUsesWith(Entry);
344 delete MD;
348 // Update MD in place (and update the map entry).
352 MD->V = To;
353 Entry = MD;
420 for (Metadata *MD : Ops1)
421 setOperand(Op++, MD);
422 for (Metadata *MD : Ops2)
423 setOperand(Op++, MD);
543 for (Metadata *MD : N->operands())
544 if (MD == N)
815 for (Metadata *MD : A->operands())
816 if (std::find(B->op_begin(), B->op_end(), MD) != B->op_end())
817 MDs.push_back(MD);
829 for (Metadata *MD : A->operands())
830 if (std::find(B->op_begin(), B->op_end(), MD) == B->op_end())
831 MDs.push_back(MD);
1018 void MDAttachmentMap::set(unsigned ID, MDNode &MD) {
1021 I.second.reset(&MD);
1025 std::make_tuple(&MD));
1212 void Function::setMetadata(unsigned KindID, MDNode *MD) {
1213 if (MD) {
1217 getContext().pImpl->FunctionMetadata[this].set(KindID, *MD);
1231 void Function::setMetadata(StringRef Kind, MDNode *MD) {
1232 if (!MD && !hasMetadata())
1234 setMetadata(getContext().getMDKindID(Kind), MD);