X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetData.cpp;h=f83adefbee3426e2124a3c093aef21a6d274db9e;hb=73b43b9b549a75fb0015c825df68abd95705a67c;hp=64332a0df56e50f874f207dfa35b048d0868c6f7;hpb=d102593b425da27fa96359300ff0e3d547d0ac8d;p=oota-llvm.git diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 64332a0df56..f83adefbee3 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -27,14 +27,13 @@ #include "llvm/ADT/StringExtras.h" #include #include -#include using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. -namespace { - // Register the default SparcV9 implementation... - RegisterPass X("targetdata", "Target Data Layout"); -} + +// Register the default SparcV9 implementation... +static RegisterPass X("targetdata", "Target Data Layout", false, + true); char TargetData::ID = 0; //===----------------------------------------------------------------------===// @@ -49,10 +48,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) { // Loop over each of the elements, placing them in memory... for (unsigned i = 0, e = NumElements; i != e; ++i) { const Type *Ty = ST->getElementType(i); - unsigned TyAlign = ST->isPacked() ? - 1 : TD.getABITypeAlignment(Ty); - uint64_t TySize = ST->isPacked() ? - TD.getTypeStoreSize(Ty) : TD.getABITypeSize(Ty); + unsigned TyAlign = ST->isPacked() ? 1 : TD.getABITypeAlignment(Ty); // Add padding if necessary to align the data element properly... StructSize = (StructSize + TyAlign - 1)/TyAlign * TyAlign; @@ -61,7 +57,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) { StructAlignment = std::max(TyAlign, StructAlignment); MemberOffsets[i] = StructSize; - StructSize += TySize; // Consume space for this data item + StructSize += TD.getABITypeSize(Ty); // Consume space for this data item } // Empty structures have alignment of 1 byte. @@ -318,6 +314,8 @@ unsigned TargetData::getAlignmentInfo(AlignTypeEnum AlignType, : Alignments[BestMatchIdx].PrefAlign; } +namespace { + /// LayoutInfo - The lazy cache of structure layout information maintained by /// TargetData. Note that the struct types must have been free'd before /// llvm_shutdown is called (and thus this is deallocated) because all the @@ -342,8 +340,10 @@ struct DenseMapLayoutKeyInfo { }; typedef DenseMap LayoutInfoTy; -static ManagedStatic LayoutInfo; +} + +static ManagedStatic LayoutInfo; TargetData::~TargetData() { if (LayoutInfo.isConstructed()) {