[llvm-commits] [llvm] r43620 - in /llvm/trunk: include/llvm/Target/ lib/Analysis/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/ lib/ExecutionEngine/Interpreter/ lib/ExecutionEngine/JIT/ lib/Target/ lib/Transforms/IPO/ lib/Transforms/Scalar/ lib/Transforms/Utils/

Duncan Sands baldrick at free.fr
Thu Nov 1 13:53:17 PDT 2007


Author: baldrick
Date: Thu Nov  1 15:53:16 2007
New Revision: 43620

URL: http://llvm.org/viewvc/llvm-project?rev=43620&view=rev
Log:
Executive summary: getTypeSize -> getTypeStoreSize / getABITypeSize.
The meaning of getTypeSize was not clear - clarifying it is important
now that we have x86 long double and arbitrary precision integers.
The issue with long double is that it requires 80 bits, and this is
not a multiple of its alignment.  This gives a primitive type for
which getTypeSize differed from getABITypeSize.  For arbitrary precision
integers it is even worse: there is the minimum number of bits needed to
hold the type (eg: 36 for an i36), the maximum number of bits that will
be overwriten when storing the type (40 bits for i36) and the ABI size
(i.e. the storage size rounded up to a multiple of the alignment; 64 bits
for i36).

This patch removes getTypeSize (not really - it is still there but
deprecated to allow for a gradual transition).  Instead there is:

(1) getTypeSizeInBits - a number of bits that suffices to hold all
values of the type.  For a primitive type, this is the minimum number
of bits.  For an i36 this is 36 bits.  For x86 long double it is 80.
This corresponds to gcc's TYPE_PRECISION.

(2) getTypeStoreSizeInBits - the maximum number of bits that is
written when storing the type (or read when reading it).  For an
i36 this is 40 bits, for an x86 long double it is 80 bits.  This
is the size alias analysis is interested in (getTypeStoreSize
returns the number of bytes).  There doesn't seem to be anything
corresponding to this in gcc.

(3) getABITypeSizeInBits - this is getTypeStoreSizeInBits rounded
up to a multiple of the alignment.  For an i36 this is 64, for an
x86 long double this is 96 or 128 depending on the OS.  This is the
spacing between consecutive elements when you form an array out of
this type (getABITypeSize returns the number of bytes).  This is
TYPE_SIZE in gcc.

Since successive elements in a SequentialType (arrays, pointers
and vectors) need to be aligned, the spacing between them will be
given by getABITypeSize.  This means that the size of an array
is the length times the getABITypeSize.  It also means that GEP
computations need to use getABITypeSize when computing offsets.
Furthermore, if an alloca allocates several elements at once then
these too need to be aligned, so the size of the alloca has to be
the number of elements multiplied by getABITypeSize.  Logically
speaking this doesn't have to be the case when allocating just
one element, but it is simpler to also use getABITypeSize in this
case.  So alloca's and mallocs should use getABITypeSize.  Finally,
since gcc's only notion of size is that given by getABITypeSize, if
you want to output assembler etc the same as gcc then getABITypeSize
is the size you want.

Since a store will overwrite no more than getTypeStoreSize bytes,
and a read will read no more than that many bytes, this is the
notion of size appropriate for alias analysis calculations.

In this patch I have corrected all type size uses except some of
those in ScalarReplAggregates, lib/Codegen, lib/Target (the hard
cases).  I will get around to auditing these too at some point,
but I could do with some help.

Finally, I made one change which I think wise but others might
consider pointless and suboptimal: in an unpacked struct the
amount of space allocated for a field is now given by the ABI
size rather than getTypeStoreSize.  I did this because every
other place that reserves memory for a type (eg: alloca) now
uses getABITypeSize, and I didn't want to make an exception
for unpacked structs, i.e. I did it to make things more uniform.
This only effects structs containing long doubles and arbitrary
precision integers.  If someone wants to pack these types more
tightly they can always use a packed struct.

Modified:
    llvm/trunk/include/llvm/Target/TargetData.h
    llvm/trunk/lib/Analysis/AliasAnalysis.cpp
    llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp
    llvm/trunk/lib/Analysis/AliasSetTracker.cpp
    llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
    llvm/trunk/lib/Analysis/ConstantFolding.cpp
    llvm/trunk/lib/Analysis/LoadValueNumbering.cpp
    llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
    llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
    llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
    llvm/trunk/lib/Target/TargetData.cpp
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
    llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
    llvm/trunk/lib/Transforms/Scalar/LICM.cpp
    llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
    llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp

Modified: llvm/trunk/include/llvm/Target/TargetData.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Target/TargetData.h (original)
+++ llvm/trunk/include/llvm/Target/TargetData.h Thu Nov  1 15:53:16 2007
@@ -155,26 +155,48 @@
   /// Target pointer size, in bits
   unsigned char getPointerSizeInBits()   const { return 8*PointerMemSize; }
 
