mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-23 11:38:38 +00:00
Fix Transforms/InstCombine/2007-05-14-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37057 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
24bb504e15
commit
6b6aef8efc
@ -6454,16 +6454,25 @@ Instruction *InstCombiner::commonPointerCastTransforms(CastInst &CI) {
|
|||||||
while (Offset) {
|
while (Offset) {
|
||||||
if (const StructType *STy = dyn_cast<StructType>(GEPIdxTy)) {
|
if (const StructType *STy = dyn_cast<StructType>(GEPIdxTy)) {
|
||||||
const StructLayout *SL = TD->getStructLayout(STy);
|
const StructLayout *SL = TD->getStructLayout(STy);
|
||||||
unsigned Elt = SL->getElementContainingOffset(Offset);
|
if (Offset < (int64_t)SL->getSizeInBytes()) {
|
||||||
NewIndices.push_back(ConstantInt::get(Type::Int32Ty, Elt));
|
unsigned Elt = SL->getElementContainingOffset(Offset);
|
||||||
|
NewIndices.push_back(ConstantInt::get(Type::Int32Ty, Elt));
|
||||||
|
|
||||||
Offset -= SL->getElementOffset(Elt);
|
Offset -= SL->getElementOffset(Elt);
|
||||||
GEPIdxTy = STy->getElementType(Elt);
|
GEPIdxTy = STy->getElementType(Elt);
|
||||||
|
} else {
|
||||||
|
// Otherwise, we can't index into this, bail out.
|
||||||
|
Offset = 0;
|
||||||
|
OrigBase = 0;
|
||||||
|
}
|
||||||
} else if (isa<ArrayType>(GEPIdxTy) || isa<VectorType>(GEPIdxTy)) {
|
} else if (isa<ArrayType>(GEPIdxTy) || isa<VectorType>(GEPIdxTy)) {
|
||||||
const SequentialType *STy = cast<SequentialType>(GEPIdxTy);
|
const SequentialType *STy = cast<SequentialType>(GEPIdxTy);
|
||||||
uint64_t EltSize = TD->getTypeSize(STy->getElementType());
|
if (uint64_t EltSize = TD->getTypeSize(STy->getElementType())) {
|
||||||
NewIndices.push_back(ConstantInt::get(IntPtrTy, Offset/EltSize));
|
NewIndices.push_back(ConstantInt::get(IntPtrTy,Offset/EltSize));
|
||||||
Offset %= EltSize;
|
Offset %= EltSize;
|
||||||
|
} else {
|
||||||
|
NewIndices.push_back(ConstantInt::get(IntPtrTy, 0));
|
||||||
|
}
|
||||||
GEPIdxTy = STy->getElementType();
|
GEPIdxTy = STy->getElementType();
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, we can't index into this, bail out.
|
// Otherwise, we can't index into this, bail out.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user