mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 02:56:06 +00:00
[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.
This commit is contained in:
parent
c9bdeabdf4
commit
00ca80938b
@ -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()) {
|
||||
|
@ -298,3 +298,11 @@ bb:
|
||||
%cmp = icmp eq ptr blockaddress(@blockaddr_no_cfi, %bb), no_cfi @func
|
||||
ret i1 %cmp
|
||||
}
|
||||
|
||||
define i1 @global_no_cfi_dso_local_equivalent() {
|
||||
; CHECK-LABEL: @global_no_cfi_dso_local_equivalent(
|
||||
; CHECK-NEXT: ret i1 icmp eq (ptr dso_local_equivalent @func, ptr no_cfi @func)
|
||||
;
|
||||
%cmp = icmp eq ptr dso_local_equivalent @func, no_cfi @func
|
||||
ret i1 %cmp
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user