-  /// getTypeSize - Return the number of bytes necessary to hold the specified
-  /// type.
-  uint64_t getTypeSize(const Type *Ty) const;
-
-  /// getABITypeSize - Return the number of bytes allocated for the specified
-  /// type when used as an element in a larger object, including alignment
-  /// padding.
-  uint64_t getABITypeSize(const Type *Ty) const {
+  /// getTypeSizeInBits - Return the number of bits necessary to hold the
+  /// specified type.  For example, returns 36 for i36 and 80 for x86_fp80.
+  uint64_t getTypeSizeInBits(const Type* Ty) const;
+
+  /// getTypeStoreSize - Return the maximum number of bytes that may be
+  /// overwritten by storing the specified type.  For example, returns 5
+  /// for i36 and 10 for x86_fp80.
+  uint64_t getTypeStoreSize(const Type *Ty) const {
+    return (getTypeSizeInBits(Ty)+7)/8;
+  }
+
+  /// getTypeStoreSizeInBits - Return the maximum number of bits that may be
+  /// overwritten by storing the specified type; always a multiple of 8.  For
+  /// example, returns 40 for i36 and 80 for x86_fp80.
+  uint64_t getTypeStoreSizeInBits(const Type *Ty) const {
+    return 8*getTypeStoreSize(Ty);
+  }
+
+  /// getABITypeSize - Return the offset in bytes between successive objects
+  /// of the specified type, including alignment padding.  This is the amount
+  /// that alloca reserves for this type.  For example, returns 12 or 16 for
+  /// x86_fp80, depending on alignment.
+  uint64_t getABITypeSize(const Type* Ty) const {
     unsigned char Align = getABITypeAlignment(Ty);
-    return (getTypeSize(Ty) + Align - 1)/Align*Align;
+    return (getTypeStoreSize(Ty) + Align - 1)/Align*Align;
   }
 
-  /// getTypeSizeInBits - Return the number of bits necessary to hold the
-  /// specified type.
-  uint64_t getTypeSizeInBits(const Type* Ty) const;
+  /// getABITypeSizeInBits - Return the offset in bits between successive
+  /// objects of the specified type, including alignment padding; always a
+  /// multiple of 8.  This is the amount that alloca reserves for this type.
+  /// For example, returns 96 or 128 for x86_fp80, depending on alignment.
+  uint64_t getABITypeSizeInBits(const Type* Ty) const {
+    return 8*getABITypeSize(Ty);
+  }
 
-  /// getABITypeSizeInBits - Return the number of bytes allocated for the
-  /// specified type when used as an element in a larger object, including
-  ///  alignment padding.
-  uint64_t getABITypeSizeInBits(const Type* Ty) const;
+  /// getTypeSize - Obsolete method, do not use.  Replaced by getTypeStoreSize
+  /// and getABITypeSize.  For alias analysis of loads and stores you probably
+  /// want getTypeStoreSize.  Use getABITypeSize for GEP computations and alloca
+  /// sizing.
+  uint64_t getTypeSize(const Type *Ty) const {
+    return getTypeStoreSize(Ty);
+  }
 
   /// getABITypeAlignment - Return the minimum ABI-required alignment for the
   /// specified type.
@@ -238,6 +260,10 @@
     return StructSize;
   }
   
