From 7c69c1ebda62ff05fa704f62f6cad4d4e7c29510 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Wed, 14 Jan 2015 01:22:47 +0000 Subject: [PATCH] Utils: Extract cloneMDNode(), NFC llvm-svn: 225917 --- llvm/lib/Transforms/Utils/ValueMapper.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 2e2795c..04c5ff2 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -203,6 +203,21 @@ static Metadata *cloneMDLocation(const MDLocation *Node, ValueToValueMapTy &VM, 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(Node), VM, Flags, TypeMapper, \ + Materializer); \ + break; +#include "llvm/IR/Metadata.def" + } +} + /// \brief Map a distinct MDNode. /// /// 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. - Metadata *NewMD; - switch (Node->getMetadataID()) { - default: - llvm_unreachable("Invalid UniquableMDNode subclass"); -#define HANDLE_UNIQUABLE_LEAF(CLASS) \ - case Metadata::CLASS##Kind: \ - NewMD = \ - clone##CLASS(cast(Node), VM, Flags, TypeMapper, Materializer); \ - break; -#include "llvm/IR/Metadata.def" - } + Metadata *NewMD = cloneMDNode(Node, VM, Flags, TypeMapper, Materializer); Dummy->replaceAllUsesWith(NewMD); MDNode::deleteTemporary(Dummy); return mapToMetadata(VM, Node, NewMD); -- 2.7.4