public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* gcc-2.95.2-51 is buggy
@ 2000-11-24  5:20 Andries.Brouwer
  2000-11-24  5:44 ` Neil Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 20+ messages in thread
From: Andries.Brouwer @ 2000-11-24  5:20 UTC (permalink / raw)
  To: greg, viro; +Cc: Andries.Brouwer, alan, bernds, linux-kernel, torvalds

>> ... RedHat's GCC snapshot "2.96" handles this case just fine.

> Now, if you can isolate the relevant part of the diff between
> 2.95.2 and RH 2.96...

Maybe I have to be more precise in the statement "gcc 2.95.2 is buggy".

I just installed gcc 2.95.2 freshly ftp'ed from ftp.gnu.org, and

% /usr/bin/gcc -v
Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)
% /usr/bin/gcc -Wall -O2 -o bug bug.c; ./bug
0x84800000
% /usr/gcc/aeb/bin/gcc -v
Reading specs from /usr/gcc/aeb/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
gcc version 2.95.2 19991024 (release)
% /usr/gcc/aeb/bin/gcc -Wall -O2 -o nobug bug.c; ./nobug
0x0

So, not all versions of gcc 2.95.2 are equal.

% rpm -qf /usr/bin/gcc
gcc-2.95.2-51

This is from a SuSE distribution, I forget which, not very recent.
Revised summary: gcc-2.95.2-51 from SuSE is buggy.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: gcc-2.95.2-51 is buggy
@ 2000-11-24  8:09 Frédéric L . W . Meunier
  0 siblings, 0 replies; 20+ messages in thread
From: Frédéric L . W . Meunier @ 2000-11-24  8:09 UTC (permalink / raw)
  To: linux-kernel

Andries.Brouwer@cwi.nl wrote:

<skip>
> % /usr/gcc/aeb/bin/gcc -v
> Reading specs from
> /usr/gcc/aeb/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/specs
> gcc version 2.95.2 19991024 (release)gcc version 2.95.2 19991024 (release)
> % /usr/gcc/aeb/bin/gcc -Wall -O2 -o nobug bug.c; ./nobug
> 0x0

Interesting. On a Slackware 7.1 recently upgraded to glibc 2.2
(and where gcc 2.95.2 from ftp.gnu.org was built because 2.2
requires this version) I get:

% gcc -Wall -O2 -o bug bug.c
% ./bug
0x84800000

% egcs-2.91.66 -Wall -O2 -o bug bug.c
% ./bug
0x0

% gcc -Wall -O -o bug bug.c
% ./bug
0x0

% gcc -v
Reading specs from
/usr/lib/gcc-lib/i386-slackware-linux/2.95.2/specs
gcc version 2.95.2 19991024 (release)

% egcs-2.91.66 -v
Reading specs from
/usr/lib/gcc-lib/i386-slackware-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)

Slackware's -current tree was upgraded to glibc 2.2 and gcc
2.95.2, but I built them myself.

-- 
0@pervalidus.{net, com, dyndns.org}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: gcc-2.95.2-51 is buggy
@ 2000-11-24 12:48 Andries.Brouwer
  2000-11-24 16:46 ` Matthew Vanecek
  0 siblings, 1 reply; 20+ messages in thread
From: Andries.Brouwer @ 2000-11-24 12:48 UTC (permalink / raw)
  To: jakub; +Cc: alan, bernds, linux-kernel, torvalds

> so the reason why it did not show up in the gcc you picked up from
> ftp.gnu.org is that you have compiled it so that it defaults to -mcpu=i686

Yes, you are right.

So 2.95.2 fails for i386, i486, i586 and does not fail for i686.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: gcc-2.95.2-51 is buggy
@ 2000-11-24 13:04 Mikael Pettersson
  0 siblings, 0 replies; 20+ messages in thread
From: Mikael Pettersson @ 2000-11-24 13:04 UTC (permalink / raw)
  To: Andries.Brouwer, jakub; +Cc: alan, bernds, greg, linux-kernel, torvalds, viro

