Skip to content

Commit 6a1badf

Browse files
committed
[ValueTracking] Add missing check when computing known bits from pointer icmp
I'm not sure whether it's possible to cause a miscompile due to the missing check right now, as the affected values mechanism effectively protects us against this. This becomes a problem for an upcoming patch though.
1 parent f17e766 commit 6a1badf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
620620
if (RHS->getType()->isPointerTy()) {
621621
// Handle comparison of pointer to null explicitly, as it will not be
622622
// covered by the m_APInt() logic below.
623-
if (match(RHS, m_Zero())) {
623+
if (LHS == V && match(RHS, m_Zero())) {
624624
switch (Pred) {
625625
case ICmpInst::ICMP_EQ:
626626
Known.setAllZero();

0 commit comments

Comments
 (0)