diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-08-13 18:17:56 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-08-13 18:17:56 +0000 |
commit | ca710e9cc5991369ef1ed5dc9fa5063d8feb24a2 (patch) | |
tree | a857d1d96c0bc4b64d401e5ba2e33b455e5b0d9d /lib/Target/TargetData.cpp | |
parent | 6c0c3010dab5581a994c82d9796e05e177fb279e (diff) |
Bug fix in TargetData::getIndexedOffset: We were using the pointer
type instead of the element type for the element size for arrays.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3302 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/TargetData.cpp')
-rw-r--r-- | lib/Target/TargetData.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 08a6536b78..54acd08966 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -159,15 +159,15 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) { if (Idx[CurIDX]->getType() == Type::UIntTy) { + // Update Ty to refer to current element + Ty = cast<SequentialType>(Ty)->getElementType(); + // Get the array index and the size of each array element. // Both must be known constants, or this will fail. unsigned arrayIdx = cast<ConstantUInt>(Idx[CurIDX])->getValue(); uint64_t elementSize = this->getTypeSize(Ty); Result += arrayIdx * elementSize; - // Update Ty to refer to current element - Ty = cast<SequentialType>(Ty)->getElementType(); - } else if (const StructType *STy = dyn_cast<const StructType>(Ty)) { assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx"); unsigned FieldNo = cast<ConstantUInt>(Idx[CurIDX])->getValue(); |