+  uint64_t getSizeInBits() const {
+    return 8*StructSize;
+  }
+
   unsigned getAlignment() const {
     return StructAlignment;
   }

Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Thu Nov  1 15:53:16 2007
@@ -95,7 +95,7 @@
 
 AliasAnalysis::ModRefResult
 AliasAnalysis::getModRefInfo(LoadInst *L, Value *P, unsigned Size) {
-  return alias(L->getOperand(0), TD->getTypeSize(L->getType()),
+  return alias(L->getOperand(0), TD->getTypeStoreSize(L->getType()),
                P, Size) ? Ref : NoModRef;
 }
 
@@ -103,8 +103,8 @@
 AliasAnalysis::getModRefInfo(StoreInst *S, Value *P, unsigned Size) {
   // If the stored address cannot alias the pointer in question, then the
   // pointer cannot be modified by the store.
-  if (!alias(S->getOperand(1), TD->getTypeSize(S->getOperand(0)->getType()),
-             P, Size))
+  if (!alias(S->getOperand(1),
+             TD->getTypeStoreSize(S->getOperand(0)->getType()), P, Size))
     return NoModRef;
 
   // If the pointer is a pointer to constant memory, then it could not have been

Modified: llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysisEvaluator.cpp Thu Nov  1 15:53:16 2007
@@ -137,12 +137,12 @@
        I1 != E; ++I1) {
     unsigned I1Size = 0;
     const Type *I1ElTy = cast<PointerType>((*I1)->getType())->getElementType();
-    if (I1ElTy->isSized()) I1Size = TD.getTypeSize(I1ElTy);
+    if (I1ElTy->isSized()) I1Size = TD.getTypeStoreSize(I1ElTy);
 
     for (std::set<Value *>::iterator I2 = Pointers.begin(); I2 != I1; ++I2) {
       unsigned I2Size = 0;
       const Type *I2ElTy =cast<PointerType>((*I2)->getType())->getElementType();
-      if (I2ElTy->isSized()) I2Size = TD.getTypeSize(I2ElTy);
+      if (I2ElTy->isSized()) I2Size = TD.getTypeStoreSize(I2ElTy);
 
       switch (AA.alias(*I1, I1Size, *I2, I2Size)) {
       case AliasAnalysis::NoAlias:
@@ -169,7 +169,7 @@
          V != Ve; ++V) {
       unsigned Size = 0;
       const Type *ElTy = cast<PointerType>((*V)->getType())->getElementType();
-      if (ElTy->isSized()) Size = TD.getTypeSize(ElTy);
+      if (ElTy->isSized()) Size = TD.getTypeStoreSize(ElTy);
 
       switch (AA.getModRefInfo(*C, *V, Size)) {
       case AliasAnalysis::NoModRef:

Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasSetTracker.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/AliasSetTracker.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp Thu Nov  1 15:53:16 2007
@@ -269,7 +269,7 @@
 bool AliasSetTracker::add(LoadInst *LI) {
   bool NewPtr;
   AliasSet &AS = addPointer(LI->getOperand(0),
-                            AA.getTargetData().getTypeSize(LI->getType()),
+                            AA.getTargetData().getTypeStoreSize(LI->getType()),
                             AliasSet::Refs, NewPtr);
   if (LI->isVolatile()) AS.setVolatile();
   return NewPtr;
@@ -279,7 +279,7 @@
   bool NewPtr;
   Value *Val = SI->getOperand(0);
   AliasSet &AS = addPointer(SI->getOperand(1),
-                            AA.getTargetData().getTypeSize(Val->getType()),
+                            AA.getTargetData().getTypeStoreSize(Val->getType()),
                             AliasSet::Mods, NewPtr);
   if (SI->isVolatile()) AS.setVolatile();
   return NewPtr;
@@ -395,7 +395,7 @@
 }
 
 bool AliasSetTracker::remove(LoadInst *LI) {
-  unsigned Size = AA.getTargetData().getTypeSize(LI->getType());
+  unsigned Size = AA.getTargetData().getTypeStoreSize(LI->getType());
   AliasSet *AS = findAliasSetForPointer(LI->getOperand(0), Size);
   if (!AS) return false;
   remove(*AS);
@@ -403,7 +403,8 @@
 }
 
 bool AliasSetTracker::remove(StoreInst *SI) {
-  unsigned Size = AA.getTargetData().getTypeSize(SI->getOperand(0)->getType());
+  unsigned Size =
+    AA.getTargetData().getTypeStoreSize(SI->getOperand(0)->getType());
   AliasSet *AS = findAliasSetForPointer(SI->getOperand(1), Size);
   if (!AS) return false;
   remove(*AS);

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Thu Nov  1 15:53:16 2007
@@ -364,7 +364,7 @@
         // global/alloca/malloc, it cannot be accessing the global (it's
         // undefined to load or store bytes before or after an object).
         const Type *ElTy = cast<PointerType>(O1->getType())->getElementType();
-        unsigned GlobalSize = getTargetData().getTypeSize(ElTy);
+        unsigned GlobalSize = getTargetData().getABITypeSize(ElTy);
         if (GlobalSize < V2Size && V2Size != ~0U)
           return NoAlias;
       }
@@ -382,7 +382,7 @@
         // global/alloca/malloc, it cannot be accessing the object (it's
         // undefined to load or store bytes before or after an object).
         const Type *ElTy = cast<PointerType>(O2->getType())->getElementType();
-        unsigned GlobalSize = getTargetData().getTypeSize(ElTy);
+        unsigned GlobalSize = getTargetData().getABITypeSize(ElTy);
         if (GlobalSize < V1Size && V1Size != ~0U)
           return NoAlias;
       }

Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original)
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Thu Nov  1 15:53:16 2007
@@ -74,7 +74,7 @@
         Offset += TD.getStructLayout(ST)->getElementOffset(CI->getZExtValue());
       } else {
         const SequentialType *SQT = cast<SequentialType>(*GTI);
-        Offset += TD.getTypeSize(SQT->getElementType())*CI->getSExtValue();
+        Offset += TD.getABITypeSize(SQT->getElementType())*CI->getSExtValue();
       }
     }
     return true;

Modified: llvm/trunk/lib/Analysis/LoadValueNumbering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoadValueNumbering.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/LoadValueNumbering.cpp (original)
+++ llvm/trunk/lib/Analysis/LoadValueNumbering.cpp Thu Nov  1 15:53:16 2007
@@ -293,7 +293,7 @@
   Function *F = LoadBB->getParent();
 
   // Find out how many bytes of memory are loaded by the load instruction...
-  unsigned LoadSize = getAnalysis<TargetData>().getTypeSize(LI->getType());
+  unsigned LoadSize = getAnalysis<TargetData>().getTypeStoreSize(LI->getType());
   AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
 
   // Figure out if the load is invalidated from the entry of the block it is in

Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Thu Nov  1 15:53:16 2007
@@ -78,20 +78,20 @@
     uint64_t pointerSize = 0;
     if (StoreInst* S = dyn_cast<StoreInst>(QI)) {
       pointer = S->getPointerOperand();
-      pointerSize = TD.getTypeSize(S->getOperand(0)->getType());
+      pointerSize = TD.getTypeStoreSize(S->getOperand(0)->getType());
     } else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
       pointer = L->getPointerOperand();
-      pointerSize = TD.getTypeSize(L->getType());
+      pointerSize = TD.getTypeStoreSize(L->getType());
     } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
       pointer = AI;
       if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
         pointerSize = C->getZExtValue() * \
-                      TD.getTypeSize(AI->getAllocatedType());
+                      TD.getABITypeSize(AI->getAllocatedType());
       else
         pointerSize = ~0UL;
     } else if (VAArgInst* V = dyn_cast<VAArgInst>(QI)) {
       pointer = V->getOperand(0);
-      pointerSize = TD.getTypeSize(V->getType());
+      pointerSize = TD.getTypeStoreSize(V->getType());
     } else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
       pointer = F->getPointerOperand();
       
