[llvm] 6a1badf - [ValueTracking] Add missing check when computing known bits from pointer icmp
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 05:11:08 PST 2023
Author: Nikita Popov
Date: 2023-12-07T14:10:59+01:00
New Revision: 6a1badfed2dcd438d94a35cc4ab3b38c7cc06208
URL: https://github.com/llvm/llvm-project/commit/6a1badfed2dcd438d94a35cc4ab3b38c7cc06208
DIFF: https://github.com/llvm/llvm-project/commit/6a1badfed2dcd438d94a35cc4ab3b38c7cc06208.diff
LOG: [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.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index ee4f97f3bf5e0..2c52107dab23b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -620,7 +620,7 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
if (RHS->getType()->isPointerTy()) {
// Handle comparison of pointer to null explicitly, as it will not be
// covered by the m_APInt() logic below.
- if (match(RHS, m_Zero())) {
+ if (LHS == V && match(RHS, m_Zero())) {
switch (Pred) {
case ICmpInst::ICMP_EQ:
Known.setAllZero();
More information about the llvm-commits
mailing list