aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/ConstantFold.cpp
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2021-09-24 18:08:56 +0100
committerSimon Pilgrim <llvm-dev@redking.me.uk>2021-09-24 18:18:53 +0100
commitbdee805b3277e04677490f42e62aa28478331254 (patch)
tree3fd6a084e13f9413a5ab7e6a6a1e72eccbd81e48 /llvm/lib/IR/ConstantFold.cpp
parent36eb6c0134afa9d6881e52c002743f4594c859ee (diff)
downloadllvm-bdee805b3277e04677490f42e62aa28478331254.zip
llvm-bdee805b3277e04677490f42e62aa28478331254.tar.gz
llvm-bdee805b3277e04677490f42e62aa28478331254.tar.bz2
[ConstantFold] ConstantFoldGetElementPtr - use APInt::isNegative() instead of getSExtValue() to support big ints
Fixes fuzz test: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=39197
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r--llvm/lib/IR/ConstantFold.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index b3b296b..2c0532b 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -2326,7 +2326,7 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
if (isIndexInRangeOfArrayType(STy->getNumElements(), CI))
// It's in range, skip to the next index.
continue;
- if (CI->getSExtValue() < 0) {
+ if (CI->isNegative()) {
// It's out of range and negative, don't try to factor it.
Unknown = true;
continue;
@@ -2337,7 +2337,7 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *PointeeTy, Constant *C,
for (unsigned I = 0, E = CV->getNumElements(); I != E; ++I) {
auto *CI = cast<ConstantInt>(CV->getElementAsConstant(I));
InRange &= isIndexInRangeOfArrayType(STy->getNumElements(), CI);
- if (CI->getSExtValue() < 0) {
+ if (CI->isNegative()) {
Unknown = true;
break;
}