Before existing NamedMDNode entry in the symbol table, remove any existing entry...
authorDevang Patel <dpatel@apple.com>
Tue, 26 Jan 2010 22:03:41 +0000 (22:03 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 26 Jan 2010 22:03:41 +0000 (22:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94600 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ValueSymbolTable.h

index 0240696821f482d168e78b1e2d95c970323910da..7497dae3c469b49cfb3090f255929f21e2209ca3 100644 (file)
@@ -194,9 +194,15 @@ public:
 /// @name Mutators
 /// @{
 public:
-  /// insert - The method inserts a new entry into the stringmap.
+  /// insert - The method inserts a new entry into the stringmap. This will
+  /// replace existing entry, if any.
   void insert(StringRef Name,  NamedMDNode *Node) {
-    (void) mmap.GetOrCreateValue(Name, Node);
+    StringMapEntry<NamedMDNode *> &Entry = 
+      mmap.GetOrCreateValue(Name, Node);
+    if (Entry.getValue() != Node) {
+      mmap.remove(&Entry);
+      (void) mmap.GetOrCreateValue(Name, Node);
+    }
   }
   
   /// This method removes a NamedMDNode from the symbol table.