mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-29 10:25:12 +00:00
Patch for a new instcombine xform, patch contributed by Nick Lewycky!
This implements Transforms/InstCombine/2006-05-10-InvalidIndexUndef.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28450 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -273,7 +273,8 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
|
|||||||
}
|
}
|
||||||
} else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) {
|
} else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) {
|
||||||
if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
|
if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
|
||||||
if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
|
if ((uint64_t)CI->getRawValue() >= ATy->getNumElements())
|
||||||
|
C = UndefValue::get(ATy->getElementType());
|
||||||
if (ConstantArray *CA = dyn_cast<ConstantArray>(C))
|
if (ConstantArray *CA = dyn_cast<ConstantArray>(C))
|
||||||
C = CA->getOperand((unsigned)CI->getRawValue());
|
C = CA->getOperand((unsigned)CI->getRawValue());
|
||||||
else if (isa<ConstantAggregateZero>(C))
|
else if (isa<ConstantAggregateZero>(C))
|
||||||
@@ -283,7 +284,8 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
} else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) {
|
} else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) {
|
||||||
if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) return 0;
|
if ((uint64_t)CI->getRawValue() >= PTy->getNumElements())
|
||||||
|
C = UndefValue::get(PTy->getElementType());
|
||||||
if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C))
|
if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C))
|
||||||
C = CP->getOperand((unsigned)CI->getRawValue());
|
C = CP->getOperand((unsigned)CI->getRawValue());
|
||||||
else if (isa<ConstantAggregateZero>(C))
|
else if (isa<ConstantAggregateZero>(C))
|
||||||
|
Reference in New Issue
Block a user