[llvm-commits] CVS: llvm/lib/VMCore/Value.cpp ValueSymbolTable.cpp
Chris Lattner
sabre at nondot.org
Tue Feb 6 22:14:09 PST 2007
Changes in directory llvm/lib/VMCore:
Value.cpp updated: 1.61 -> 1.62
ValueSymbolTable.cpp updated: 1.6 -> 1.7
---
Log message:
eliminate ValueSymbolTable::rename, it has no advantage over using remove+insert.
Make insert/remove assert if used incorrectly instead of returning a bool.
---
Diffs of the changes: (+5 -42)
Value.cpp | 4 +++-
ValueSymbolTable.cpp | 43 ++-----------------------------------------
2 files changed, 5 insertions(+), 42 deletions(-)
Index: llvm/lib/VMCore/Value.cpp
diff -u llvm/lib/VMCore/Value.cpp:1.61 llvm/lib/VMCore/Value.cpp:1.62
--- llvm/lib/VMCore/Value.cpp:1.61 Mon Feb 5 14:47:20 2007
+++ llvm/lib/VMCore/Value.cpp Wed Feb 7 00:13:49 2007
@@ -120,7 +120,9 @@
Name = name;
else if (hasName()) {
if (!name.empty()) { // Replacing name.
- ST->rename(this, name);
+ ST->remove(this);
+ Name = name;
+ ST->insert(this);
} else { // Transitioning from hasName -> noname.
ST->remove(this);
Name.clear();
Index: llvm/lib/VMCore/ValueSymbolTable.cpp
diff -u llvm/lib/VMCore/ValueSymbolTable.cpp:1.6 llvm/lib/VMCore/ValueSymbolTable.cpp:1.7
--- llvm/lib/VMCore/ValueSymbolTable.cpp:1.6 Tue Feb 6 23:52:51 2007
+++ llvm/lib/VMCore/ValueSymbolTable.cpp Wed Feb 7 00:13:49 2007
@@ -103,54 +103,15 @@
}
// Remove a value
-bool ValueSymbolTable::remove(Value *V) {
+void ValueSymbolTable::remove(Value *V) {
assert(V->hasName() && "Value doesn't have name!");
iterator Entry = vmap.find(V->getName());
- if (Entry == vmap.end())
- return false;
+ assert(Entry != vmap.end() && "Entry was not in the symtab!");
DEBUG(DOUT << " Removing Value: " << Entry->second->getName() << "\n");
// Remove the value from the plane...
vmap.erase(Entry);
- return true;
-}
-
-
-// rename - Given a value with a non-empty name, remove its existing entry
-// from the symbol table and insert a new one for Name. This is equivalent to
-// doing "remove(V), V->Name = Name, insert(V)",
-//
-bool ValueSymbolTable::rename(Value *V, const std::string &name) {
- assert(V && "Can't rename a null Value");
- assert(V->hasName() && "Can't rename a nameless Value");
- assert(!V->getName().empty() && "Can't rename an Value with null name");
- assert(V->getName() != name && "Can't rename a Value with same name");
- assert(!name.empty() && "Can't rename a named Value with a null name");
-
- // Find the name
- iterator VI = vmap.find(V->getName());
-
- // If we didn't find it, we're done
- if (VI == vmap.end())
- return false;
-
- // Remove the old entry.
- vmap.erase(VI);
-
- // See if we can insert the new name.
- VI = vmap.lower_bound(name);
-
- // Is there a naming conflict?
- if (VI != vmap.end() && VI->first == name) {
- V->Name = getUniqueName( name);
- vmap.insert(make_pair(V->Name, V));
- } else {
- V->Name = name;
- vmap.insert(VI, make_pair(V->Name, V));
- }
-
- return true;
}
// DumpVal - a std::for_each function for dumping a value
More information about the llvm-commits
mailing list