On Fri, 24 Nov 2000, Jakub Jelinek wrote:

>so the reason why it did not show up in the gcc you picked up from
>ftp.gnu.org is that you have compiled it so that it defaults to -mcpu=i686
>where the bug does not show up.

Indeed. I just ran some tests, and I can confirm that gcc 2.95.2 vanilla
exhibits the bug when compiled and run for i486 or i585, but not i686.

/Mikael
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 20+ messages in thread
* Re: gcc-2.95.2-51 is buggy
@ 2000-11-27 14:28 Pavel Pisa;research student
  0 siblings, 0 replies; 20+ messages in thread
From: Pavel Pisa;research student @ 2000-11-27 14:28 UTC (permalink / raw)
  To: linux-kernel

Hello all,

I have used patch from GCC-PATCHES list
posted by Bernd Schmidt <bernds at redhat dot com>.
Because of high importance I am forwarding this patch to
Linux-Kernel. Patch seems to solve problem.

I have added warning print for case of problem,
to find which parts of Linux kernel could be affected by this GCC
bug. There are results:

linux-2.4.0-test10-pre?   compiled for K7
make[2]: Entering directory `/usr/src/linux-2.4.0-t9/fs'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.0-t9/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe  -mpreferred-stack-boundary=2 -march=i686 -malign-functions=4  -fno-strict-aliasing    -c -o block_dev.o block_dev.c
block_dev.c: In function `block_read':
block_dev.c:311: warning: possible original gcc 2.95.2 error c/877
make[2]: Entering directory `/usr/src/linux-2.4.0-t9/ipc'
gcc -D__KERNEL__ -I/usr/src/linux-2.4.0-t9/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe  -mpreferred-stack-boundary=2 -march=i686 -malign-functions=4  -fno-strict-aliasing    -c -o msg.o msg.c
msg.c: In function `sys_msgctl':
msg.c:576: warning: possible original gcc 2.95.2 error c/877
gcc -D__KERNEL__ -I/usr/src/linux-2.4.0-t9/include -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe  -mpreferred-stack-boundary=2 -march=i686 -malign-functions=4  -fno-strict-aliasing    -c -o sem.o sem.c

I have run same compilation for 2.2.15 kernel compiled for K6
make[2]: Entering directory `/usr/src/linux-2.2.15/fs'
block_dev.c: In function `block_read':
block_dev.c:304: warning: possible original gcc 2.95.2 error c/877

I hope that my mail is not only waste of your time.
These possible wrong compiled files could be sources of other
false kernel related bugs.

If you have interest I will to try to compile 2.2.x and 2.4.0-x kernels
for bare i586 to find more such problematic places.

Best wishes 
            Pavel Pisa

PS: For faster response CC any reply directly to my address, please.

-----------------------------------------------------------------------------
To: aeb at cwi dot nl 
Subject: Re: c/877: gcc 2.95.2 generates incorrect code on i386 
From: Bernd Schmidt <bernds at redhat dot com> 
Date: Fri, 24 Nov 2000 15:40:05 +0000 (GMT) 
cc: gcc-gnats at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot
    org 



On 24 Nov 2000 aeb@cwi.nl wrote:

> >Synopsis:       gcc 2.95.2 generates incorrect code on i386

> It seems that a variable length shift of a long long
> is miscompiled. This causes Linux kernel bugs.

This is (as usual) a bug in reload.  We have two insns:

