[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp SlotCalculator.h
Chris Lattner
sabre at nondot.org
Fri Feb 9 21:03:06 PST 2007
Changes in directory llvm/lib/Bytecode/Writer:
SlotCalculator.cpp updated: 1.98 -> 1.99
SlotCalculator.h updated: 1.39 -> 1.40
---
Log message:
simplify getOrCreateTypeSlot, eliminat doInsertType. Eliminate post-order iteration stuff.
---
Diffs of the changes: (+10 -32)
SlotCalculator.cpp | 39 ++++++++++-----------------------------
SlotCalculator.h | 3 ---
2 files changed, 10 insertions(+), 32 deletions(-)
Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.98 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.99
--- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.98 Fri Feb 9 22:57:36 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Fri Feb 9 23:02:50 2007
@@ -24,7 +24,6 @@
#include "llvm/TypeSymbolTable.h"
#include "llvm/Type.h"
#include "llvm/ValueSymbolTable.h"
-#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/STLExtras.h"
#include <algorithm>
#include <functional>
@@ -355,34 +354,16 @@
int SlotNo = getTypeSlot(Ty); // Check to see if it's already in!
if (SlotNo != -1) return (unsigned)SlotNo;
- // Insert the current type before any subtypes. This is important because
- // recursive types elements are inserted in a bottom up order. Changing
- // this here can break things. For example:
- //
- // global { \2 * } { { \2 }* null }
- //
- unsigned ResultSlot = doInsertType(Ty);
-
- // Loop over any contained types in the definition... in post
- // order.
- for (po_iterator<const Type*> I = po_begin(Ty), E = po_end(Ty);
- I != E; ++I) {
- if (*I != Ty && !TypeMap.count(*I)) {
- // If we haven't seen this sub type before, add it to our type table!
- doInsertType(*I);
- }
- }
- return ResultSlot;
-}
-
-
-// doInsertType - This is a small helper function to be called only
-// be insertType.
-//
-unsigned SlotCalculator::doInsertType(const Type *Ty) {
// Insert into TypeMap.
- unsigned DestSlot = TypeMap[Ty] = Types.size();
+ unsigned ResultSlot = TypeMap[Ty] = Types.size();
Types.push_back(Ty);
- SC_DEBUG(" Inserting type [" << DestSlot << "] = " << *Ty << "\n" );
- return DestSlot;
+ SC_DEBUG(" Inserting type [" << ResultSlot << "] = " << *Ty << "\n" );
+
+ // Loop over any contained types in the definition, ensuring they are also
+ // inserted.
+ for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end();
+ I != E; ++I)
+ getOrCreateTypeSlot(*I);
+
+ return ResultSlot;
}
Index: llvm/lib/Bytecode/Writer/SlotCalculator.h
diff -u llvm/lib/Bytecode/Writer/SlotCalculator.h:1.39 llvm/lib/Bytecode/Writer/SlotCalculator.h:1.40
--- llvm/lib/Bytecode/Writer/SlotCalculator.h:1.39 Fri Feb 9 22:54:01 2007
+++ llvm/lib/Bytecode/Writer/SlotCalculator.h Fri Feb 9 23:02:50 2007
@@ -107,9 +107,6 @@
void CreateSlotIfNeeded(const Value *V);
unsigned getOrCreateTypeSlot(const Type *T);
- // doInsertValue - Small helper function to be called only be insertVal.
- unsigned doInsertType(const Type *T);
-
// processModule - Process all of the module level function declarations and
// types that are available.
//
More information about the llvm-commits
mailing list