mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
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
This commit is contained in:
@@ -159,15 +159,15 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
|
|||||||
|
|
||||||
for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
|
for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
|
||||||
if (Idx[CurIDX]->getType() == Type::UIntTy) {
|
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.
|
// Get the array index and the size of each array element.
|
||||||
// Both must be known constants, or this will fail.
|
// Both must be known constants, or this will fail.
|
||||||
unsigned arrayIdx = cast<ConstantUInt>(Idx[CurIDX])->getValue();
|
unsigned arrayIdx = cast<ConstantUInt>(Idx[CurIDX])->getValue();
|
||||||
uint64_t elementSize = this->getTypeSize(Ty);
|
uint64_t elementSize = this->getTypeSize(Ty);
|
||||||
Result += arrayIdx * elementSize;
|
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)) {
|
} else if (const StructType *STy = dyn_cast<const StructType>(Ty)) {
|
||||||
assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
|
assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
|
||||||
unsigned FieldNo = cast<ConstantUInt>(Idx[CurIDX])->getValue();
|
unsigned FieldNo = cast<ConstantUInt>(Idx[CurIDX])->getValue();
|
||||||
|
Reference in New Issue
Block a user