https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61786

            Bug ID: 61786
           Summary: wrong code by LTO on x86_64-linux-gnu
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following code when using LTO on
x86_64-linux-gnu in both 32-bit and 64-bit modes. 

This is a regression from 4.9.x. 

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.10.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 4.10.0 20140711 (experimental) [trunk revision 212447] (GCC) 
$ 
$ gcc-trunk -O0 -c fn1.c
$ gcc-trunk -O0 -c main.c
$ gcc-trunk -O1 fn1.o main.o
$ a.out
$ 
$ gcc-4.9 -flto -O0 -c fn1.c
$ gcc-4.9 -flto -O0 -c main.c
$ gcc-4.9 -flto -O1 fn1.o main.o
$ a.out
$ 
$ gcc-trunk -flto -O0 -c fn1.c
$ gcc-trunk -flto -O0 -c main.c
$ gcc-trunk -flto -O1 fn1.o main.o
$ a.out
^C
$ 
$ cat fn1.c
int a, *c = &a, d; 
char b = 1;

void
fn1 (void)
{
  d = 1;
 lbl:
  if (b == d)
    {
      d = *c;
      if (b)
    goto lbl;
    }
}

int
fn2 (void)
{
  fn1 ();
  return 0;
}
$ cat main.c
extern int fn2 (void); 

int
main ()
{
  fn2 ();
  return 0;
}
$

Reply via email to