public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/8008: gcc pushes arguments without updating SP
@ 2002-09-23 0:16 matt
0 siblings, 0 replies; only message in thread
From: matt @ 2002-09-23 0:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 8008
>Category: optimization
>Synopsis: gcc pushes arguments without updating SP
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Mon Sep 23 00:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Matt Thomas
>Release: 3.3 20020922 (experimental)
>Organization:
3am Software Foundry
>Environment:
System: NetBSD pilot.local 1.6F NetBSD 1.6F (PILOT.MP) #8: Mon Aug 19 01:55:52 PDT 2002 matt@pilot.local:/export/i386/kobj/PILOT.MP i386
host: i386-pc-netbsdelf
build: i386-pc-netbsdelf
target: vax-dec-netbsdelf
configured with: /export/toolchain/gcc/configure --target=vax-netbsdelf --host=i386-netbsdelf --build=i386-netbsdelf --disable-shared --enable-static : (reconfigured) : (reconfigured) : (reconfigured)
>Description:
Gcc is generating code which is incorrectly substituting the use of a general
register in place of the stack pointer when the use of the stack pointer is
required.
>How-To-Repeat:
Compile gcc.c-torture/execute/20020412-1.c as -O1 and -O2 and compare
generated assembly.
Note the following section of assembly:
pushl %r8
- pushl %r1
- pushl %r7
- calls $3,memcpy
+ movl %r1,-(%r7)
+ movl %r7,-(%r7)
+ movab memcpy,%r11
+ calls $3,(%r11)
In the -O2 complied version, two arguments are pushed via %r7 instead of %sp.
This is incorrect in two ways. The first way is that %sp is not pointing at
the bottom of the stack, and hence, the start of the arguments. The second
problem is that before the pushl %r8, %r7 == %sp, so the first movl
obliterates the value pushed by the pushl %r8. The second movl saves the
wrong value (%r7 - 4) on the stack (where at point it should have been
%sp + 8).
>Fix:
The fix is to tell gcc to *never* mung the stack (or below the stack)
without using the stack pointer. How ones does that is beyond me.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2002-09-23 7:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-23 0:16 optimization/8008: gcc pushes arguments without updating SP matt
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).