[LLVMdev] Constant folding inttoptr i32 0 to null pointer?

Reid Kleckner rnk at google.com
Tue Jun 9 14:23:53 PDT 2015


On Tue, Jun 9, 2015 at 2:15 PM, Benyei, Guy <guy.benyei at intel.com> wrote:

> Currently it seems to work fine, but as you said, this behavior is not
> exactly well defined. I would really expect any access to null - no matter
> in what address space - to be replaced with undef by some optimization pass.
>
> "An integer constant other than zero or a pointer value returned from a
> function not defined within LLVM may be associated with address ranges
> allocated through mechanisms other than those provided by LLVM. Such ranges
> shall not overlap with any ranges of addresses allocated by mechanisms
> provided by LLVM."
>
> Doesn't it mean, that the integer constant zero cannot be associated with
> any kind of memory, including non-default address space memory? Seems that
> address 0 still has to be handled somehow...
>

I agree it's confusing, but for what it's worth, we already do things like
loading from null in address space 257 and 256 to load from [gs:00] and
[fs:00] on x86. It's supposed to work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150609/91dc7e45/attachment.html>


More information about the llvm-dev mailing list