summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/ValueMapper.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp
index d967e0a95c6..8aa546c7211 100644
--- a/llvm/lib/Transforms/Utils/ValueMapper.cpp
+++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp
@@ -258,9 +258,11 @@ static Metadata *mapUniquedNode(const MDNode *Node,
// Create a temporary node upfront in case we have a metadata cycle.
auto ClonedMD = Node->clone();
- if (!remap(Node, ClonedMD.get(), Cycles, VM, Flags, TypeMapper, Materializer))
+ if (!remap(Node, ClonedMD.get(), Cycles, VM, Flags, TypeMapper, Materializer)) {
// No operands changed, so use the identity mapping.
+ ClonedMD->replaceAllUsesWith(const_cast<MDNode *>(Node));
return mapToSelf(VM, Node);
+ }
// At least one operand has changed, so uniquify the cloned node.
return mapToMetadata(VM, Node,
OpenPOWER on IntegriCloud