Skip to content

[LVI] Fix the type when inferring nonnull from a dereferenceable attribute bundle#177562

Merged
philnik777 merged 1 commit intollvm:mainfrom
philnik777:fix_lvi
Jan 23, 2026
Merged

[LVI] Fix the type when inferring nonnull from a dereferenceable attribute bundle#177562
philnik777 merged 1 commit intollvm:mainfrom
philnik777:fix_lvi

Conversation

@philnik777
Copy link
Copy Markdown
Contributor

No description provided.

@philnik777 philnik777 requested a review from nikic as a code owner January 23, 2026 10:21
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Jan 23, 2026
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Jan 23, 2026

@llvm/pr-subscribers-llvm-analysis

Author: Nikolas Klauser (philnik777)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/177562.diff

1 Files Affected:

  • (modified) llvm/lib/Analysis/LazyValueInfo.cpp (+1-1)
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index 0bdd158970dc7..b4d64536a5aca 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -854,7 +854,7 @@ void LazyValueInfoImpl::intersectAssumeOrGuardBlockValueConstantRange(
           if (auto *CI = dyn_cast<ConstantInt>(RK.IRArgValue);
               CI && !CI->isZero())
             BBLV = BBLV.intersect(ValueLatticeElement::getNot(
-                Constant::getNullValue(RK.IRArgValue->getType())));
+                Constant::getNullValue(RK.WasOn->getType())));
           break;
 
         default:

@philnik777
Copy link
Copy Markdown
Contributor Author

I think this should fix #176734 (comment), but I'm not sure how to test this. Any hints would be appreciated.

Copy link
Copy Markdown
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nikic
Copy link
Copy Markdown
Contributor

nikic commented Jan 23, 2026

I think this should fix #176734 (comment), but I'm not sure how to test this. Any hints would be appreciated.

I'm not sure it's worthwhile to track down when exactly the type ends up mattering, but something we could do instead is to add an additional consistency assertion to make sure that the type of the value and the type of the value lattice (for constant lattice values) match somewhere.

@philnik777 philnik777 merged commit 6fc8028 into llvm:main Jan 23, 2026
13 checks passed
@philnik777 philnik777 deleted the fix_lvi branch January 23, 2026 11:10
@llvm-ci
Copy link
Copy Markdown

llvm-ci commented Jan 23, 2026

LLVM Buildbot has detected a new failure on builder openmp-s390x-linux running on systemz-1 while building llvm at step 6 "test-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/19768

Here is the relevant piece of the build log for the reference
Step 6 (test-openmp) failure: test (failure)
******************** TEST 'libomp :: tasking/issue-94260-2.c' FAILED ********************
Exit Code: -11

Command Output (stdout):
--
# RUN: at line 1
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp   -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src  -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic && /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic
# executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: -11

--

********************


Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Jan 29, 2026
sshrestha-aa pushed a commit to sshrestha-aa/llvm-project that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:analysis Includes value tracking, cost tables and constant folding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants