llvm.org GIT mirror llvm / df7a3b3
Utils: Extract cloneMDNode(), NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225917 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
1 changed file(s) with 16 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
202202 mapMetadataOp(Node->getInlinedAt(), VM, Flags, TypeMapper, Materializer));
203203 }
204204
205 static Metadata *cloneMDNode(const UniquableMDNode *Node, ValueToValueMapTy &VM,
206 RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
207 ValueMaterializer *Materializer) {
208 switch (Node->getMetadataID()) {
209 default:
210 llvm_unreachable("Invalid UniquableMDNode subclass");
211 #define HANDLE_UNIQUABLE_LEAF(CLASS) \
212 case Metadata::CLASS##Kind: \
213 return clone##CLASS(cast(Node), VM, Flags, TypeMapper, \
214 Materializer); \
215 break;
216 #include "llvm/IR/Metadata.def"
217 }
218 }
219
205220 /// \brief Map a distinct MDNode.
206221 ///
207222 /// Distinct nodes are not uniqued, so they must always recreated.
263278 }
264279
265280 // At least one operand needs remapping.
266 Metadata *NewMD;
267 switch (Node->getMetadataID()) {
268 default:
269 llvm_unreachable("Invalid UniquableMDNode subclass");
270 #define HANDLE_UNIQUABLE_LEAF(CLASS) \
271 case Metadata::CLASS##Kind: \
272 NewMD = \
273 clone##CLASS(cast(Node), VM, Flags, TypeMapper, Materializer); \
274 break;
275 #include "llvm/IR/Metadata.def"
276 }
281 Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer);
277282 Dummy->replaceAllUsesWith(NewMD);
278283 MDNode::deleteTemporary(Dummy);
279284 return mapToMetadata(VM, Node, NewMD);