diff options
-rw-r--r-- | include/llvm/ValueSymbolTable.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/llvm/ValueSymbolTable.h b/include/llvm/ValueSymbolTable.h index 0240696..7497dae 100644 --- a/include/llvm/ValueSymbolTable.h +++ b/include/llvm/ValueSymbolTable.h @@ -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. |