public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/61786] New: wrong code by LTO on x86_64-linux-gnu
@ 2014-07-12 4:34 su at cs dot ucdavis.edu
2014-07-12 5:01 ` [Bug lto/61786] " su at cs dot ucdavis.edu
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-07-12 4:34 UTC (permalink / raw)
To: gcc-bugs
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;
}
$
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug lto/61786] wrong code by LTO on x86_64-linux-gnu
2014-07-12 4:34 [Bug lto/61786] New: wrong code by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
@ 2014-07-12 5:01 ` su at cs dot ucdavis.edu
2014-07-14 1:48 ` hp at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: su at cs dot ucdavis.edu @ 2014-07-12 5:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61786
--- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> ---
Not sure whether it is due to the same root cause, but the combined code is
also miscompiled at (only) -O2 by the current trunk.
Interestingly, -flto seems to make the miscompilation disappear.
$ 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 -Os small.c; a.out
$ gcc-trunk -O3 small.c; a.out
$ gcc-4.9 -O2 small.c; a.out
$ gcc-trunk -flto -O2 small.c; a.out
$
$ gcc-trunk -O2 small.c
$ a.out
^C
$
$
---------------------
int a, *c = &a, d;
char b = 1;
void
fn1 ()
{
d = 1;
lbl:
if (b == d)
{
d = *c;
if (b)
goto lbl;
}
}
int
fn2 ()
{
fn1 ();
return 0;
}
int
main ()
{
fn2 ();
return 0;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug lto/61786] wrong code by LTO on x86_64-linux-gnu
2014-07-12 4:34 [Bug lto/61786] New: wrong code by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-07-12 5:01 ` [Bug lto/61786] " su at cs dot ucdavis.edu
@ 2014-07-14 1:48 ` hp at gcc dot gnu.org
2014-07-14 11:15 ` rguenth at gcc dot gnu.org
2014-07-14 11:23 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: hp at gcc dot gnu.org @ 2014-07-14 1:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61786
Hans-Peter Nilsson <hp at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-07-14
CC| |hp at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #2 from Hans-Peter Nilsson <hp at gcc dot gnu.org> ---
Comfirmed at r212486 (-O2 and not -O2 -flto). Also seen for
mmix-knuth-mmixware so apparently not target-specific. (Would be nice to have a
test-case that aborts instead of loops infinitely; fits better within the
test-harness.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug lto/61786] wrong code by LTO on x86_64-linux-gnu
2014-07-12 4:34 [Bug lto/61786] New: wrong code by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-07-12 5:01 ` [Bug lto/61786] " su at cs dot ucdavis.edu
2014-07-14 1:48 ` hp at gcc dot gnu.org
@ 2014-07-14 11:15 ` rguenth at gcc dot gnu.org
2014-07-14 11:23 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-14 11:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61786
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Both testcases confirmed as fixed with the PR61757 fix. I'll add the
testcases.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug lto/61786] wrong code by LTO on x86_64-linux-gnu
2014-07-12 4:34 [Bug lto/61786] New: wrong code by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
` (2 preceding siblings ...)
2014-07-14 11:15 ` rguenth at gcc dot gnu.org
@ 2014-07-14 11:23 ` rguenth at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-14 11:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61786
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Author: rguenth
Date: Mon Jul 14 11:22:34 2014
New Revision: 212515
URL: https://gcc.gnu.org/viewcvs?rev=212515&root=gcc&view=rev
Log:
2014-07-14 Richard Biener <rguenther@suse.de>
PR tree-optimization/61786
* gcc.dg/torture/pr61786.c: New testcase.
* gcc.dg/lto/pr61786_0.c: Likewise.
* gcc.dg/lto/pr61786_1.c: Likewise.
Added:
trunk/gcc/testsuite/gcc.dg/lto/pr61786_0.c
trunk/gcc/testsuite/gcc.dg/lto/pr61786_1.c
trunk/gcc/testsuite/gcc.dg/torture/pr61786.c
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-07-14 11:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-12 4:34 [Bug lto/61786] New: wrong code by LTO on x86_64-linux-gnu su at cs dot ucdavis.edu
2014-07-12 5:01 ` [Bug lto/61786] " su at cs dot ucdavis.edu
2014-07-14 1:48 ` hp at gcc dot gnu.org
2014-07-14 11:15 ` rguenth at gcc dot gnu.org
2014-07-14 11:23 ` 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).