diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-09-24 18:08:56 +0100 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2021-09-24 18:18:53 +0100 |
commit | bdee805b3277e04677490f42e62aa28478331254 (patch) | |
tree | 3fd6a084e13f9413a5ab7e6a6a1e72eccbd81e48 /llvm/lib/IR/ConstantFold.cpp | |
parent | 36eb6c0134afa9d6881e52c002743f4594c859ee (diff) | |
download | llvm-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.cpp | 4 |
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; } |