[llvm-branch-commits] [llvm-branch] r90372 - /llvm/branches/Apple/Zoidberg/lib/Target/TargetData.cpp
Bill Wendling
isanbard at gmail.com
Wed Dec 2 17:16:13 PST 2009
Author: void
Date: Wed Dec 2 19:16:13 2009
New Revision: 90372
URL: http://llvm.org/viewvc/llvm-project?rev=90372&view=rev
Log:
$ svn merge -c 90371 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r90371 into '.':
U lib/Target/TargetData.cpp
Modified:
llvm/branches/Apple/Zoidberg/lib/Target/TargetData.cpp
Modified: llvm/branches/Apple/Zoidberg/lib/Target/TargetData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Zoidberg/lib/Target/TargetData.cpp?rev=90372&r1=90371&r2=90372&view=diff
==============================================================================
--- llvm/branches/Apple/Zoidberg/lib/Target/TargetData.cpp (original)
+++ llvm/branches/Apple/Zoidberg/lib/Target/TargetData.cpp Wed Dec 2 19:16:13 2009
@@ -323,11 +323,12 @@
: Alignments[BestMatchIdx].PrefAlign;
}
-typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
-
namespace {
class StructLayoutMap : public AbstractTypeUser {
+public:
+ typedef DenseMap<const StructType*, StructLayout*> LayoutInfoTy;
+private:
LayoutInfoTy LayoutInfo;
/// refineAbstractType - The callback method invoked when an abstract type is
@@ -336,14 +337,9 @@
///
virtual void refineAbstractType(const DerivedType *OldTy,
const Type *) {
- const StructType *STy = dyn_cast<const StructType>(OldTy);
- assert(STy && "This can only track struct types.");
-
- LayoutInfoTy::iterator Iter = LayoutInfo.find(STy);
- Iter->second->~StructLayout();
- free(Iter->second);
- LayoutInfo.erase(Iter);
- OldTy->removeAbstractTypeUser(this);
+ assert(LayoutInfo.find(cast<const StructType>(OldTy)) != LayoutInfo.end() &&
+ "Abstract value not in local map!");
+ InvalidateEntry(cast<const StructType>(OldTy));
}
/// typeBecameConcrete - The other case which AbstractTypeUsers must be aware
@@ -352,14 +348,9 @@
/// This method notifies ATU's when this occurs for a type.
///
virtual void typeBecameConcrete(const DerivedType *AbsTy) {
- const StructType *STy = dyn_cast<const StructType>(AbsTy);
- assert(STy && "This can only track struct types.");
-
- LayoutInfoTy::iterator Iter = LayoutInfo.find(STy);
- Iter->second->~StructLayout();
- free(Iter->second);
- LayoutInfo.erase(Iter);
- AbsTy->removeAbstractTypeUser(this);
+ assert(LayoutInfo.find(cast<const StructType>(AbsTy)) != LayoutInfo.end() &&
+ "Abstract value not in local map!");
+ InvalidateEntry(cast<const StructType>(AbsTy));
}
public:
@@ -373,23 +364,21 @@
if (Key && Key->isAbstract())
Key->removeAbstractTypeUser(this);
- if (Value) {
- Value->~StructLayout();
- free(Value);
- }
+ Value->~StructLayout();
+ free(Value);
}
}
- LayoutInfoTy::iterator end() {
- return LayoutInfo.end();
- }
-
- LayoutInfoTy::iterator find(const StructType *&Val) {
- return LayoutInfo.find(Val);
- }
+ void InvalidateEntry(const StructType *Ty) {
+ LayoutInfoTy::iterator I = LayoutInfo.find(Ty);
+ if (I == LayoutInfo.end()) return;
+
+ I->second->~StructLayout();
+ free(I->second);
+ LayoutInfo.erase(I);
- bool erase(LayoutInfoTy::iterator I) {
- return LayoutInfo.erase(I);
+ if (Ty->isAbstract())
+ Ty->removeAbstractTypeUser(this);
}
StructLayout *&operator[](const StructType *STy) {
@@ -400,7 +389,7 @@
virtual void dump() const {}
};
-} // end namespace llvm
+} // end anonymous namespace
TargetData::~TargetData() {
delete static_cast<StructLayoutMap*>(LayoutMap);
@@ -438,17 +427,9 @@
/// avoid a dangling pointer in this cache.
void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const {
if (!LayoutMap) return; // No cache.
-
- StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap);
- 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);
+ StructLayoutMap *STM = static_cast<StructLayoutMap*>(LayoutMap);
+ STM->InvalidateEntry(Ty);
}
std::string TargetData::getStringRepresentation() const {
More information about the llvm-branch-commits
mailing list