http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56143



             Bug #: 56143

           Summary: Incorrect code generation with -O0 in x86_64

    Classification: Unclassified

           Product: gcc

           Version: 4.8.0

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: p...@mandriva.com.br





Created attachment 29303

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29303

lightning.i



$ rpm -q gcc

gcc-4.8.0-0.6.fc19.x86_64



I could not create a reduced example that would trigger the bug.

Attached is the .i file.

Search for "*_jit->pc.ui++ = i0 - (_jit->pc.w + 4);" for the two

occurrences of bad code generation.



If I modify the code to somewhat like:



"long w = i0 - (_jit->pc.w + 4); *_jit->pc.ui++ = w;" it works.





Some extra information just in case...



$ git clone git://git.savannah.gnu.org/lightning.git

$ cd lightning

$ autoreconf -ifs

$ ./configure --prefix=/usr

$ make CFLAGS="-O0 -g3 -Wall"

$ cd check

$ make debug

(gdb) r -v fib.tst

    0x7ffff7bff000      jmpq   0x7ffff7bff068 main:fib.tst:28

    0x7ffff7bff005      nopl   (%rax)

# nfibs:fib.tst:9

    0x7ffff7bff008      sub    $0x30,%rsp

    0x7ffff7bff00c      mov    %rbx,0x28(%rsp)

    0x7ffff7bff011      mov    %rbp,(%rsp)

    0x7ffff7bff015      mov    %rsp,%rbp

    0x7ffff7bff018      sub    $0x18,%rsp

    0x7ffff7bff01c      mov    %rdi,%r11

    0x7ffff7bff01f      mov    $0x1,%r10d

    0x7ffff7bff025      cmp    $0x2,%r11

    0x7ffff7bff029      jb     0x7ffff7bff050 nfibs:fib.tst:23

    0x7ffff7bff02f      sub    $0x1,%r11

    0x7ffff7bff033      mov    $0x1,%eax

# nfibs:fib.tst:17

    0x7ffff7bff038      sub    $0x1,%r11

    0x7ffff7bff03c      lea    (%rax,%r10,1),%rbx

    0x7ffff7bff040      mov    %r10,%rax

    0x7ffff7bff043      lea    0x1(%rbx),%r10

    0x7ffff7bff047      test   %r11,%r11

    0x7ffff7bff04a      jne    0x7ffff7bff034 nfibs:fib.tst:9   <<<< error here

# nfibs:fib.tst:23

[...]

Program received signal SIGSEGV, Segmentation fault.

0x00007ffff7bff034 in ?? ()



It did miscalculate the displacement, should have been

jne    0x7ffff7bff038

what happens if creating a temporary.

Reply via email to