@@ -287,15 +287,15 @@
   bool queryIsVolatile = false;
   if (StoreInst* S = dyn_cast<StoreInst>(query)) {
     dependee = S->getPointerOperand();
-    dependeeSize = TD.getTypeSize(S->getOperand(0)->getType());
+    dependeeSize = TD.getTypeStoreSize(S->getOperand(0)->getType());
     queryIsVolatile = S->isVolatile();
   } else if (LoadInst* L = dyn_cast<LoadInst>(query)) {
     dependee = L->getPointerOperand();
-    dependeeSize = TD.getTypeSize(L->getType());
+    dependeeSize = TD.getTypeStoreSize(L->getType());
     queryIsVolatile = L->isVolatile();
   } else if (VAArgInst* V = dyn_cast<VAArgInst>(query)) {
     dependee = V->getOperand(0);
-    dependeeSize = TD.getTypeSize(V->getType());
+    dependeeSize = TD.getTypeStoreSize(V->getType());
   } else if (FreeInst* F = dyn_cast<FreeInst>(query)) {
     dependee = F->getPointerOperand();
     
@@ -330,7 +330,7 @@
       }
       
       pointer = S->getPointerOperand();
-      pointerSize = TD.getTypeSize(S->getOperand(0)->getType());
+      pointerSize = TD.getTypeStoreSize(S->getOperand(0)->getType());
     } else if (LoadInst* L = dyn_cast<LoadInst>(QI)) {
       // All volatile loads/stores depend on each other
       if (queryIsVolatile && L->isVolatile()) {
@@ -343,17 +343,17 @@
       }
       
       pointer = L->getPointerOperand();
-      pointerSize = TD.getTypeSize(L->getType());
+      pointerSize = TD.getTypeStoreSize(L->getType());
     } else if (AllocationInst* AI = dyn_cast<AllocationInst>(QI)) {
       pointer = AI;
       if (ConstantInt* C = dyn_cast<ConstantInt>(AI->getArraySize()))
         pointerSize = C->getZExtValue() * \
-                      TD.getTypeSize(AI->getAllocatedType());
+                      TD.getABITypeSize(AI->getAllocatedType());
       else
         pointerSize = ~0UL;
     } else if (VAArgInst* V = dyn_cast<VAArgInst>(QI)) {
       pointer = V->getOperand(0);
-      pointerSize = TD.getTypeSize(V->getType());
+      pointerSize = TD.getTypeStoreSize(V->getType());
     } else if (FreeInst* F = dyn_cast<FreeInst>(QI)) {
       pointer = F->getPointerOperand();
       

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Thu Nov  1 15:53:16 2007
@@ -3524,7 +3524,7 @@
           MVT::ValueType slotVT = 
                   (Node->getOpcode() == ISD::FP_EXTEND) ? oldVT : newVT;
           const Type *Ty = MVT::getTypeForValueType(slotVT);
-          uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+          uint64_t TySize = TLI.getTargetData()->getABITypeSize(Ty);
           unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
           MachineFunction &MF = DAG.getMachineFunction();
           int SSFI =
@@ -3618,7 +3618,7 @@
         // slots and always reusing the same one.  We currently always create
         // new ones, as reuse may inhibit scheduling.
         const Type *Ty = MVT::getTypeForValueType(ExtraVT);
-        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+        uint64_t TySize = TLI.getTargetData()->getABITypeSize(Ty);
         unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
         MachineFunction &MF = DAG.getMachineFunction();
         int SSFI =

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Thu Nov  1 15:53:16 2007
@@ -482,7 +482,7 @@
       Align = TM.getTargetData()->getPreferredTypeAlignmentShift(Type);
       if (Align == 0) {
         // Alignment of vector types.  FIXME!
-        Align = TM.getTargetData()->getTypeSize(Type);
+        Align = TM.getTargetData()->getABITypeSize(Type);
         Align = Log2_64(Align);
       }
     }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu Nov  1 15:53:16 2007
@@ -261,7 +261,7 @@
     if (AllocaInst *AI = dyn_cast<AllocaInst>(I))
       if (ConstantInt *CUI = dyn_cast<ConstantInt>(AI->getArraySize())) {
         const Type *Ty = AI->getAllocatedType();
-        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+        uint64_t TySize = TLI.getTargetData()->getABITypeSize(Ty);
         unsigned Align = 
           std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty),
                    AI->getAlignment());
@@ -2335,7 +2335,7 @@
     return;   // getValue will auto-populate this.
 
   const Type *Ty = I.getAllocatedType();
-  uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+  uint64_t TySize = TLI.getTargetData()->getABITypeSize(Ty);
   unsigned Align =
     std::max((unsigned)TLI.getTargetData()->getPrefTypeAlignment(Ty),
              I.getAlignment());
@@ -3546,7 +3546,7 @@
         // Otherwise, create a stack slot and emit a store to it before the
         // asm.
         const Type *Ty = OpVal->getType();
-        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+        uint64_t TySize = TLI.getTargetData()->getABITypeSize(Ty);
         unsigned Align  = TLI.getTargetData()->getPrefTypeAlignment(Ty);
         MachineFunction &MF = DAG.getMachineFunction();
         int SSFI = MF.getFrameInfo()->CreateStackObject(TySize, Align);
@@ -3804,7 +3804,7 @@
     Src = DAG.getNode(ISD::ZERO_EXTEND, IntPtr, Src);
 
   // Scale the source by the type size.
-  uint64_t ElementSize = TD->getTypeSize(I.getType()->getElementType());
+  uint64_t ElementSize = TD->getABITypeSize(I.getType()->getElementType());
   Src = DAG.getNode(ISD::MUL, Src.getValueType(),
                     Src, getIntPtrConstant(ElementSize));
 
@@ -3917,7 +3917,7 @@
       const StructType *STy = cast<StructType>(Ty->getElementType());
       unsigned StructAlign =
           Log2_32(getTargetData()->getCallFrameTypeAlignment(STy));
