[llvm] r225912 - Utils: Extract cloneMDTuple(), NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Tue Jan 13 17:12:14 PST 2015
Author: dexonsmith
Date: Tue Jan 13 19:12:14 2015
New Revision: 225912
URL: http://llvm.org/viewvc/llvm-project?rev=225912&view=rev
Log:
Utils: Extract cloneMDTuple(), NFC
Modified:
llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=225912&r1=225911&r2=225912&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Tue Jan 13 19:12:14 2015
@@ -219,6 +219,19 @@ static bool shouldRemapUniquedNode(const
return false;
}
+static Metadata *cloneMDTuple(const UniquableMDNode *Node,
+ ValueToValueMapTy &VM, RemapFlags Flags,
+ ValueMapTypeRemapper *TypeMapper,
+ ValueMaterializer *Materializer) {
+ SmallVector<Metadata *, 4> Elts;
+ Elts.reserve(Node->getNumOperands());
+ for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I)
+ Elts.push_back(mapMetadataOp(Node->getOperand(I), VM, Flags, TypeMapper,
+ Materializer));
+
+ return MDTuple::get(Node->getContext(), Elts);
+}
+
/// \brief Map a uniqued MDNode.
///
/// Uniqued nodes may not need to be recreated (they may map to themselves).
@@ -241,13 +254,7 @@ static Metadata *mapUniquedNode(const Un
}
// At least one operand needs remapping.
- SmallVector<Metadata *, 4> Elts;
- Elts.reserve(Node->getNumOperands());
- for (unsigned I = 0, E = Node->getNumOperands(); I != E; ++I)
- Elts.push_back(mapMetadataOp(Node->getOperand(I), VM, Flags, TypeMapper,
- Materializer));
-
- MDNode *NewMD = MDTuple::get(Node->getContext(), Elts);
+ Metadata *NewMD = cloneMDTuple(Node, VM, Flags, TypeMapper, Materializer);
Dummy->replaceAllUsesWith(NewMD);
MDNode::deleteTemporary(Dummy);
return mapToMetadata(VM, Node, NewMD);
More information about the llvm-commits
mailing list