diff options
author | Nikita Popov <npopov@redhat.com> | 2022-01-06 09:58:31 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-01-06 09:59:40 +0100 |
commit | c41aa41957c102fdbe1e92c31fd1aec1c5fccbd5 (patch) | |
tree | 3a95ecbb9d2439cc72681737102c1fdddb18cf24 /llvm/lib/IR/ConstantFold.cpp | |
parent | 37c9171764ee1a1ce34cd5cf984fee818cd617fb (diff) | |
download | llvm-c41aa41957c102fdbe1e92c31fd1aec1c5fccbd5.zip llvm-c41aa41957c102fdbe1e92c31fd1aec1c5fccbd5.tar.gz llvm-c41aa41957c102fdbe1e92c31fd1aec1c5fccbd5.tar.bz2 |
[ConstFold] Add missing check for inbounds gep
If the gep is not inbounds, then the gep might compute a null
value even if the base pointer is non-null.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 0d76dd7..9f1d76b 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1537,7 +1537,7 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2, if (const GlobalValue *GV = dyn_cast<GlobalValue>(CE1Op0)) { // If its not weak linkage, the GVal must have a non-zero address // so the result is greater-than - if (!GV->hasExternalWeakLinkage()) + if (!GV->hasExternalWeakLinkage() && CE1GEP->isInBounds()) return ICmpInst::ICMP_UGT; } } else if (const GlobalValue *GV2 = dyn_cast<GlobalValue>(V2)) { |