Bug 34415 - [4.3 Regression] Possible miscompilation on MIPS
Summary: [4.3 Regression] Possible miscompilation on MIPS
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Richard Sandiford
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-10 00:53 UTC by Martin Michlmayr
Modified: 2007-12-16 09:58 UTC (History)
3 users (show)

See Also:
Host:
Target: mips-linux-gnu
Build:
Known to work: 4.2.0
Known to fail: 4.3.0
Last reconfirmed: 2007-12-10 18:11:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Michlmayr 2007-12-10 00:53:37 UTC
The mawk test suite doesn't pass when I build mawk with gcc 4.3 at
-O3 on mips.  I cannot give you an isolated testcase but I've
narrowed it down so that someone with more experience can take a
look.  I hope one of the two of you (David, Richard) can take a look.

Get mawk from upstream or Debian and compile it normally.  If you do:

cp mawk test/mawk
cd test
./mawk -f ../examples/decl.awk mawktest.dat | cmp -s - decl-awk.out ; echo $?
cd ..

you'll see that it works.

Now do:

cd rexp
/usr/lib/gcc-snapshot/bin/gcc -g -Wall -O3 -DMAWK -I.. -c -o rexp0.o rexp0.c
cd ..
rm mawk
make mawk

and run the test above again and you'll see it fails.  It fails because
the whitespace is different, e.g.
-hash: function returning unsigned (extern)
+hash: function returning  unsigned  (extern)

OK, we so know that something in rexp0.c doesn't work at -O3.
Unfortunately at this point I don't have enough experience to
investigate further.  I found out one more thing, though.  The
testsuite works again (when rexp0.c is compiled with -O3) if you
apply the following patch:

+++ rexp/rexp0.c     2007-12-07 18:54:03.000000000 +0000
@@ -68,7 +68,7 @@
 /* static functions */
 int PROTO(do_str, (int, char **, MACHINE *)) ;
 int PROTO(do_class, (char **, MACHINE *)) ;
-static int PROTO(escape, (char **)) ;
+int PROTO(escape, (char **)) ;
 static BV *PROTO(store_bvp, (BV *)) ;
 static int PROTO(ctohex, (int)) ;

@@ -576,7 +576,7 @@
   on entry *s -> at the character after the slash
  *-------------------*/

-static int
+int
 escape(start_p)
    char **start_p ;
 {

I hope one of you can investigate.  I'm not 100% sure this is a bug
in GCC rather than in mawk, but mawk works fine on x86_64 when
compiled with -O3.  I've only seen the testsuite failure on MIPS so
far.
Comment 1 David Daney 2007-12-10 05:15:27 UTC
Perhaps we could get a URL to a version of mawk that is failing.

Also details about how you configured gcc and which svn revision number you tested, and how mawk was configured.
Comment 2 Martin Michlmayr 2007-12-10 05:33:53 UTC
(In reply to comment #1)
> Perhaps we could get a URL to a version of mawk that is failing.
> 
> Also details about how you configured gcc and which svn revision number you
> tested, and how mawk was configured.

It's all standard Debian stuff.

apt-get source mawk will give you mawk (1.3.3-11).
apt-get install gcc-snapshot will give you a compiler based on trunk
(sid)tbm@appdev:~/src/mawk-1.3.3$ /usr/lib/gcc-snapshot/bin/gcc -v
Using built-in specs.
Target: mips-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 20071030-1' --with-bugurl=file:///usr/share/doc/gcc-snapshot/README.Bugs --enable-languages=c,c++,obj-c++ --prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --disable-nls --enable-clocale=gnu --enable-libstdcxx-debug --disable-libssp --disable-werror --build=mips-linux-gnu --host=mips-linux-gnu --target=mips-linux-gnu
Thread model: posix
gcc version 4.3.0 20071030 (experimental) [trunk revision 127646] (Debian 20071030-1)
Comment 3 Richard Biener 2007-12-10 09:52:34 UTC
As of the experience with the removed 'static' keyword it is very likely that
the function where escape() is inlined to is miscompiled.
Comment 4 Richard Sandiford 2007-12-10 18:11:08 UTC
Confirmed.
Comment 5 Richard Sandiford 2007-12-11 10:07:52 UTC
This is a bug in the delayed branch scheduler.  Patch here:
http://gcc.gnu.org/ml/gcc-patches/2007-12/msg00506.html
Comment 6 Richard Sandiford 2007-12-16 09:54:46 UTC
Subject: Bug 34415

Author: rsandifo
Date: Sun Dec 16 09:54:34 2007
New Revision: 130987

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130987
Log:
gcc/
	PR rtl-optimization/34415
	* df.h (DF_LR_IN, DF_LR_OUT): Update comments.
	* resource.c (mark_target_live_regs): Use DF_LR_IN rather than
	df_get_live_in.  Don't handle pseudos.

gcc/testsuite/
	PR rtl-optimization/34415
	* gcc.c-torture/execute/pr34415.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr34415.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/df.h
    trunk/gcc/resource.c
    trunk/gcc/testsuite/ChangeLog

Comment 7 Richard Sandiford 2007-12-16 09:58:41 UTC
Fixed on trunk.