[llvm-bugs] [Bug 27255] NULL-based pointer arithmetic generates ud2

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Apr 6 16:58:47 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27255

Reid Kleckner <rnk at google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |rnk at google.com
         Resolution|INVALID                     |---

--- Comment #2 from Reid Kleckner <rnk at google.com> ---
So, doing pointer arithmetic off of null may be UB in C strictly speaking, but
I think optimizing based on that at the LLVM level has soundness issues.

I would expect the following LLVM transform to be semantics preserving, but you
are saying it isn't:

%0 = ptrtoint i8* %myptr, i64
%1 = add i64 0, i64 %0
%2 = inttoptr i64 %1, i8*
%3 = load i8, i8* %2
=>
%0 = ptrtoint i8* %myptr, i64
%1 = getelementptr i8* null, i64 %0
%2 = load i8, i8* %1

Why should it matter to instcombine whether the valid pointer comes from the
base or the index of the GEP?

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160406/5412be94/attachment.html>


More information about the llvm-bugs mailing list