(insn 69 67 70 (set (reg:QI 46)
        (subreg:QI (reg:SI 43) 0))

(insn 70 69 72 (set (reg:DI 44)
        (ashiftrt:DI (reg:DI 44)
            (reg:QI 46)))               (expr_list:REG_DEAD 46)

Neither reg 46 nor reg 44 gets a hard register.  While processing insn 70,
reload decides that it will need reg 2 (%cl) for reg 46, and reg 3/4
(%ebx/%esi) for reg 44.  It also notices that the value of reg 44 is
already available in reg 1/2 (%edx/%ecx), so it can avoid loading it from
the stack and instead use reg 1/2 as overriding input.  It then notices
that reg 46 dies in insn 70 and is set in insn 69, so it would be possible
simply to replace the destination of insn 69 with the reload reg (%cl).

The problem is that by changing insn 69 to store into %cl, the input
override for the other reload gets clobbered.  Oops.  The function
reload_reg_free_for_value_p doesn't test for this case.

I'm currently bootstrapping with the patch below; I'll check it in (along
with a testcase) once that finishes.  It won't apply cleanly to 2.95, but
it should be quite easy to figure out how to apply it.  This is an obvious
candidate should we decide to make a 2.95.3 release.

(As a side note, this bug has nothing to do with the fact that there's a
long long shift in this testcase, although I think I've noticed a bunch
of potential bugs related to multiword values in the reload inheritance
code while looking at this testcase...)


Bernd

        * reload1.c (conflicts_with_override): New function.
        (emit_input_reload_insns): Use it to tighten test for validity
        of substituting into output of previous insn.

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.241
diff -u -p -r1.241 reload1.c
--- reload1.c   2000/11/14 10:23:37     1.241
+++ reload1.c   2000/11/24 15:11:43
@@ -417,6 +417,7 @@ static int reload_reg_reaches_end_p PARA
                                                 enum reload_type));
 static int allocate_reload_reg         PARAMS ((struct insn_chain *, int,
                                                 int));
+static int conflicts_with_override     PARAMS ((rtx));
 static void failed_reload              PARAMS ((rtx, int));
 static int set_reload_reg              PARAMS ((int, int));
 static void choose_reload_regs_init    PARAMS ((struct insn_chain *, rtx *));
@@ -4882,6 +4883,21 @@ reload_reg_free_for_value_p (regno, opnu
   return 1;
 }
 
+/* Determine whether the reload reg X overlaps any rtx'es used for
+   overriding inheritance.  Return nonzero if so.  */
+
+static int
+conflicts_with_override (x)
+     rtx x;
+{
+  int i;
+  for (i = 0; i < n_reloads; i++)
+    if (reload_override_in[i]
+       && reg_overlap_mentioned_p (x, reload_override_in[i]))
+      return 1;
+  return 0;
+}
+
 /* Give an error message saying we failed to find a reload for INSN,
    and clear out reload R.  */
 static void
@@ -6215,6 +6231,7 @@ emit_input_reload_insns (chain, rl, old,
           && dead_or_set_p (insn, old)
           /* This is unsafe if some other reload
              uses the same reg first.  */
+          && ! conflicts_with_override (reloadreg)
           && reload_reg_free_for_value_p (REGNO (reloadreg),
                                           rl->opnum,
                                           rl->when_needed,




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

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

end of thread, other threads:[~2000-11-27 14:58 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-11-24  5:20 gcc-2.95.2-51 is buggy Andries.Brouwer
2000-11-24  5:44 ` Neil Brown
2000-11-24  6:47   ` Alexander Viro
2000-11-25 17:26   ` Rik van Riel
2000-11-25 19:16     ` Jeff V. Merkey
2000-11-25 20:01     ` Andries Brouwer
2000-11-25 20:06       ` Rik van Riel
2000-11-26 15:33         ` Olaf Dietsche
2000-11-26 16:58           ` Rik van Riel
2000-11-26 19:36           ` Mike Castle
2000-11-26 19:41             ` Russell King
2000-11-26 19:55           ` J . A . Magallon
2000-11-24  9:37 ` Ion Badulescu
2000-11-24 10:18   ` Linux Kernel Developer
2000-11-24  9:57 ` Jakub Jelinek
  -- strict thread matches above, loose matches on Subject: below --
2000-11-24  8:09 Frédéric L . W . Meunier
2000-11-24 12:48 Andries.Brouwer
2000-11-24 16:46 ` Matthew Vanecek
2000-11-24 13:04 Mikael Pettersson
2000-11-27 14:28 Pavel Pisa;research student

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox