diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-10 05:02:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-10 05:02:50 +0000 |
commit | 1e91abbf6182e54d18d62b3bc30e8e453080367d (patch) | |
tree | 6cf26ede1bad051d6824522c63d9d760ff392207 /llvm/lib/Bytecode | |
parent | d090c6beedd8c36d3b9d31523beb2a6001c57e74 (diff) | |
download | bcm5719-llvm-1e91abbf6182e54d18d62b3bc30e8e453080367d.tar.gz bcm5719-llvm-1e91abbf6182e54d18d62b3bc30e8e453080367d.zip |
simplify getOrCreateTypeSlot, eliminat doInsertType. Eliminate post-order iteration stuff.
llvm-svn: 34127
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r-- | llvm/lib/Bytecode/Writer/SlotCalculator.cpp | 39 | ||||
-rw-r--r-- | llvm/lib/Bytecode/Writer/SlotCalculator.h | 3 |
2 files changed, 10 insertions, 32 deletions
diff --git a/llvm/lib/Bytecode/Writer/SlotCalculator.cpp b/llvm/lib/Bytecode/Writer/SlotCalculator.cpp index 00f7cbc5aea..d4c16e9bac5 100644 --- a/llvm/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/llvm/lib/Bytecode/Writer/SlotCalculator.cpp @@ -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 @@ unsigned SlotCalculator::getOrCreateTypeSlot(const Type *Ty) { 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; } diff --git a/llvm/lib/Bytecode/Writer/SlotCalculator.h b/llvm/lib/Bytecode/Writer/SlotCalculator.h index 9223fb71f42..a8e22103403 100644 --- a/llvm/lib/Bytecode/Writer/SlotCalculator.h +++ b/llvm/lib/Bytecode/Writer/SlotCalculator.h @@ -107,9 +107,6 @@ private: 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. // |