From cbb70ce070d220642b038ea101d9c0f9fbf860d6 Mon Sep 17 00:00:00 2001 From: dim Date: Sun, 20 Feb 2011 12:57:14 +0000 Subject: Vendor import of llvm trunk r126079: http://llvm.org/svn/llvm-project/llvm/trunk@126079 --- lib/VMCore/Metadata.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/VMCore/Metadata.cpp') diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index da69c43..0b8e8df 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -339,17 +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; - MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint); - - if (N) { - N->replaceAllUsesWith(this); - N->destroy(); - N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint); - assert(N == 0 && "shouldn't be in the map now!"); (void)N; + if (MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint)) { + replaceAllUsesWith(N); + destroy(); + return; } // InsertPoint will have been set by the FindNodeOrInsertPos call. -- cgit v1.1