[llvm-bugs] [Bug 37701] New: GCC 4.9.2 and later miscompiles LLVM

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jun 6 08:50:48 PDT 2018


            Bug ID: 37701
           Summary: GCC 4.9.2 and later miscompiles LLVM
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: simon.dardis at mips.com
                CC: llvm-bugs at lists.llvm.org

LLVM since r330024 has been miscompiled by GCC 4.9.2 or later for MIPS. The
issue occurs when LLVM is compiled with PIC and optimizations (01+).

The problem is that GCC's implementation of shrink wrapping can move the
prologue past a branch instruction which is later expanded into a long jump. To
fetch the address of the target, the long branch sequence fetches the GOT
pointer from it's spill slot on the stack to load the address of the indirect
branch target. However the prologue is responsible for spilling the GOT pointer
to the stack.

This results in a indirect jump with to an uninitialized value, detectable with
valgrind. Some setups may somehow get the correct behaviour, others will get
incoherent stack traces upon crashing. At this point in time, it appears to
affect only the AArch64 backend for LLVM with a MIPS host.

There are number of workarounds such as compiling at -O0, disabling PIC or
disabling shrink-wrapping (-fno-shrink-wrap).

This issue affects multiple versions of GCC from 4.9.2 onwards. GCC bug filed
as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86069

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/20180606/a4ba155a/attachment-0001.html>

More information about the llvm-bugs mailing list