public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/64684] New: wrong code by LTO on x86_64-linux-gnu
@ 2015-01-20  7:41 su at cs dot ucdavis.edu
  2015-01-20  9:42 ` [Bug lto/64684] [5 Regression] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: su at cs dot ucdavis.edu @ 2015-01-20  7:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64684
           Summary: wrong code by LTO on x86_64-linux-gnu
           Product: gcc
           Version: 5.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/5.0.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 5.0.0 20150119 (experimental) [trunk revision 219832] (GCC) 

$ 
$ gcc-trunk -O1 -c fn1.c
$ gcc-trunk -Os -c fn2.c
$ gcc-trunk -O0 -c main.c
$ gcc-trunk -O0 fn1.o fn2.o main.o
$ ./a.out
$ 
$ 
$ gcc-4.9 -flto -O1 -c fn1.c
$ gcc-4.9 -flto -Os -c fn2.c
$ gcc-4.9 -flto -O0 -c main.c
$ gcc-4.9 -flto fn1.o fn2.o main.o
$ ./a.out
$ 
$ gcc-trunk -flto -O1 -c fn1.c
$ gcc-trunk -flto -Os -c fn2.c
$ gcc-trunk -flto -O0 -c main.c
$ gcc-trunk -flto fn1.o fn2.o main.o
$ ./a.out
Aborted (core dumped)
$ 
$ cat fn1.c
extern void fn2 (void);
extern int a;

void
fn1 ()
{
  a = -1;
  fn2 ();
  a &= 1;
}
$ cat fn2.c
extern int a;

void
fn2 (void)
{
  a = 0;
}
$ cat main.c
extern void fn1 (void);

int a;

int
main ()
{
  fn1 ();

  if (a != 0) 
    __builtin_abort (); 

  return 0;
}
$


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-01-20 13:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-20  7:41 [Bug lto/64684] New: wrong code by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
2015-01-20  9:42 ` [Bug lto/64684] [5 Regression] " rguenth at gcc dot gnu.org
2015-01-20 10:30 ` rguenth at gcc dot gnu.org
2015-01-20 10:41 ` rguenth at gcc dot gnu.org
2015-01-20 10:47 ` rguenth at gcc dot gnu.org
2015-01-20 13:26 ` rguenth at gcc dot gnu.org
2015-01-20 13:27 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).