llvm.org GIT mirror llvm / 9ed4497
IR: MDNode => Value: Add Instruction::getMDNode() Add `Instruction::getMDNode()` that casts to `MDNode` before changing `Instruction::getMetadata()` to return `Value`. This avoids adding `cast_or_null<MDNode>` boiler-plate throughout the code. Part of PR21433. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221023 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
2 changed file(s) with 28 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
152152 return getMetadataImpl(Kind);
153153 }
154154
155 /// Get the the metadata as an MDNode.
156 ///
157 /// \pre Any KindID metadata is implemented using \a MDNode.
158 MDNode *getMDNode(unsigned KindID) const {
159 if (!hasMetadata())
160 return nullptr;
161 return getMDNodeImpl(KindID);
162 }
163
164 /// Get the the metadata as an MDNode.
165 ///
166 /// \pre Any KindID metadata is implemented using \a MDNode.
167 MDNode *getMDNode(StringRef Kind) const {
168 if (!hasMetadata())
169 return nullptr;
170 return getMDNodeImpl(Kind);
171 }
172
155173 /// getAllMetadata - Get all metadata attached to this Instruction. The first
156174 /// element of each pair returned is the KindID, the second element is the
157175 /// metadata value. This list is returned sorted by the KindID.
272290 // These are all implemented in Metadata.cpp.
273291 MDNode *getMetadataImpl(unsigned KindID) const;
274292 MDNode *getMetadataImpl(StringRef Kind) const;
293 MDNode *getMDNodeImpl(unsigned KindID) const;
294 MDNode *getMDNodeImpl(StringRef Kind) const;
275295 void getAllMetadataImpl(SmallVectorImpl > &)const;
276296 void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl
277297 MDNode*> > &) const;
608608 return getMetadataImpl(getContext().getMDKindID(Kind));
609609 }
610610
611 MDNode *Instruction::getMDNodeImpl(unsigned KindID) const {
612 return getMetadataImpl(KindID);
613 }
614
615 MDNode *Instruction::getMDNodeImpl(StringRef Kind) const {
616 return getMetadataImpl(Kind);
617 }
618
611619 void Instruction::dropUnknownMetadata(ArrayRef KnownIDs) {
612620 SmallSet KnownSet;
613621 KnownSet.insert(KnownIDs.begin(), KnownIDs.end());