aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-01-11 23:29:26 +0000
committerChris Lattner <sabre@nondot.org>2004-01-11 23:29:26 +0000
commit9380297bc0dacd02d331cd5cffee115ecf26ae48 (patch)
tree54542b7b06a7c149f28ec35e40ea83ca571e1fd1 /lib
parentb08bdc4a161313bb09a73e6c61f0cb0669e291c7 (diff)
Fix a regression that I introduced yesterday. :(
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp24
-rw-r--r--lib/VMCore/SlotCalculator.cpp24
2 files changed, 32 insertions, 16 deletions
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index ca87b603ee..b40d94ea24 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -132,24 +132,32 @@ void SlotCalculator::processModule() {
// all non-value types are pushed to the end of the type table, giving nice
// low numbers to the types that can be used by instructions, thus reducing
// the amount of explodage we suffer.
- if (!IgnoreNamedNodes && Table[Type::TypeTyID].size() >= 64) {
+ if (!IgnoreNamedNodes && Table[Type::TypeTyID].size() >= 0/*64*/) {
// Scan through the type table moving value types to the start of the table.
- TypePlane &Types = Table[Type::TypeTyID];
+ TypePlane *Types = &Table[Type::TypeTyID];
unsigned FirstNonValueTypeID = 0;
- for (unsigned i = 0, e = Types.size(); i != e; ++i)
- if (cast<Type>(Types[i])->isFirstClassType() ||
- cast<Type>(Types[i])->isPrimitiveType()) {
+ for (unsigned i = 0, e = Types->size(); i != e; ++i)
+ if (cast<Type>((*Types)[i])->isFirstClassType() ||
+ cast<Type>((*Types)[i])->isPrimitiveType()) {
// Check to see if we have to shuffle this type around. If not, don't
// do anything.
if (i != FirstNonValueTypeID) {
+ assert(i != Type::TypeTyID && FirstNonValueTypeID != Type::TypeTyID &&
+ "Cannot move around the type plane!");
+
// Swap the type ID's.
- std::swap(Types[i], Types[FirstNonValueTypeID]);
+ std::swap((*Types)[i], (*Types)[FirstNonValueTypeID]);
// Keep the NodeMap up to date.
- std::swap(NodeMap[Types[i]], NodeMap[Types[FirstNonValueTypeID]]);
+ NodeMap[(*Types)[i]] = i;
+ NodeMap[(*Types)[FirstNonValueTypeID]] = FirstNonValueTypeID;
// When we move a type, make sure to move its value plane as needed.
- std::swap(Table[i], Table[FirstNonValueTypeID]);
+ if (Table.size() > FirstNonValueTypeID) {
+ if (Table.size() <= i) Table.resize(i+1);
+ std::swap(Table[i], Table[FirstNonValueTypeID]);
+ Types = &Table[Type::TypeTyID];
+ }
}
++FirstNonValueTypeID;
}
diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp
index ca87b603ee..b40d94ea24 100644
--- a/lib/VMCore/SlotCalculator.cpp
+++ b/lib/VMCore/SlotCalculator.cpp
@@ -132,24 +132,32 @@ void SlotCalculator::processModule() {
// all non-value types are pushed to the end of the type table, giving nice
// low numbers to the types that can be used by instructions, thus reducing
// the amount of explodage we suffer.
- if (!IgnoreNamedNodes && Table[Type::TypeTyID].size() >= 64) {
+ if (!IgnoreNamedNodes && Table[Type::TypeTyID].size() >= 0/*64*/) {
// Scan through the type table moving value types to the start of the table.
- TypePlane &Types = Table[Type::TypeTyID];
+ TypePlane *Types = &Table[Type::TypeTyID];
unsigned FirstNonValueTypeID = 0;
- for (unsigned i = 0, e = Types.size(); i != e; ++i)
- if (cast<Type>(Types[i])->isFirstClassType() ||
- cast<Type>(Types[i])->isPrimitiveType()) {
+ for (unsigned i = 0, e = Types->size(); i != e; ++i)
+ if (cast<Type>((*Types)[i])->isFirstClassType() ||
+ cast<Type>((*Types)[i])->isPrimitiveType()) {
// Check to see if we have to shuffle this type around. If not, don't
// do anything.
if (i != FirstNonValueTypeID) {
+ assert(i != Type::TypeTyID && FirstNonValueTypeID != Type::TypeTyID &&
+ "Cannot move around the type plane!");
+
// Swap the type ID's.
- std::swap(Types[i], Types[FirstNonValueTypeID]);
+ std::swap((*Types)[i], (*Types)[FirstNonValueTypeID]);
// Keep the NodeMap up to date.
- std::swap(NodeMap[Types[i]], NodeMap[Types[FirstNonValueTypeID]]);
+ NodeMap[(*Types)[i]] = i;
+ NodeMap[(*Types)[FirstNonValueTypeID]] = FirstNonValueTypeID;
// When we move a type, make sure to move its value plane as needed.
- std::swap(Table[i], Table[FirstNonValueTypeID]);
+ if (Table.size() > FirstNonValueTypeID) {
+ if (Table.size() <= i) Table.resize(i+1);
+ std::swap(Table[i], Table[FirstNonValueTypeID]);
+ Types = &Table[Type::TypeTyID];
+ }
}
++FirstNonValueTypeID;
}