-      unsigned StructSize  = getTargetData()->getTypeSize(STy);
+      unsigned StructSize  = getTargetData()->getABITypeSize(STy);
       Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs);
       Flags |= (StructSize  << ISD::ParamFlags::ByValSizeOffs);
     }
@@ -4047,7 +4047,7 @@
       const StructType *STy = cast<StructType>(Ty->getElementType());
       unsigned StructAlign =
           Log2_32(getTargetData()->getCallFrameTypeAlignment(STy));
-      unsigned StructSize  = getTargetData()->getTypeSize(STy);
+      unsigned StructSize  = getTargetData()->getABITypeSize(STy);
       Flags |= (StructAlign << ISD::ParamFlags::ByValAlignOffs);
       Flags |= (StructSize  << ISD::ParamFlags::ByValSizeOffs);
     }

Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Thu Nov  1 15:53:16 2007
@@ -735,7 +735,7 @@
     return;
   } else if (const ConstantVector *CP = dyn_cast<ConstantVector>(Init)) {
     unsigned ElementSize =
-      getTargetData()->getTypeSize(CP->getType()->getElementType());
+      getTargetData()->getABITypeSize(CP->getType()->getElementType());
     for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i)
       InitializeMemory(CP->getOperand(i), (char*)Addr+i*ElementSize);
     return;
@@ -744,7 +744,7 @@
     StoreValueToMemory(Val, (GenericValue*)Addr, Init->getType());
     return;
   } else if (isa<ConstantAggregateZero>(Init)) {
-    memset(Addr, 0, (size_t)getTargetData()->getTypeSize(Init->getType()));
+    memset(Addr, 0, (size_t)getTargetData()->getABITypeSize(Init->getType()));
     return;
   }
 
@@ -752,7 +752,7 @@
   case Type::ArrayTyID: {
     const ConstantArray *CPA = cast<ConstantArray>(Init);
     unsigned ElementSize =
-      getTargetData()->getTypeSize(CPA->getType()->getElementType());
+      getTargetData()->getABITypeSize(CPA->getType()->getElementType());
     for (unsigned i = 0, e = CPA->getNumOperands(); i != e; ++i)
       InitializeMemory(CPA->getOperand(i), (char*)Addr+i*ElementSize);
     return;
@@ -843,7 +843,7 @@
         const Type *Ty = I->getType()->getElementType();
 
         // Allocate some memory for it!
-        unsigned Size = TD->getTypeSize(Ty);
+        unsigned Size = TD->getABITypeSize(Ty);
         addGlobalMapping(I, new char[Size]);
       } else {
         // External variable reference. Try to use the dynamic loader to
@@ -897,7 +897,7 @@
   DOUT << "Global '" << GV->getName() << "' -> " << GA << "\n";
 
   const Type *ElTy = GV->getType()->getElementType();
-  size_t GVSize = (size_t)getTargetData()->getTypeSize(ElTy);
+  size_t GVSize = (size_t)getTargetData()->getABITypeSize(ElTy);
   if (GA == 0) {
     // If it's not already specified, allocate memory for the global.
     GA = new char[GVSize];

Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Interpreter/Execution.cpp Thu Nov  1 15:53:16 2007
@@ -746,7 +746,7 @@
   unsigned NumElements = 
     getOperandValue(I.getOperand(0), SF).IntVal.getZExtValue();
 
-  unsigned TypeSize = (size_t)TD.getTypeSize(Ty);
+  unsigned TypeSize = (size_t)TD.getABITypeSize(Ty);
 
   // Avoid malloc-ing zero bytes, use max()...
   unsigned MemToAlloc = std::max(1U, NumElements * TypeSize);
@@ -806,7 +806,7 @@
         Idx = (int64_t)IdxGV.IntVal.getZExtValue();
       else 
         assert(0 && "Invalid index type for getelementptr");
-      Total += TD.getTypeSize(ST->getElementType())*Idx;
+      Total += TD.getABITypeSize(ST->getElementType())*Idx;
     }
   }
 

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Thu Nov  1 15:53:16 2007
@@ -337,7 +337,7 @@
     // actually initialize the global after current function has finished
     // compilation.
     const Type *GlobalType = GV->getType()->getElementType();
-    size_t S = getTargetData()->getTypeSize(GlobalType);
+    size_t S = getTargetData()->getABITypeSize(GlobalType);
     size_t A = getTargetData()->getPrefTypeAlignment(GlobalType);
     if (A <= 8) {
       Ptr = malloc(S);

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Thu Nov  1 15:53:16 2007
@@ -899,7 +899,7 @@
   unsigned Size = CPE.Offset;
   const Type *Ty = CPE.isMachineConstantPoolEntry()
     ? CPE.Val.MachineCPVal->getType() : CPE.Val.ConstVal->getType();
-  Size += TheJIT->getTargetData()->getTypeSize(Ty);
+  Size += TheJIT->getTargetData()->getABITypeSize(Ty);
 
   ConstantPoolBase = allocateSpace(Size, 1 << MCP->getConstantPoolAlignment());
   ConstantPool = MCP;

Modified: llvm/trunk/lib/Target/TargetData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Target/TargetData.cpp (original)
+++ llvm/trunk/lib/Target/TargetData.cpp Thu Nov  1 15:53:16 2007
@@ -49,14 +49,13 @@
   // 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;
-    uint64_t TySize;
-    TyAlign = (ST->isPacked() ? 1 : TD.getABITypeAlignment(Ty));
-    TySize = TD.getTypeSize(Ty);
-
-    // Add padding if necessary to make the data element aligned properly...
-    if (StructSize % TyAlign != 0)
-      StructSize = (StructSize/TyAlign + 1) * TyAlign;   // Add padding...
+    unsigned TyAlign = ST->isPacked() ?
+      1 : TD.getABITypeAlignment(Ty);
+    uint64_t TySize  = ST->isPacked() ?
+      TD.getTypeStoreSize(Ty) : TD.getABITypeSize(Ty);
+
+    // Add padding if necessary to align the data element properly...
+    StructSize = (StructSize + TyAlign - 1)/TyAlign * TyAlign;
 
     // Keep track of maximum alignment constraint
     StructAlignment = std::max(TyAlign, StructAlignment);
@@ -406,83 +405,47 @@
 }
 
 
