summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-09-28 22:07:19 +0000
committerDan Gohman <gohman@apple.com>2010-09-28 22:07:19 +0000
commit25a7bc90814527f9351dfcc4cec96f2a57f7c8ec (patch)
tree0725d60bb97199daddc58c017479d891abeeb407 /llvm/lib/VMCore/Metadata.cpp
parenta3181e2d79c831c310914b4b3e2786bf914b68ab (diff)
downloadbcm5719-llvm-25a7bc90814527f9351dfcc4cec96f2a57f7c8ec.tar.gz
bcm5719-llvm-25a7bc90814527f9351dfcc4cec96f2a57f7c8ec.zip
When an MDNode changes to become identical to another MDNode,
delete the MDNode that changed, rather than the other MDNode. This is less work, because it doesn't require the changed node to be re-inserted into the uniquing map and it doesn't require the is-function-local flag to be recomputed. Also, it avoids trouble when the existing node is part of a complicated data structure. llvm-svn: 114996
Diffstat (limited to 'llvm/lib/VMCore/Metadata.cpp')
-rw-r--r--llvm/lib/VMCore/Metadata.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp
index 162884c5f68..0b8e8dfa8b3 100644
--- a/llvm/lib/VMCore/Metadata.cpp
+++ b/llvm/lib/VMCore/Metadata.cpp
@@ -339,15 +339,14 @@ void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) {
// Now that the node is out of the folding set, get ready to reinsert it.
// First, check to see if another node with the same operands already exists
- // in the set. If it doesn't exist, this returns the position to insert it.
+ // in the set. If so, then this node is redundant.
FoldingSetNodeID ID;
Profile(ID);
void *InsertPoint;
if (MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint)) {
- N->replaceAllUsesWith(this);
- N->destroy();
- N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint);
- assert(N == 0 && "shouldn't be in the map now!"); (void)N;
+ replaceAllUsesWith(N);
+ destroy();
+ return;
}
// InsertPoint will have been set by the FindNodeOrInsertPos call.
OpenPOWER on IntegriCloud