llvm.org GIT mirror llvm / 6f73d6f
Utils: Extract cloneMDTuple(), NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225912 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
1 changed file(s) with 14 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
218218 return false;
219219 }
220220
221 static Metadata *cloneMDTuple(const UniquableMDNode *Node,
222 ValueToValueMapTy &VM, RemapFlags Flags,
223 ValueMapTypeRemapper *TypeMapper,
224 ValueMaterializer *Materializer) {
225 SmallVector Elts;
226 Elts.reserve(Node->getNumOperands());
227 for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I)
228 Elts.push_back(mapMetadataOp(Node->getOperand(I), VM, Flags, TypeMapper,
229 Materializer));
230
231 return MDTuple::get(Node->getContext(), Elts);
232 }
233
221234 /// \brief Map a uniqued MDNode.
222235 ///
223236 /// Uniqued nodes may not need to be recreated (they may map to themselves).
240253 }
241254
242255 // At least one operand needs remapping.
243 SmallVector Elts;
244 Elts.reserve(Node->getNumOperands());
245 for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I)
246 Elts.push_back(mapMetadataOp(Node->getOperand(I), VM, Flags, TypeMapper,
247 Materializer));
248
249 MDNode *NewMD = MDTuple::get(Node->getContext(), Elts);
256 Metadata *NewMD = cloneMDTuple(Node, VM, Flags, TypeMapper, Materializer);
250257 Dummy->replaceAllUsesWith(NewMD);
251258 MDNode::deleteTemporary(Dummy);
252259 return mapToMetadata(VM, Node, NewMD);