-uint64_t TargetData::getTypeSize(const Type *Ty) const {
+uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
   assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
   switch (Ty->getTypeID()) {
   case Type::LabelTyID:
   case Type::PointerTyID:
-    return getPointerSize();
+    return getPointerSizeInBits();
   case Type::ArrayTyID: {
     const ArrayType *ATy = cast<ArrayType>(Ty);
-    uint64_t Size;
-    unsigned char Alignment;
-    Size = getTypeSize(ATy->getElementType());
-    Alignment = getABITypeAlignment(ATy->getElementType());
-    uint64_t AlignedSize = (Size + Alignment - 1)/Alignment*Alignment;
-    return AlignedSize*ATy->getNumElements();
+    return getABITypeSizeInBits(ATy->getElementType())*ATy->getNumElements();
   }
   case Type::StructTyID: {
     // Get the layout annotation... which is lazily created on demand.
     const StructLayout *Layout = getStructLayout(cast<StructType>(Ty));
-    return Layout->getSizeInBytes();
-  }
-  case Type::IntegerTyID: {
-    unsigned BitWidth = cast<IntegerType>(Ty)->getBitWidth();
-    if (BitWidth <= 8) {
-      return 1;
-    } else if (BitWidth <= 16) {
-      return 2;
-    } else if (BitWidth <= 32) {
-      return 4;
-    } else if (BitWidth <= 64) {
-      return 8;
-    } else {
-      // The size of this > 64 bit type is chosen as a multiple of the
-      // preferred alignment of the largest "native" size the target supports. 
-      // We first obtain the the alignment info for this type and then compute
-      // the next largest multiple of that size.
-      uint64_t size = getAlignmentInfo(INTEGER_ALIGN, BitWidth, false) * 8;
-      return (((BitWidth / (size)) + (BitWidth % size != 0)) * size) / 8;
-    }
-    break;
+    return Layout->getSizeInBits();
   }
+  case Type::IntegerTyID:
+    return cast<IntegerType>(Ty)->getBitWidth();
   case Type::VoidTyID:
-    return 1;
+    return 8;
   case Type::FloatTyID:
-    return 4;
+    return 32;
   case Type::DoubleTyID:
-    return 8;
+    return 64;
   case Type::PPC_FP128TyID:
   case Type::FP128TyID:
-    return 16;
+    return 128;
   // In memory objects this is always aligned to a higher boundary, but
-  // only 10 bytes contain information.
+  // only 80 bits contain information.
   case Type::X86_FP80TyID:
-    return 10;
+    return 80;
   case Type::VectorTyID: {
     const VectorType *PTy = cast<VectorType>(Ty);
-    return PTy->getBitWidth() / 8;
+    return PTy->getBitWidth();
   }
   default:
-    assert(0 && "TargetData::getTypeSize(): Unsupported type");
+    assert(0 && "TargetData::getTypeSizeInBits(): Unsupported type");
     break;
   }
   return 0;
 }
 
