stripAndComputeConstantOffsets is only called on pointers; check this
with an assert instead of failing and requiring callers to check for failure. llvm-svn: 173998
This commit is contained in:
@@ -665,8 +665,7 @@ Value *llvm::SimplifyAddInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW,
|
|||||||
/// no constant offsets applied.
|
/// no constant offsets applied.
|
||||||
static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
|
static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
|
||||||
Value *&V) {
|
Value *&V) {
|
||||||
if (!V->getType()->isPointerTy())
|
assert(V->getType()->isPointerTy());
|
||||||
return 0;
|
|
||||||
|
|
||||||
unsigned IntPtrWidth = TD.getPointerSizeInBits();
|
unsigned IntPtrWidth = TD.getPointerSizeInBits();
|
||||||
APInt Offset = APInt::getNullValue(IntPtrWidth);
|
APInt Offset = APInt::getNullValue(IntPtrWidth);
|
||||||
@@ -701,11 +700,7 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout &TD,
|
|||||||
static Constant *computePointerDifference(const DataLayout &TD,
|
static Constant *computePointerDifference(const DataLayout &TD,
|
||||||
Value *LHS, Value *RHS) {
|
Value *LHS, Value *RHS) {
|
||||||
Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
|
Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
|
||||||
if (!LHSOffset)
|
|
||||||
return 0;
|
|
||||||
Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
|
Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
|
||||||
if (!RHSOffset)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// If LHS and RHS are not related via constant offsets to the same base
|
// If LHS and RHS are not related via constant offsets to the same base
|
||||||
// value, there is nothing we can do here.
|
// value, there is nothing we can do here.
|
||||||
@@ -1710,11 +1705,7 @@ static Constant *computePointerICmp(const DataLayout &TD,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
|
Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS);
|
||||||
if (!LHSOffset)
|
|
||||||
return 0;
|
|
||||||
Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
|
Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS);
|
||||||
if (!RHSOffset)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// If LHS and RHS are not related via constant offsets to the same base
|
// If LHS and RHS are not related via constant offsets to the same base
|
||||||
// value, there is nothing we can do here.
|
// value, there is nothing we can do here.
|
||||||
|
|||||||
Reference in New Issue
Block a user