mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-04 18:38:37 +00:00
ConstantFoldLoadThroughGEPConstantExpr wasn't handling pointers to
packed types correctly. llvm-svn: 25470
This commit is contained in:
parent
d2c0ccedd3
commit
40c6c91f56
@ -267,16 +267,29 @@ Constant *llvm::ConstantFoldLoadThroughGEPConstantExpr(Constant *C,
|
||||
return 0;
|
||||
}
|
||||
} else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) {
|
||||
const ArrayType *ATy = cast<ArrayType>(*I);
|
||||
if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
|
||||
if (ConstantArray *CA = dyn_cast<ConstantArray>(C))
|
||||
C = CA->getOperand((unsigned)CI->getRawValue());
|
||||
else if (isa<ConstantAggregateZero>(C))
|
||||
C = Constant::getNullValue(ATy->getElementType());
|
||||
else if (isa<UndefValue>(C))
|
||||
C = UndefValue::get(ATy->getElementType());
|
||||
else
|
||||
if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
|
||||
if ((uint64_t)CI->getRawValue() >= ATy->getNumElements()) return 0;
|
||||
if (ConstantArray *CA = dyn_cast<ConstantArray>(C))
|
||||
C = CA->getOperand((unsigned)CI->getRawValue());
|
||||
else if (isa<ConstantAggregateZero>(C))
|
||||
C = Constant::getNullValue(ATy->getElementType());
|
||||
else if (isa<UndefValue>(C))
|
||||
C = UndefValue::get(ATy->getElementType());
|
||||
else
|
||||
return 0;
|
||||
} else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) {
|
||||
if ((uint64_t)CI->getRawValue() >= PTy->getNumElements()) return 0;
|
||||
if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C))
|
||||
C = CP->getOperand((unsigned)CI->getRawValue());
|
||||
else if (isa<ConstantAggregateZero>(C))
|
||||
C = Constant::getNullValue(PTy->getElementType());
|
||||
else if (isa<UndefValue>(C))
|
||||
C = UndefValue::get(PTy->getElementType());
|
||||
else
|
||||
return 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user