[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Oct 4 09:52:58 PDT 2005
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.133 -> 1.134
---
Log message:
minor cleanup/fastpath for the bcreader. This speeds up the bcreader
from 1:41 -> 1:39 on the large python .bc file in a release build.
---
Diffs of the changes: (+23 -2)
Constants.cpp | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.133 llvm/lib/VMCore/Constants.cpp:1.134
--- llvm/lib/VMCore/Constants.cpp:1.133 Mon Oct 3 20:17:50 2005
+++ llvm/lib/VMCore/Constants.cpp Tue Oct 4 11:52:46 2005
@@ -520,6 +520,9 @@
typedef std::map<MapKey, ConstantClass *> MapTy;
typedef typename MapTy::iterator MapIterator;
private:
+ /// Map - This is the main map from the element descriptor to the Constants.
+ /// This is the primary way we avoid creating two of the same shape
+ /// constant.
MapTy Map;
typedef std::map<const TypeClass*, MapIterator> AbstractTypeMapTy;
@@ -548,6 +551,24 @@
Exists = !IP.second;
return IP.first;
}
+
+ /// SimpleRemove - This method removes the specified constant from the map,
+ /// without updating type information. This should only be used when we're
+ /// changing an element in the map, making this the second half of a 'move'
+ /// operation.
+ void SimpleRemove(ConstantClass *CP) {
+ MapIterator I = Map.find(MapKey((TypeClass*)CP->getRawType(),
+ getValType(CP)));
+ if (I == Map.end() || I->second != CP) {
+ // FIXME: This should not use a linear scan. If this gets to be a
+ // performance problem, someone should look at this.
+ for (I = Map.begin(); I != Map.end() && I->second != CP; ++I)
+ /* empty */;
+ }
+ assert(I != Map.end() && "Constant not found in constant table!");
+ assert(I->second == CP && "Didn't find correct element?");
+ Map.erase(I);
+ }
/// getOrCreate - Return the specified constant from the map, creating it if
/// necessary.
@@ -1383,7 +1404,7 @@
// in place!
if (I != ArrayConstants.map_end() && I->second == this)
++I; // Do not invalidate iterator!
- ArrayConstants.remove(this); // Remove old shape from the map.
+ ArrayConstants.SimpleRemove(this); // Remove old shape from the map.
// Update to the new values.
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
@@ -1445,7 +1466,7 @@
// in place!
if (I != StructConstants.map_end() && I->second == this)
++I; // Do not invalidate iterator!
- StructConstants.remove(this); // Remove old shape from the map.
+ StructConstants.SimpleRemove(this); // Remove old shape from the map.
// Update to the new values.
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
More information about the llvm-commits
mailing list