diff options
author | Nikita Popov <npopov@redhat.com> | 2024-03-19 12:20:00 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2024-03-19 12:24:11 +0100 |
commit | 00ca80938b732ee43deb2a94bec1c7efef3025d4 (patch) | |
tree | 3b72f40c45d4d917a8a88630135a4df84143b3a8 /llvm/lib/IR/ConstantFold.cpp | |
parent | c9bdeabdf4b46fbf1f6a9fcbf9cd61d460b18c08 (diff) | |
download | llvm-00ca80938b732ee43deb2a94bec1c7efef3025d4.zip llvm-00ca80938b732ee43deb2a94bec1c7efef3025d4.tar.gz llvm-00ca80938b732ee43deb2a94bec1c7efef3025d4.tar.bz2 |
[ConstantFold] Fix comparison between special pointer constants
This code was assuming that the LHS would always be one of
GlobalVariable, BlockAddress or ConstantExpr. However, it can
also be a special constant like dso_local_equivalent or no_cfi.
Make sure this is handled gracefully.
Diffstat (limited to 'llvm/lib/IR/ConstantFold.cpp')
-rw-r--r-- | llvm/lib/IR/ConstantFold.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index 034e397..e227851 100644 --- a/llvm/lib/IR/ConstantFold.cpp +++ b/llvm/lib/IR/ConstantFold.cpp @@ -1154,10 +1154,9 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2) { GV->getType()->getAddressSpace())) return ICmpInst::ICMP_UGT; } - } else { + } else if (auto *CE1 = dyn_cast<ConstantExpr>(V1)) { // Ok, the LHS is known to be a constantexpr. The RHS can be any of a // constantexpr, a global, block address, or a simple constant. - ConstantExpr *CE1 = cast<ConstantExpr>(V1); Constant *CE1Op0 = CE1->getOperand(0); switch (CE1->getOpcode()) { |