mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-16 06:30:13 +00:00
Undo one of those last fixes -- it was incorrect.
llvm-svn: 6593
This commit is contained in:
parent
6e22f0fa52
commit
15a27e40c6
@ -193,10 +193,12 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy,
|
|||||||
Ty = cast<SequentialType>(Ty)->getElementType();
|
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 the index shd be 0; else this fails.
|
// The size must be a known value, except if arrayIdx is 0.
|
||||||
|
// In particular, don't try to get the type size if the arrayIdx is 0:
|
||||||
|
// 0 index into an unsized type is legal and should be allowed.
|
||||||
int64_t arrayIdx = cast<ConstantSInt>(Idx[CurIDX])->getValue();
|
int64_t arrayIdx = cast<ConstantSInt>(Idx[CurIDX])->getValue();
|
||||||
Result += arrayIdx * (int64_t)getTypeSize(Ty);
|
Result += arrayIdx == 0? 0
|
||||||
|
: arrayIdx * (int64_t)getTypeSize(Ty);
|
||||||
} else {
|
} else {
|
||||||
const StructType *STy = cast<StructType>(Ty);
|
const StructType *STy = cast<StructType>(Ty);
|
||||||
assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
|
assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user