[llvm-bugs] [Bug 28224] [Regression] GVN optimization pass since llvm 3.8 produces wrong IR in one case

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jul 4 02:04:28 PDT 2016


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

llvm at joakim.fea.st changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #9 from llvm at joakim.fea.st ---
> I guess what I am trying to say is that this bug has nothing to
> do with inlining: imagine that the code in imagine_shift was in
> main because it was written that way.

I don't have to imagine it: I noted in my comment that when I replaced the
function with the exact same code, manual inlining essentially, clang warned
about that expression, while it did nothing if the code was in a separate
function.

Since I noted this behavior on the ldc forum, one of the ldc contributors
pointed me at this old llvm blog post, explaining why llvm doesn't try to warn
about such behavior:

http://blog.llvm.org/2011/05/what-every-c-programmer-should-know_21.html

While there are a lot of arguments there, I don't find the reasoning that "we
simply don't have the internal tracking infrastructure to produce" usable error
messages that follow optimizations from the original code to be convincing.  I
think that needs to be done.

Anyway, I suppose the usual argument is that the function is wrong given
certain input and it's not up to the optimizer to flag such bugs, but the code
should have been tested unoptimized to shake out such bugs first. I'll look
into why our debug-mode tests weren't catching this either, that's likely the
real reason this got through.

Of course, many people don't exhaustively test their code and it's going to
make matters worse for them when the llvm optimizer just removes it without a
warning.

-- 
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/20160704/c88994e5/attachment-0001.html>


More information about the llvm-bugs mailing list