diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-13 22:54:01 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-13 22:54:01 +0000 |
commit | 11f60fd65a79350de1e9f295ea2c997bdc534ea9 (patch) | |
tree | 2a72eec0a206f64110c2c29bdeae9db1357a5356 /llvm/lib/Transforms/Utils/ValueMapper.cpp | |
parent | 3ef4e4a98c9c8ea57ee803897895458087856dbb (diff) | |
download | bcm5719-llvm-11f60fd65a79350de1e9f295ea2c997bdc534ea9.tar.gz bcm5719-llvm-11f60fd65a79350de1e9f295ea2c997bdc534ea9.zip |
ValueMapper: Resolve cycles on the new nodes
Fix a major bug from r265456. Although it's now much rarer, ValueMapper
sometimes has to duplicate cycles. The
might-transitively-reference-a-temporary counts don't decrement on their
own when there are cycles, and you need to call MDNode::resolveCycles to
fix it.
r265456 was checking the input nodes to see if they were unresolved.
This is useless; they should never be unresolved. Instead we should
check the output nodes and resolve cycles on them.
llvm-svn: 266258
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 76875ec7385..772800c2e61 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -587,6 +587,7 @@ void MDNodeMapper::mapDistinctNodes() { void MDNodeMapper::mapUniquedNodes() { // Construct uniqued nodes, building forward references as necessary. + SmallVector<MDNode *, 16> CyclicNodes; for (auto *N : POT) { if (N->isDistinct()) continue; @@ -601,11 +602,12 @@ void MDNodeMapper::mapUniquedNodes() { TempMDNode ClonedN = D.Placeholder ? std::move(D.Placeholder) : N->clone(); remapOperands(D, *ClonedN); - M.mapToMetadata(N, MDNode::replaceWithUniqued(std::move(ClonedN))); + CyclicNodes.push_back(MDNode::replaceWithUniqued(std::move(ClonedN))); + M.mapToMetadata(N, CyclicNodes.back()); } // Resolve cycles. - for (auto *N : POT) + for (auto *N : CyclicNodes) if (!N->isResolved()) N->resolveCycles(); } |