Utils: Extract cloneMDNode(), NFC

llvm-svn: 225917
This commit is contained in:
Duncan P. N. Exon Smith 2015-01-14 01:22:47 +00:00
parent b6515d6a71
commit 7c69c1ebda
1 changed files with 16 additions and 11 deletions

View File

@ -203,6 +203,21 @@ static Metadata *cloneMDLocation(const MDLocation *Node, ValueToValueMapTy &VM,
mapMetadataOp(Node->getInlinedAt(), VM, Flags, TypeMapper, Materializer)); mapMetadataOp(Node->getInlinedAt(), VM, Flags, TypeMapper, Materializer));
} }
static Metadata *cloneMDNode(const UniquableMDNode *Node, ValueToValueMapTy &VM,
RemapFlags Flags, ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer) {
switch (Node->getMetadataID()) {
default:
llvm_unreachable("Invalid UniquableMDNode subclass");
#define HANDLE_UNIQUABLE_LEAF(CLASS) \
case Metadata::CLASS##Kind: \
return clone##CLASS(cast<CLASS>(Node), VM, Flags, TypeMapper, \
Materializer); \
break;
#include "llvm/IR/Metadata.def"
}
}
/// \brief Map a distinct MDNode. /// \brief Map a distinct MDNode.
/// ///
/// Distinct nodes are not uniqued, so they must always recreated. /// Distinct nodes are not uniqued, so they must always recreated.
@ -264,17 +279,7 @@ static Metadata *mapUniquedNode(const UniquableMDNode *Node,
} }
// At least one operand needs remapping. // At least one operand needs remapping.
Metadata *NewMD; Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer);
switch (Node->getMetadataID()) {
default:
llvm_unreachable("Invalid UniquableMDNode subclass");
#define HANDLE_UNIQUABLE_LEAF(CLASS) \
case Metadata::CLASS##Kind: \
NewMD = \
clone##CLASS(cast<CLASS>(Node), VM, Flags, TypeMapper, Materializer); \
break;
#include "llvm/IR/Metadata.def"
}
Dummy->replaceAllUsesWith(NewMD); Dummy->replaceAllUsesWith(NewMD);
MDNode::deleteTemporary(Dummy); MDNode::deleteTemporary(Dummy);
return mapToMetadata(VM, Node, NewMD); return mapToMetadata(VM, Node, NewMD);