public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code
@ 2001-06-22 19:56 William M. Brack
  0 siblings, 0 replies; 4+ messages in thread
From: William M. Brack @ 2001-06-22 19:56 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR optimization/3387; it has been noted by GNATS.

From: "William M. Brack" <wbrack@mmm.com.hk>
To: <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code
Date: Sat, 23 Jun 2001 10:50:59 +0800

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0046_01C0FBD2.637B41E0
 Content-Type: text/plain;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: 7bit
 
 Looking at the bug database for this report, it appears that the attached
 file was somehow lost during the web submission.  If true, please add it to
 the PR for me; if false, please ignore this (and excuse my ignorance).
 
 W. Brack
 
 ------=_NextPart_000_0046_01C0FBD2.637B41E0
 Content-Type: application/octet-stream;
 	name="bug1.c"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="bug1.c"
 
 /*=0D
 The following program generates incorrect code (judged by reading the =
 generated=0D
 assembler source) when compiled with flags -O2 and -fPIC.  It seems to =
 compile=0D
 correctly with flags -O1 and -fPIC, as well as with flags -O2 only.=0D
 =0D
 The critical problem is that the routine "f1" modifies the referenced =
 param (str),=0D
 so the restoration of the initial value is required ( "str =3D tmp;" ).  =
 However,=0D
 the generated code deletes that statement.=0D
 =0D
 Please note:  This fragment is completely artificial - it is a VERY =
 reduced excerpt=0D
 from a reasonably complex program in which the problem caused complete =
 failure.=0D
 Any criticism about about "poor coding" will be taken as a personal =
 insult ;>)=0D
 */=0D
 =0D
 int f1(int uri, char **str);=0D
 int f2(int uri, char **str);=0D
 =0D
 int bug(int uri, char *str) {=0D
     int ret;=0D
     char *tmp =3D str;		/* Save the initial value of param str */=0D
 =0D
     ret =3D f1(uri, &str);	/* This routine modifies the value of str =
 */=0D
     if (ret !=3D 0) {=0D
 	str =3D tmp;		/* Restore the initial value of str */=0D
         ret =3D f2(uri, &str);=0D
     }=0D
     if (ret !=3D 0)=0D
 	return(ret);=0D
 =0D
     ret =3D f2(uri, &str);=0D
 =0D
     return(0);=0D
 }=0D
 
 ------=_NextPart_000_0046_01C0FBD2.637B41E0--
 


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

* Re: optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code
@ 2001-09-12 14:24 sirl
  0 siblings, 0 replies; 4+ messages in thread
From: sirl @ 2001-09-12 14:24 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, veillard, wbrack

Synopsis: GCC 3.0 optimisation -O2 -fPIC produces incorrect code

State-Changed-From-To: feedback->closed
State-Changed-By: sirl
State-Changed-When: Wed Sep 12 14:24:28 2001
State-Changed-Why:
    Fix backported to branch, will be in 3.0.2.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3387&database=gcc


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

* Re: optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code
@ 2001-09-09 10:44 sirl
  0 siblings, 0 replies; 4+ messages in thread
From: sirl @ 2001-09-09 10:44 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, veillard, wbrack

Synopsis: GCC 3.0 optimisation -O2 -fPIC produces incorrect code

State-Changed-From-To: open->feedback
State-Changed-By: sirl
State-Changed-When: Sun Sep  9 10:44:30 2001
State-Changed-Why:
    With current gcc-3_0-branch this testcase seems to produce correct code, see below. Can you please verify that the current gcc-3_0-branch works for you in the original context too?
    
            .file   "xml2bug.c"
            .text
            .align 16
    .globl bug
            .type   bug,@function
    bug:
            pushl   %ebp
            movl    %esp, %ebp
            pushl   %edi
            pushl   %esi
            pushl   %ebx
            subl    $20, %esp
            call    .LPR0
            addl    $_GLOBAL_OFFSET_TABLE_, %ebx
            movl    8(%ebp), %edi
            leal    12(%ebp), %esi
            pushl   %esi
            pushl   %edi
            call    f1@PLT
            addl    $16, %esp
            testl   %eax, %eax
            je      .L3
            subl    $8, %esp
            pushl   %esi
            pushl   %edi
            call    f2@PLT
            addl    $16, %esp
            testl   %eax, %eax
            je      .L3
    .L1:
            leal    -12(%ebp), %esp
            popl    %ebx
            popl    %esi
            popl    %edi
            popl    %ebp
            ret
            .p2align 4,,7
    .L3:
            subl    $8, %esp
            pushl   %esi
            pushl   %edi
            call    f2@PLT
            xorl    %eax, %eax
            jmp     .L1
    .Lfe1:
            .size   bug,.Lfe1-bug
    .LPR0:
            movl    (%esp), %ebx
            ret
            .ident  "GCC: (GNU) 3.0.2 20010909 (prerelease)"

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3387&database=gcc


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

* optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code
@ 2001-06-22 17:56 wbrack
  0 siblings, 0 replies; 4+ messages in thread
From: wbrack @ 2001-06-22 17:56 UTC (permalink / raw)
  To: gcc-gnats; +Cc: veillard

>Number:         3387
>Category:       optimization
>Synopsis:       GCC 3.0 optimisation -O2 -fPIC produces incorrect code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 22 17:56:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     wbrack@mmm.com.hk
>Release:        GCC-3.0
>Organization:
>Environment:
i686-pc-linux-gnu
>Description:
Under optimisation, one necessary assignment statement (judged by reading the assembler output) is deleted.  Further comment in attached file, checked with web interface to codesourcery as demonstrating the problem with (latest) compiler.
>How-To-Repeat:
compile the attached (small) routine
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2001-09-12 14:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-22 19:56 optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code William M. Brack
  -- strict thread matches above, loose matches on Subject: below --
2001-09-12 14:24 sirl
2001-09-09 10:44 sirl
2001-06-22 17:56 wbrack

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).