diff options
author | Dan Gohman <dan433584@gmail.com> | 2013-01-31 00:12:20 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2013-01-31 00:12:20 +0000 |
commit | ed4029bae878703cf77de67bde25a926d5f69f1c (patch) | |
tree | 2962f6db4458a4ada13de264265e1d8862d0b942 /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | a320e00e7462e386999a6b2ece7e16e980d363e5 (diff) | |
download | bcm5719-llvm-ed4029bae878703cf77de67bde25a926d5f69f1c.tar.gz bcm5719-llvm-ed4029bae878703cf77de67bde25a926d5f69f1c.zip |
stripAndComputeConstantOffsets is only called on pointers; check this
with an assert instead of failing and requiring callers to check for failure.
llvm-svn: 173998
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index d97e226c3ae..bc514574066 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -665,8 +665,7 @@ Value *llvm::SimplifyAddInst(Value *Op0, Value *Op1, bool isNSW, bool isNUW, /// no constant offsets applied. static Constant *stripAndComputeConstantOffsets(const DataLayout &TD, Value *&V) { - if (!V->getType()->isPointerTy()) - return 0; + assert(V->getType()->isPointerTy()); unsigned IntPtrWidth = TD.getPointerSizeInBits(); APInt Offset = APInt::getNullValue(IntPtrWidth); @@ -701,11 +700,7 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout &TD, static Constant *computePointerDifference(const DataLayout &TD, Value *LHS, Value *RHS) { Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS); - if (!LHSOffset) - return 0; Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS); - if (!RHSOffset) - return 0; // If LHS and RHS are not related via constant offsets to the same base // value, there is nothing we can do here. @@ -1710,11 +1705,7 @@ static Constant *computePointerICmp(const DataLayout &TD, } Constant *LHSOffset = stripAndComputeConstantOffsets(TD, LHS); - if (!LHSOffset) - return 0; Constant *RHSOffset = stripAndComputeConstantOffsets(TD, RHS); - if (!RHSOffset) - return 0; // If LHS and RHS are not related via constant offsets to the same base // value, there is nothing we can do here. |