This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
(Note: please ignore my prior email to gcc-bugs@gcc.gnu.org as this bug report replaces it. The .zip file included in my priot email didn't include the -save-temps .i output, whereas the .zip file attached to this report does) Dr. Ulrich Weigand (weigand@informatik.uni-erlangen.de) has analyzed this bug as follows: "This would appear to be a gcc bug. Specifically, what appears to happen here is that instruction scheduling moves the leal across the call to __alloca. This in turn is caused by a bug in the cygwin prolog generation code that emits the __alloca call as a regular function call." "As regular function calls do not change the stack pointer, the instruction scheduling pass concluded that it was safe to move the leal 16(%esp),%edi across the call (%edi is preserved across calls as well)." "Instead, the __alloca call should have been annotated to express the fact that it changes %esp in a special way. How to best fix this I'd leave to the i386 backend maintainers; please report this bug (with testcase and explanation) to the gcc bug-tracking system." "(From what I can see, the same bug exists unchanged in gcc 3.2.1 and the current pre-3.3 sources. As this particular code path is only used for cygwin, it probably wasn't noticed earlier ...)" Release: gcc version 3.2 20020927 (prerelease) Environment: PIII 800MHz Windows 2000 Pro SP3 Cygwin 1.3.16-1 gcc 3.2-3 $ uname -a CYGWIN_NT-5.0 (censored) 1.3.16(0.65/3/2) 2002-11-22 22:18 i686 unknown How-To-Repeat: fish@foobar ~/fishtest $ cat fish.c #include <stdio.h> #include <string.h> void foo () { char a[15000]; a[0]=0; printf("String length=%d\n",strlen(a)); memset( &a[0], 0xCD, 13371 ); a[13371]=0; printf("String length=%d\n",strlen(a)); } int main ( int argc, char* argv[] ) { foo(); return 0; } fish@foobar ~/fishtest $ gcc -march=i686 -g -O2 -fomit-frame-pointer -c fish.c -Wa,-adhln=fish.c.listing.txt fish@foobar ~/fishtest $ gcc -march=i686 -g -O2 -fomit-frame-pointer -o fish.exe fish.o fish@foobar ~/fishtest $ fish String length=2
Fix: 1. -O0 or -O1, or... 2. -fno-omit-frame-pointer, or... 3. use memset len < 13371, or... 4. don't use largish local stack vars so as to prevent __alloca from being called/used.
From: =?iso-8859-1?q?Danny=20Smith?= <danny_r_smith_2001@yahoo.co.nz> To: hercules-390@yahoogroups.com, gcc-gnats@gcc.gnu.org, gcc-prs@gcc.gnu.org, zHercules@yahoogroups.com, gcc-bugs@gcc.gnu.org, nobody@gcc.gnu.org, fish@infidels.org Cc: Subject: Re: optimization/8750: Cygwin prolog generation erroneously emitting __alloca as regular function call Date: Fri, 20 Dec 2002 06:06:43 +1100 (EST) http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8750 The followin fixes PR optimization/8750, a serious regression from 2.95 on W32 targets (which set TARGET_STACK_PROBE) Tested on 3.2 and 3.3 branches with i386-pc-mingw32. Can someone with more knowledge of 1386 backend please review and perhaps suggest less naive fix. ChangeLog 2002-12-19 Danny Smith <dannysmith@users.sourceforge.net> PR optimization/8750 * config/i386/i386.c (ix86_expand_prologue): Don't allow scheduling pass to move insns across __alloca call. Index: i386.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v retrieving revision 1.495 diff -c -3 -p -r1.495 i386.c *** i386.c 9 Dec 2002 23:53:59 -0000 1.495 --- i386.c 19 Dec 2002 10:44:08 -0000 *************** ix86_expand_prologue () *** 4516,4521 **** --- 4516,4525 ---- CALL_INSN_FUNCTION_USAGE (insn) = gen_rtx_EXPR_LIST (VOIDmode, gen_rtx_USE (VOIDmode, arg0), CALL_INSN_FUNCTION_USAGE (insn)); + + /* Don't allow scheduling pass to move insns across __alloca + call. */ + emit_insn (gen_blockage (const0_rtx)); } if (use_mov) { http://greetings.yahoo.com.au - Yahoo! Greetings - Send your seasons greetings online this year!
From: rth@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: optimization/8750 Date: 9 Jan 2003 02:34:52 -0000 CVSROOT: /cvs/gcc Module name: gcc Changes by: rth@gcc.gnu.org 2003-01-08 18:34:52 Modified files: gcc : ChangeLog gcc/config/i386: i386.c Log message: PR optimization/8750 * config/i386/i386.c (ix86_expand_prologue): Don't allow scheduling pass to move insns across __alloca call. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.16298&r2=1.16299 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&r1=1.506&r2=1.507
From: rth@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: optimization/8750 Date: 9 Jan 2003 02:35:48 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: rth@gcc.gnu.org 2003-01-08 18:35:48 Modified files: gcc : ChangeLog gcc/config/i386: i386.c Log message: PR optimization/8750 * config/i386/i386.c (ix86_expand_prologue): Don't allow scheduling pass to move insns across __alloca call. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.46&r2=1.16114.2.47 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.495.2.2&r2=1.495.2.3
From: dannysmith@gcc.gnu.org To: gcc-gnats@gcc.gnu.org Cc: Subject: optimization/8750 Date: 9 Jan 2003 03:07:46 -0000 CVSROOT: /cvs/gcc Module name: gcc Branch: cygwin-mingw-v2-branch Changes by: dannysmith@gcc.gnu.org 2003-01-08 19:07:46 Modified files: gcc : ChangeLog.cygwin-mingw gcc/config/i386: i386.c Log message: Backport from 3.3 PR optimization/8750 * config/i386/i386.c (ix86_expand_prologue): Don't allow scheduling pass to move insns across __alloca call. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.cygwin-mingw.diff?cvsroot=gcc&only_with_tag=cygwin-mingw-v2-branch&r1=1.1.4.1&r2=1.1.4.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&only_with_tag=cygwin-mingw-v2-branch&r1=1.368.2.19.2.8.2.1&r2=1.368.2.19.2.8.2.2
Responsible-Changed-From-To: unassigned->dannysmith Responsible-Changed-Why: Submitter of the fix.
State-Changed-From-To: open->analyzed State-Changed-Why: Do you plan to backport the patch to the 3.2 branch? If no, please close the bug.
From: Danny Smith <dannysmith@clear.net.nz> To: gcc-gnats@gcc.gnu.org, zHercules@yahoogroups.com, gcc-bugs@gcc.gnu.org, dannysmith@sources.redhat.com, gcc-prs@gcc.gnu.org, fish@infidels.org, hercules-390@yahoogroups.com Cc: Subject: Re: optimization/8750: Cygwin prolog generation erroneously emitting __alloca as regular function call Date: Sun, 23 Feb 2003 21:50:15 +0000 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=g cc&pr=8750 Patch for 3_2-branch is at: http://gcc.gnu.org/ml/gcc-patches/2003-02/msg01482.html
State-Changed-From-To: analyzed->closed State-Changed-Why: Fixed in 3.3
*** Bug 9185 has been marked as a duplicate of this bug. ***
*** Bug 8437 has been marked as a duplicate of this bug. ***
Subject: Bug 8750 CVSROOT: /cvs/gcc Module name: gcc Changes by: kcook@gcc.gnu.org 2003-10-12 17:10:12 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.c-torture/execute: 20031012-1.c Log message: PR optimization/8750 * gcc.c-torture/execute/20031012-1.c: New Test Case. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3115&r2=1.3116 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.c-torture/execute/20031012-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1