forked from OSchip/llvm-project
[ValueTracking] fix isOnlyUsedInZeroEqualityComparison with no users
This is another problem exposed by: https://bugs.llvm.org/PR50836
This commit is contained in:
parent
b05804ab4c
commit
a85d7a56c7
|
@ -280,8 +280,7 @@ bool llvm::haveNoCommonBitsSet(const Value *LHS, const Value *RHS,
|
|||
}
|
||||
|
||||
bool llvm::isOnlyUsedInZeroEqualityComparison(const Instruction *I) {
|
||||
// FIXME: Should not return true if there are no users.
|
||||
return all_of(I->users(), [](const User *U) {
|
||||
return !I->user_empty() && all_of(I->users(), [](const User *U) {
|
||||
ICmpInst::Predicate P;
|
||||
return match(U, m_ICmp(P, m_Value(), m_Zero())) && ICmpInst::isEquality(P);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -instcombine -S | FileCheck %s
|
||||
|
||||
target datalayout = "p:64:64"
|
||||
|
||||
; This would crash - PR50836
|
||||
|
||||
define i64 @strlen(i32* %s) {
|
||||
; CHECK-LABEL: @strlen(
|
||||
; CHECK-NEXT: [[R:%.*]] = call i64 @strlen(i32* noundef nonnull dereferenceable(1) [[S:%.*]])
|
||||
; CHECK-NEXT: ret i64 0
|
||||
;
|
||||
%r = call i64 @strlen(i32* %s)
|
||||
ret i64 0
|
||||
}
|
Loading…
Reference in New Issue