[llvm-bugs] [Bug 29023] New: GVN-hoist miscompiles libgo/runtime/mgc0.c

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Aug 17 14:04:39 PDT 2016


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

            Bug ID: 29023
           Summary: GVN-hoist miscompiles libgo/runtime/mgc0.c
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: cdavis5x at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16976
  --> https://llvm.org/bugs/attachment.cgi?id=16976&action=edit
Unoptimized IR from mgc0.c

When the GVN-hoist pass is enabled, Clang miscompiles the file runtime/mgc0.c
from llgo's libgo. As a result, any program built with llgo will die on
startup.

Here's what I know so far:
* The miscompile only happens when Clang generates and optimizes the IR in one
run. I can reproduce it reliably by passing -O2 (or even -O1) to Clang. But if
I pass -O0 -S -emit-llvm, and try to run opt or even Clang on the IR with -O2,
I can't reproduce this. Yes, this does suck.
* The specific miscompilation I'm referring to is in the runtime_markspan()
function. A check that the variable runtime_checking is true is optimized away
as always true, and the condition for the loop on line 2676 is also optimized
away as always true. This results in a loop that only terminates with a call to
a noreturn function, with the rest of the function after that point being
optimized away as unreachable.
* Turning GVN-hoist off fixes the miscompilation.

I wish I had more information, but given bullet 1, reducing a test case is nigh
impossible. The lack of debug output in GVN-hoist does not help matters,
either. I will attach IR files that demonstrate the problem shortly.

-- 
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/20160817/aac4a418/attachment-0001.html>


More information about the llvm-bugs mailing list