X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FTypesContext.h;h=ad09478bbcfd5e675e5057f49ce0dea417d5c08f;hb=6c3541d5597033bdb2f26f5ade811b482c32a39a;hp=93a801b9f660c2bb7526e465b184c95341c05b74;hpb=c0a6a2afcb2af269b989e5cf0eb471c1e1a7263f;p=oota-llvm.git diff --git a/lib/VMCore/TypesContext.h b/lib/VMCore/TypesContext.h index 93a801b9f66..ad09478bbcf 100644 --- a/lib/VMCore/TypesContext.h +++ b/lib/VMCore/TypesContext.h @@ -15,6 +15,7 @@ #ifndef LLVM_TYPESCONTEXT_H #define LLVM_TYPESCONTEXT_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include @@ -68,7 +69,7 @@ static unsigned getSubElementHash(const Type *Ty) { class IntegerValType { uint32_t bits; public: - IntegerValType(uint16_t numbits) : bits(numbits) {} + IntegerValType(uint32_t numbits) : bits(numbits) {} static IntegerValType get(const IntegerType *Ty) { return IntegerValType(Ty->getBitWidth()); @@ -157,8 +158,8 @@ class StructValType { std::vector ElTypes; bool packed; public: - StructValType(const std::vector &args, bool isPacked) - : ElTypes(args), packed(isPacked) {} + StructValType(ArrayRef args, bool isPacked) + : ElTypes(args.vec()), packed(isPacked) {} static StructValType get(const StructType *ST) { std::vector ElTypes; @@ -187,8 +188,8 @@ class FunctionValType { std::vector ArgTypes; bool isVarArg; public: - FunctionValType(const Type *ret, const std::vector &args, - bool isVA) : RetTy(ret), ArgTypes(args), isVarArg(isVA) {} + FunctionValType(const Type *ret, ArrayRef args, bool isVA) + : RetTy(ret), ArgTypes(args.vec()), isVarArg(isVA) {} static FunctionValType get(const FunctionType *FT); @@ -216,7 +217,6 @@ protected: /// std::multimap TypesByHash; -public: ~TypeMapBase() { // PATypeHolder won't destroy non-abstract types. // We can't destroy them by simply iterating, because @@ -236,6 +236,7 @@ public: } } +public: void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) { std::multimap::iterator I = TypesByHash.lower_bound(Hash); @@ -281,7 +282,6 @@ class TypeMap : public TypeMapBase { std::map Map; public: typedef typename std::map::iterator iterator; - ~TypeMap() { print("ON EXIT"); } inline TypeClass *get(const ValType &V) { iterator I = Map.find(V); @@ -318,7 +318,7 @@ public: // The old record is now out-of-date, because one of the children has been // updated. Remove the obsolete entry from the map. unsigned NumErased = Map.erase(ValType::get(Ty)); - assert(NumErased && "Element not found!"); NumErased = NumErased; + assert(NumErased && "Element not found!"); (void)NumErased; // Remember the structural hash for the type before we start hacking on it, // in case we need it later. @@ -345,7 +345,7 @@ public: // We already have this type in the table. Get rid of the newly refined // type. TypeClass *NewTy = cast((Type*)I->second.get()); - Ty->unlockedRefineAbstractTypeTo(NewTy); + Ty->refineAbstractTypeTo(NewTy); return; } } else { @@ -360,31 +360,33 @@ public: if (I->second == Ty) { // Remember the position of the old type if we see it in our scan. Entry = I; + continue; + } + + if (!TypesEqual(Ty, I->second)) + continue; + + TypeClass *NewTy = cast((Type*)I->second.get()); + + // Remove the old entry form TypesByHash. If the hash values differ + // now, remove it from the old place. Otherwise, continue scanning + // within this hashcode to reduce work. + if (NewTypeHash != OldTypeHash) { + RemoveFromTypesByHash(OldTypeHash, Ty); } else { - if (TypesEqual(Ty, I->second)) { - TypeClass *NewTy = cast((Type*)I->second.get()); - - // Remove the old entry form TypesByHash. If the hash values differ - // now, remove it from the old place. Otherwise, continue scanning - // withing this hashcode to reduce work. - if (NewTypeHash != OldTypeHash) { - RemoveFromTypesByHash(OldTypeHash, Ty); - } else { - if (Entry == E) { - // Find the location of Ty in the TypesByHash structure if we - // haven't seen it already. - while (I->second != Ty) { - ++I; - assert(I != E && "Structure doesn't contain type??"); - } - Entry = I; - } - TypesByHash.erase(Entry); + if (Entry == E) { + // Find the location of Ty in the TypesByHash structure if we + // haven't seen it already. + while (I->second != Ty) { + ++I; + assert(I != E && "Structure doesn't contain type??"); } - Ty->unlockedRefineAbstractTypeTo(NewTy); - return; + Entry = I; } + TypesByHash.erase(Entry); } + Ty->refineAbstractTypeTo(NewTy); + return; } // If there is no existing type of the same structure, we reinsert an