[llvm] [DataLayout] Add isNullPointerAllZeroes (PR #165314)

Robert Imschweiler via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 28 02:16:19 PDT 2025


ro-i wrote:

> It is correct at the LLVM IR level.

yes, which is wrong, right? The code snippet you referenced also states this: "Currently LLVM assumes null pointers always have value 0, which results in incorrectly transformed IR."
So *if* we want to add some helper function like the one proposed by @arichardson and implemented in this PR, then we shouldn't assume anything except for address space 0, right? Because while it may be true at the moment, it will not be true soonish because it's actually wrong.

Except if you'd like to define `ptr null` so that it's always 0, which would require creating another name for "NULL". But as far as I understand your comments in the RFC, you're rather in favor of handling `ptr null` such that it's not necessarily 0.

https://github.com/llvm/llvm-project/pull/165314


More information about the llvm-commits mailing list