mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Simplify ConstantExpr::getInBoundsGetElementPtr and fix a possible crash, if
constant folding eliminated the GEP instruction. - clang was hitting this on its test suite (for x86_64, at least). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78698 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1442,14 +1442,11 @@ Constant *ConstantExpr::getGetElementPtr(Constant *C, Value* const *Idxs,
|
|||||||
Constant *ConstantExpr::getInBoundsGetElementPtr(Constant *C,
|
Constant *ConstantExpr::getInBoundsGetElementPtr(Constant *C,
|
||||||
Value* const *Idxs,
|
Value* const *Idxs,
|
||||||
unsigned NumIdx) {
|
unsigned NumIdx) {
|
||||||
// Get the result type of the getelementptr!
|
Constant *Result = getGetElementPtr(C, Idxs, NumIdx);
|
||||||
const Type *Ty =
|
// Set in bounds attribute, assuming constant folding didn't eliminate the
|
||||||
GetElementPtrInst::getIndexedType(C->getType(), Idxs, Idxs+NumIdx);
|
// GEP.
|
||||||
assert(Ty && "GEP indices invalid!");
|
if (GEPOperator *GEP = dyn_cast<GEPOperator>(Result))
|
||||||
unsigned As = cast<PointerType>(C->getType())->getAddressSpace();
|
GEP->setIsInBounds(true);
|
||||||
Constant *Result = getGetElementPtrTy(PointerType::get(Ty, As), C,
|
|
||||||
Idxs, NumIdx);
|
|
||||||
cast<GEPOperator>(Result)->setIsInBounds(true);
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user