Changes in directory llvm/lib/Target:
TargetData.cpp updated: 1.57 -> 1.58 --- Log message: Implement a new InvalidateStructLayoutInfo method and add some comments --- Diffs of the changes: (+18 -0) TargetData.cpp | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.57 llvm/lib/Target/TargetData.cpp:1.58 --- llvm/lib/Target/TargetData.cpp:1.57 Tue Aug 2 14:25:02 2005 +++ llvm/lib/Target/TargetData.cpp Fri Jan 13 18:07:34 2006 @@ -131,6 +131,9 @@ BoolAlignment = 1; } +/// Layouts - The lazy cache of structure layout information maintained by +/// TargetData. +/// static std::map<std::pair<const TargetData*,const StructType*>, StructLayout> *Layouts = 0; @@ -165,6 +168,21 @@ } } +/// InvalidateStructLayoutInfo - TargetData speculatively caches StructLayout +/// objects. If a TargetData object is alive when types are being refined and +/// removed, this method must be called whenever a StructType is removed to +/// avoid a dangling pointer in this cache. +void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const { + if (!Layouts) return; // No cache. + + std::map<std::pair<const TargetData*,const StructType*>, + StructLayout>::iterator I = Layouts->find(std::make_pair(this, Ty)); + if (I != Layouts->end()) + Layouts->erase(I); +} + + + static inline void getTypeInfo(const Type *Ty, const TargetData *TD, uint64_t &Size, unsigned char &Alignment) { assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits