summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetData.cpp
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-08-13 18:17:56 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-08-13 18:17:56 +0000
commita3efa260ea17e61951d6c034241054b0caebb452 (patch)
tree0353c20bed7c0caac17b74b3695d2984a58f6167 /llvm/lib/Target/TargetData.cpp
parent4f729affe6db2bf9c61ad08827811d9bcdbb702f (diff)
downloadbcm5719-llvm-a3efa260ea17e61951d6c034241054b0caebb452.tar.gz
bcm5719-llvm-a3efa260ea17e61951d6c034241054b0caebb452.zip
Bug fix in TargetData::getIndexedOffset: We were using the pointer
type instead of the element type for the element size for arrays. llvm-svn: 3302
Diffstat (limited to 'llvm/lib/Target/TargetData.cpp')
-rw-r--r--llvm/lib/Target/TargetData.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Target/TargetData.cpp b/llvm/lib/Target/TargetData.cpp
index 08a6536b78a..54acd08966e 100644
--- a/llvm/lib/Target/TargetData.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud