Bug 14637 - [lno] [merge] wrong code with -O2 -finline-functions
Summary: [lno] [merge] wrong code with -O2 -finline-functions
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: lno
: P2 normal
Target Milestone: lno
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code, wrong-code
Depends on:
Blocks:
 
Reported: 2004-03-18 16:43 UTC by Serge Belyshev
Modified: 2004-03-21 11:33 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2004-03-20 08:24:58


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Serge Belyshev 2004-03-18 16:43:41 UTC
xgcc (GCC) 3.5-tree-ssa-lno 20040318 (merged 20040221) get an ICE at while doing
profiledbootstrap (after stage1, while compiling libgcc). Configured with

../gcc/configure --program-suffix=-3.5-tree-ssa-lno --enable-languages=c
--with-arch=athlon-xp --disable-checking --disable-werror

Bootstrap started with

make CFLAGS='-O2 -fomit-frame-pointer -fweb' STAGE1_CFLAGS='-O2
-fomit-frame-pointer -fweb' BOOT_CFLAGS='-O3 -fomit-frame-pointer
-fno-rename-registers' profiledbootstrap

[snip]

./xgcc -B./ -B/usr/local/i686-pc-linux-gnu/bin/ -isystem
/usr/local/i686-pc-linux-gnu/include -isystem
/usr/local/i686-pc-linux-gnu/sys-include
-L/usr/local/src/gcc/lno/build/gcc/../ld -O2  -DIN_GCC    -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition
 -isystem ./include  -fPIC -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2
-D__GCC_FLOAT_NOT_NEEDED  -I. -I. -I../../gcc/gcc -I../../gcc/gcc/.
-I../../gcc/gcc/../include -I../../gcc/gcc/../libbanshee/libcompat
-I../../gcc/gcc/../libbanshee -I../../gcc/gcc/../libbanshee/points-to  
-DL_divdi3 -c ../../gcc/gcc/libgcc2.c -fexceptions -fnon-call-exceptions -o
libgcc/./_divdi3.o
../../gcc/gcc/libgcc2.c: In function `__divdi3':
../../gcc/gcc/libgcc2.c:1014: internal compiler error: in cgraph_remove_edge, at
cgraph.c:292
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[3]: *** [libgcc/./_divdi3.o] Ошибка 1
make[3]: Leaving directory `/usr/local/src/gcc/lno/build/gcc'
make[2]: *** [libgcc.a] Ошибка 2
make[2]: Leaving directory `/usr/local/src/gcc/lno/build/gcc'
make[1]: *** [stageprofile_build] Ошибка 2
make[1]: Leaving directory `/usr/local/src/gcc/lno/build/gcc'
make: *** [profiledbootstrap] Ошибка 2
Comment 1 Andrew Pinski 2004-03-18 16:53:49 UTC
This is almost definitely caused by the kernel headers defining inline as inline 
__attribute__((always_inline)) which is not right.
Can you provide the preprocessed source.
Comment 2 Serge Belyshev 2004-03-18 17:23:14 UTC
[I cannot add an attachment?!?! bugzilla says me 'You did not specify a file to
attach', but I do!]

probably yes, because of always_inline; but in libgcc2.c:484 or libgcc2.c:782
and not in Mariusz Mazur's carefully edited kernel headers for linux 2.6.0 and
up (cvs://cvs.pld-linux.org/linux-libc-headers).
Comment 3 Serge Belyshev 2004-03-18 22:06:39 UTC
Surely this is miscompilation of gcc itself. I changed BOOT_CFLAGS from '-O3
-fomit-frame-pointer -fno-rename-registers' to '-O2 -fomit-frame-pointer -fweb'
and this 'bug' disappeares.

Reduced testcase for above, obviously invalid, bug is just

static int f () {return 0;}
void g () {f ();}

Is -O3 option supposed to generate invalid code in lno and tree-ssa or this is
something new?
Comment 4 Andrew Pinski 2004-03-18 22:10:21 UTC
What compiler are you building with as if the compiler is miscompiled it might because of the frist 
stage compiler is miscompiled?
Do not set STAGE1_CFLAGS without knowing what the consensus are like this one.
Comment 5 Serge Belyshev 2004-03-18 23:51:03 UTC
I build stage1 with gcc-3.4.0-20040318 -O2 -fomit-frame-pointer -fweb. But I am
sure that stage1 is not miscompiled. I now found that stage2 miscompiled only
when BOOT_CFLAGS set to '-O2 -finline-functions' (with the same symptom like ICE
in cgraph.c).

I suppose that this bug is not specific to lno, now I am checking tree-ssa.
Comment 6 Serge Belyshev 2004-03-19 04:25:08 UTC
Ok, this bug is NOT present in current (20040319 00:30 UTC) tree-ssa. And this
is true bug, I get same effect when I recompile lno (again 20040319 00:30 UTC)
from scratch with:

$ export CC=gcc-3.3
$ ../gcc/configure --program-suffix='-3.5-tree-ssa-lno' --enable-languages=c
--with-arch=athlon-xp --disable-checking --disable-werror
$ make CFLAGS='-O2' STAGE1_CFLAGS='-O0' BOOT_CFLAGS='-O2 -finline-functions'
boootstrap

Where gcc-3.3 is 100% stable gcc 3.3.4 checked out 20040306. Bootstrap fails
with the same effect -- ICE in cgraph.c while compiling libgcc.a at stage2_build.
Comment 7 Volker Reichelt 2004-03-19 21:03:54 UTC
This might be related to PR 14433.
When I did a full bootstrap, the bug was there.
When I compiled tree-ssa by hand it disappeared.
To me this looks like a miscompilation of the compiler.

Fortunately, the bug disappeared on 2004-03-12.
I don't know when it appeared (since doing a full bootstrap
for each iteration of a binary search was just too much work).

Since the last merge of the lno-branch was before that date,
it might be possible that you ran into the same problem on
the lno-branch.

To support that theory you might want to try tree-ssa as of
2004-03-10 and see whether you can reproduce the problem there.
Or you can wait for the next lno-merge, and see whether the bug
disappears or not.
Comment 8 Serge Belyshev 2004-03-20 06:24:58 UTC
This bug is present in 3.5-tree-ssa 20040309 (cvs up -D 20040310 -r
tree-ssa-20020619-branch) with same syndrome.
Comment 9 Andrew Pinski 2004-03-20 08:24:51 UTC
Confirmed, waiting for a merge.
Comment 10 Andrew Pinski 2004-03-21 07:44:20 UTC
Can someone try again as now the lno branch has been merged from the tree-ssa again 
today (from today too)?
Comment 11 Serge Belyshev 2004-03-21 11:33:38 UTC
make bootstrap of gcc 3.5-tree-ssa-lno 20040321 (merged 20040321) with
BOOT_CFLAGS set to '-O2 -finline-functions' succeeds, so this PR is over.