Revert r90371. It was causing build failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90383 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bill Wendling
2009-12-03 01:54:07 +00:00
parent 15d75d9f11
commit cb06403145

View File

@ -315,12 +315,11 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType,
: Alignments[BestMatchIdx].PrefAlign; : Alignments[BestMatchIdx].PrefAlign;
} }
typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
namespace { namespace {
class StructLayoutMap : public AbstractTypeUser { class StructLayoutMap : public AbstractTypeUser {
public:
typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
private:
LayoutInfoTy LayoutInfo; LayoutInfoTy LayoutInfo;
/// refineAbstractType - The callback method invoked when an abstract type is /// refineAbstractType - The callback method invoked when an abstract type is
@ -329,9 +328,14 @@ private:
/// ///
virtual void refineAbstractType(const DerivedType *OldTy, virtual void refineAbstractType(const DerivedType *OldTy,
const Type *) { const Type *) {
assert(LayoutInfo.find(cast<const StructType>(OldTy)) != LayoutInfo.end() && const StructType *STy = dyn_cast<const StructType>(OldTy);
"Abstract value not in local map!"); assert(STy && "This can only track struct types.");
InvalidateEntry(cast<const StructType>(OldTy));
LayoutInfoTy::iterator Iter = LayoutInfo.find(STy);
Iter->second->~StructLayout();
free(Iter->second);
LayoutInfo.erase(Iter);
OldTy->removeAbstractTypeUser(this);
} }
/// typeBecameConcrete - The other case which AbstractTypeUsers must be aware /// typeBecameConcrete - The other case which AbstractTypeUsers must be aware
@ -340,9 +344,14 @@ private:
/// This method notifies ATU's when this occurs for a type. /// This method notifies ATU's when this occurs for a type.
/// ///
virtual void typeBecameConcrete(const DerivedType *AbsTy) { virtual void typeBecameConcrete(const DerivedType *AbsTy) {
assert(LayoutInfo.find(cast<const StructType>(AbsTy)) != LayoutInfo.end() && const StructType *STy = dyn_cast<const StructType>(AbsTy);
"Abstract value not in local map!"); assert(STy && "This can only track struct types.");
InvalidateEntry(cast<const StructType>(AbsTy));
LayoutInfoTy::iterator Iter = LayoutInfo.find(STy);
Iter->second->~StructLayout();
free(Iter->second);
LayoutInfo.erase(Iter);
AbsTy->removeAbstractTypeUser(this);
} }
public: public:
@ -356,21 +365,23 @@ public:
if (Key && Key->isAbstract()) if (Key && Key->isAbstract())
Key->removeAbstractTypeUser(this); Key->removeAbstractTypeUser(this);
Value->~StructLayout(); if (Value) {
free(Value); Value->~StructLayout();
free(Value);
}
} }
} }
void InvalidateEntry(const StructType *Ty) { LayoutInfoTy::iterator end() {
LayoutInfoTy::iterator I = LayoutInfo.find(Ty); return LayoutInfo.end();
if (I == LayoutInfo.end()) return; }
I->second->~StructLayout(); LayoutInfoTy::iterator find(const StructType *&Val) {
free(I->second); return LayoutInfo.find(Val);
LayoutInfo.erase(I); }
if (Ty->isAbstract()) bool erase(LayoutInfoTy::iterator I) {
Ty->removeAbstractTypeUser(this); return LayoutInfo.erase(I);
} }
StructLayout *&operator[](const StructType *STy) { StructLayout *&operator[](const StructType *STy) {
@ -381,7 +392,7 @@ public:
virtual void dump() const {} virtual void dump() const {}
}; };
} // end anonymous namespace } // end namespace llvm
TargetData::~TargetData() { TargetData::~TargetData() {
delete static_cast<StructLayoutMap*>(LayoutMap); delete static_cast<StructLayoutMap*>(LayoutMap);
@ -421,7 +432,15 @@ void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {
if (!LayoutMap) return; // No cache. if (!LayoutMap) return; // No cache.
StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap); StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap);
STM->InvalidateEntry(Ty); LayoutInfoTy::iterator I = STM->find(Ty);
if (I == STM->end()) return;
I->second->~StructLayout();
free(I->second);
STM->erase(I);
if (Ty->isAbstract())
Ty->removeAbstractTypeUser(STM);
} }
std::string TargetData::getStringRepresentation() const { std::string TargetData::getStringRepresentation() const {