-uint64_t TargetData::getTypeSizeInBits(const Type *Ty) const {
-  if (Ty->isInteger())
-    return cast<IntegerType>(Ty)->getBitWidth();
-  else
-    return getTypeSize(Ty) * 8;
-}
-
-uint64_t TargetData::getABITypeSizeInBits(const Type *Ty) const {
-  if (Ty->isInteger())
-    return cast<IntegerType>(Ty)->getBitWidth();
-  else
-    return getABITypeSize(Ty) * 8;
-}
 /*!
   \param abi_or_pref Flag that determines which alignment is returned. true
   returns the ABI alignment, false returns the preferred alignment.
@@ -542,7 +505,7 @@
     break;
   }
 
-  return getAlignmentInfo((AlignTypeEnum)AlignType, getTypeSize(Ty) * 8,
+  return getAlignmentInfo((AlignTypeEnum)AlignType, getTypeSizeInBits(Ty),
                           abi_or_pref);
 }
 
@@ -603,7 +566,7 @@
 
       // Get the array index and the size of each array element.
       int64_t arrayIdx = cast<ConstantInt>(Indices[CurIDX])->getSExtValue();
-      Result += arrayIdx * (int64_t)getTypeSize(Ty);
+      Result += arrayIdx * (int64_t)getABITypeSize(Ty);
     }
   }
 
@@ -623,7 +586,7 @@
     if (Alignment < 4) {
       // If the global is not external, see if it is large.  If so, give it a
       // larger alignment.
-      if (getTypeSize(ElemType) > 128)
+      if (getTypeSizeInBits(ElemType) > 128)
         Alignment = 4;    // 16-byte alignment.
     }
   }

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu Nov  1 15:53:16 2007
@@ -277,7 +277,7 @@
 
     const PointerType *LoadTy =
       cast<PointerType>(Load->getOperand(0)->getType());
-    unsigned LoadSize = (unsigned)TD.getTypeSize(LoadTy->getElementType());
+    unsigned LoadSize = (unsigned)TD.getTypeStoreSize(LoadTy->getElementType());
 
     if (AA.canInstructionRangeModify(BB->front(), *Load, Arg, LoadSize))
       return false;  // Pointer is invalidated!

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Nov  1 15:53:16 2007
@@ -1227,7 +1227,7 @@
         // (2048 bytes currently), as we don't want to introduce a 16M global or
         // something.
         if (NElements->getZExtValue()*
-                     TD.getTypeSize(MI->getAllocatedType()) < 2048) {
+                     TD.getABITypeSize(MI->getAllocatedType()) < 2048) {
           GVI = OptimizeGlobalAddressOfMalloc(GV, MI);
           return true;
         }

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu Nov  1 15:53:16 2007
@@ -634,7 +634,7 @@
           cast<ConstantInt>(AddrInst->getOperand(i))->getZExtValue();
         ConstantOffset += SL->getElementOffset(Idx);
       } else {
-        uint64_t TypeSize = TD->getTypeSize(GTI.getIndexedType());
+        uint64_t TypeSize = TD->getABITypeSize(GTI.getIndexedType());
         if (ConstantInt *CI = dyn_cast<ConstantInt>(AddrInst->getOperand(i))) {
           ConstantOffset += CI->getSExtValue()*TypeSize;
         } else if (TypeSize) {  // Scales of zero don't do anything.

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Thu Nov  1 15:53:16 2007
@@ -137,8 +137,8 @@
              dep != MemoryDependenceAnalysis::NonLocal &&
              isa<StoreInst>(dep)) {
         if (dep != last ||
-             TD.getTypeSize(last->getOperand(0)->getType()) >
-             TD.getTypeSize(BBI->getOperand(0)->getType())) {
+             TD.getTypeStoreSize(last->getOperand(0)->getType()) >
+             TD.getTypeStoreSize(BBI->getOperand(0)->getType())) {
           dep = MD.getDependency(BBI, dep);
           continue;
         }
@@ -210,7 +210,7 @@
   
   Value* depPointer = dependency->getPointerOperand();
   const Type* depType = dependency->getOperand(0)->getType();
-  unsigned depPointerSize = TD.getTypeSize(depType);
+  unsigned depPointerSize = TD.getTypeStoreSize(depType);
   
   // Check for aliasing
   AliasAnalysis::AliasResult A = AA.alias(F->getPointerOperand(), ~0UL,
@@ -329,7 +329,7 @@
         unsigned pointerSize = ~0UL;
         if (ConstantInt* C = dyn_cast<ConstantInt>((*I)->getArraySize()))
           pointerSize = C->getZExtValue() * \
-                        TD.getTypeSize((*I)->getAllocatedType());     
+                        TD.getABITypeSize((*I)->getAllocatedType());
         
         // See if the call site touches it
         AliasAnalysis::ModRefResult A = AA.getModRefInfo(CS, *I, pointerSize);
@@ -394,7 +394,7 @@
     unsigned pointerSize = ~0UL;
     if (ConstantInt* C = dyn_cast<ConstantInt>((*I)->getArraySize()))
       pointerSize = C->getZExtValue() * \
-                    TD.getTypeSize((*I)->getAllocatedType());     
+                    TD.getABITypeSize((*I)->getAllocatedType());
       
     // See if this pointer could alias it
     AliasAnalysis::AliasResult A = AA.alias(*I, pointerSize,

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Thu Nov  1 15:53:16 2007
@@ -4438,7 +4438,7 @@
 
   for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i, ++GTI) {
     Value *Op = GEP->getOperand(i);
-    uint64_t Size = TD.getTypeSize(GTI.getIndexedType()) & PtrSizeMask;
+    uint64_t Size = TD.getABITypeSize(GTI.getIndexedType()) & PtrSizeMask;
     if (ConstantInt *OpC = dyn_cast<ConstantInt>(Op)) {
       if (OpC->isZero()) continue;
       
@@ -4523,7 +4523,7 @@
             return ReplaceInstUsesWith(I, UndefValue::get(I.getType()));
           if (C->isNullValue())
             EmitIt = false;
-          else if (TD->getTypeSize(GTI.getIndexedType()) == 0) {
+          else if (TD->getABITypeSize(GTI.getIndexedType()) == 0) {
             EmitIt = false;  // This is indexing into a zero sized array?
           } else if (isa<ConstantInt>(C))
             return ReplaceInstUsesWith(I, // No comparison is needed here.
@@ -6305,8 +6305,8 @@
   // same, we open the door to infinite loops of various kinds.
   if (!AI.hasOneUse() && CastElTyAlign == AllocElTyAlign) return 0;
 
-  uint64_t AllocElTySize = TD->getTypeSize(AllocElTy);
-  uint64_t CastElTySize = TD->getTypeSize(CastElTy);
+  uint64_t AllocElTySize = TD->getABITypeSize(AllocElTy);
+  uint64_t CastElTySize = TD->getABITypeSize(CastElTy);
   if (CastElTySize == 0 || AllocElTySize == 0) return 0;
 
   // See if we can satisfy the modulus by pulling a scale out of the array
@@ -6573,7 +6573,7 @@
           // is something like [0 x {int, int}]
           const Type *IntPtrTy = TD->getIntPtrType();
           int64_t FirstIdx = 0;
-          if (int64_t TySize = TD->getTypeSize(GEPIdxTy)) {
+          if (int64_t TySize = TD->getABITypeSize(GEPIdxTy)) {
             FirstIdx = Offset/TySize;
             Offset %= TySize;
           
@@ -6605,7 +6605,7 @@
               }
             } else if (isa<ArrayType>(GEPIdxTy) || isa<VectorType>(GEPIdxTy)) {
               const SequentialType *STy = cast<SequentialType>(GEPIdxTy);
-              if (uint64_t EltSize = TD->getTypeSize(STy->getElementType())) {
+              if (uint64_t EltSize = TD->getABITypeSize(STy->getElementType())){
                 NewIndices.push_back(ConstantInt::get(IntPtrTy,Offset/EltSize));
                 Offset %= EltSize;
               } else {
@@ -8644,7 +8644,7 @@
       // insert it.  This explicit cast can make subsequent optimizations more
       // obvious.
       Value *Op = GEP.getOperand(i);
-      if (TD->getTypeSize(Op->getType()) > TD->getPointerSize())
+      if (TD->getTypeSizeInBits(Op->getType()) > TD->getPointerSizeInBits())
         if (Constant *C = dyn_cast<Constant>(Op)) {
           GEP.setOperand(i, ConstantExpr::getTrunc(C, TD->getIntPtrType()));
           MadeChange = true;
@@ -8724,12 +8724,12 @@
           } else if (Constant *GO1C = dyn_cast<Constant>(GO1)) {
             GO1 = ConstantExpr::getIntegerCast(GO1C, SO1->getType(), true);
           } else {
-            unsigned PS = TD->getPointerSize();
-            if (TD->getTypeSize(SO1->getType()) == PS) {
+            unsigned PS = TD->getPointerSizeInBits();
+            if (TD->getTypeSizeInBits(SO1->getType()) == PS) {
               // Convert GO1 to SO1's type.
               GO1 = InsertCastToIntPtrTy(GO1, SO1->getType(), &GEP, this);
 
-            } else if (TD->getTypeSize(GO1->getType()) == PS) {
+            } else if (TD->getTypeSizeInBits(GO1->getType()) == PS) {
               // Convert SO1 to GO1's type.
               SO1 = InsertCastToIntPtrTy(SO1, GO1->getType(), &GEP, this);
             } else {
@@ -8818,8 +8818,8 @@
       const Type *SrcElTy = cast<PointerType>(X->getType())->getElementType();
       const Type *ResElTy=cast<PointerType>(PtrOp->getType())->getElementType();
       if (isa<ArrayType>(SrcElTy) &&
-          TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
-          TD->getTypeSize(ResElTy)) {
+          TD->getABITypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
+          TD->getABITypeSize(ResElTy)) {
         Value *Idx[2];
         Idx[0] = Constant::getNullValue(Type::Int32Ty);
         Idx[1] = GEP.getOperand(1);
@@ -8837,7 +8837,7 @@
       if (isa<ArrayType>(SrcElTy) &&
           (ResElTy == Type::Int8Ty || ResElTy == Type::Int8Ty)) {
         uint64_t ArrayEltSize =
-            TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType());
+            TD->getABITypeSize(cast<ArrayType>(SrcElTy)->getElementType());
         
         // Check to see if "tmp" is a scale by a multiple of ArrayEltSize.  We
         // allow either a mul, shift, or constant here.
@@ -8938,7 +8938,7 @@
   // Note that we only do this for alloca's, because malloc should allocate and
   // return a unique pointer, even for a zero byte allocation.
   if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized() &&
-      TD->getTypeSize(AI.getAllocatedType()) == 0)
+      TD->getABITypeSize(AI.getAllocatedType()) == 0)
     return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
 
   return 0;

Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Thu Nov  1 15:53:16 2007
@@ -366,7 +366,7 @@
     // Don't hoist loads which have may-aliased stores in loop.
     unsigned Size = 0;
     if (LI->getType()->isSized())
-      Size = AA->getTargetData().getTypeSize(LI->getType());
+      Size = AA->getTargetData().getTypeStoreSize(LI->getType());
     return !pointerInvalidatedByLoop(LI->getOperand(0), Size);
   } else if (CallInst *CI = dyn_cast<CallInst>(&I)) {
     // Handle obvious cases efficiently.

Modified: llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/PredicateSimplifier.cpp Thu Nov  1 15:53:16 2007
@@ -1120,11 +1120,8 @@
     uint32_t typeToWidth(const Type *Ty) const {
       if (TD)
         return TD->getTypeSizeInBits(Ty);
-
-      if (const IntegerType *ITy = dyn_cast<IntegerType>(Ty))
-        return ITy->getBitWidth();
-
-      return 0;
+      else
+        return Ty->getPrimitiveSizeInBits();
     }
 
     static bool isRelatedBy(const ConstantRange &CR1, const ConstantRange &CR2,

Modified: llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp?rev=43620&r1=43619&r2=43620&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerAllocations.cpp Thu Nov  1 15:53:16 2007
@@ -116,7 +116,7 @@
       // malloc(type) becomes sbyte *malloc(size)
       Value *MallocArg;
       if (LowerMallocArgToInteger)
-        MallocArg = ConstantInt::get(Type::Int64Ty, TD.getTypeSize(AllocTy));
+        MallocArg = ConstantInt::get(Type::Int64Ty, TD.getABITypeSize(AllocTy));
       else
         MallocArg = ConstantExpr::getSizeOf(AllocTy);
       MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg), 





More information about the llvm-commits mailing list