[llvm-dev] GEP with a null pointer base

Marcin SÅ‚owik via llvm-dev llvm-dev at lists.llvm.org
Sun Jul 9 13:10:49 PDT 2017


Can we go back a little?

1) Add a new transformation to InstCombine that will replace 'getelementptr
> i8, i8* null, <ty> %n' with 'inttoptr <ty> %n to i8*' when <ty> has the
> same size as a pointer for the target architecture.


What's the actual problem with this approach? I personally find it the most
compelling - it is well-defined (well, somewhat), front-end agnostic (and
assume some front ends may find this kind of pointer arithmetic to be
well-defined) and predictable.
I would even extend it to allow offsets of different types to be used, with
additional zero-extension when applicable.

Cheers,
Marcin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170709/082091d2/attachment.html>


More information about the llvm-dev mailing list