[llvm-dev] GEP with a null pointer base
Peter Lawrence via llvm-dev
llvm-dev at lists.llvm.org
Thu Jul 6 14:05:11 PDT 2017
> On Jul 6, 2017, at 1:00 PM, via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
>> So far, so good. The problem is that while LLVM seems to consider
>> the above IR to be valid, we officially do not allow dereferencing
>> a pointer constructed in this way (if I’m reading the rules
>> correctly). Consequently, if this GEP ever gets close enough to a
>> load using the pointer, InstCombine will eliminate the GEP and the
>> load.
This is the part that confuses me, why would such code be eliminated.
If it is illegal then this should be a compilation failure,
If it is legal then either you prefer to let it compile as is,
or you prefer to allow “undefined behavior optimization” to take effect,
In which case it is not the load instruction that should be deleted but
rather then entire block containing the load (under the assumption
that “undefined behavior” is unreachable) and InstCombine isn’t the
place to do that.
Confused,
Peter Lawrence.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170706/33a2f7d9/attachment.html>
More information about the llvm-dev
mailing list