From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5267 invoked by alias); 20 May 2004 07:58:08 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 5219 invoked by uid 48); 20 May 2004 07:58:07 -0000 Date: Fri, 21 May 2004 11:45:00 -0000 From: "dannysmith at users dot sourceforge dot net" To: gcc-bugs@gcc.gnu.org Message-ID: <20040520075803.15551.dannysmith@users.sourceforge.net> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug target/15551] New: -mtune=pentium4 -O2 with sjlj EH breaks stack probe worker on windows32 targets X-Bugzilla-Reason: CC X-SW-Source: 2004-05/txt/msg02216.txt.bz2 List-Id: When following testcase is compiled with g++ -O2 -mtune=pentium4 for a cygwin or mingw target, the executable segfaults. When tuning switch is set to pentium3 or lower, the executable works correctly. This is observed on 3.4.0 and on trunk, but not on gcc-3.3.3 /* pm.cpp */ /* Testcase submitted by Hans Horn to mingw bug tracker */ #include #include using namespace std; ostream* logfile; //char expList[20000]; int main () { logfile = new ofstream("bar", ios::out); char expList[20000]; strcpy(expList, "foo"); return 0; } /* end pm.cpp */ The problem appears to be in scheduling pass moving sjlj exception handling insns across call to the allocate stack probe worker (_alloca) in the function prologue. Here is the assembler output for main() prologue from g++ -S -O2 -mtune=pentium4 pm.cpp _main: pushl %ebp movl $20092, %eax movl %esp, %ebp pushl %edi pushl %esi movl $___gxx_personality_sj0, -20052(%ebp) <<<< movl $LLSDA1484, -20048(%ebp) <<<< pushl %ebx movl $L4, -20040(%ebp) <<<< call __alloca movl $16, %eax andl $-16, %esp call __alloca leal -24(%ebp), %eax movl %eax, -20044(%ebp) leal -20076(%ebp), %eax movl %esp, -20036(%ebp) movl %eax, (%esp) call __Unwind_SjLj_Register call ___main The following patch fixes by restoring the gen_blockage barrier in i386.c:ix86_expand_prologue that was removed at revision 1.608 http://gcc.gnu.org/ml/gcc-cvs/2003-10/msg00685.html The patch was tested on i386-pc-mingw32 on 3.4.1 and trunk. * config/i386/i386.c (ix86_expand_prologue): Ensure that scheduling pass does not move insns across __alloca call Index: i386.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v retrieving revision 1.668 diff -c -3 -p -r1.668 i386.c *** i386.c 17 May 2004 15:23:12 -0000 1.668 --- i386.c 20 May 2004 07:30:16 -0000 *************** ix86_expand_prologue (void) *** 5295,5300 **** --- 5295,5304 ---- rtx t = plus_constant (stack_pointer_rtx, allocate); emit_move_insn (eax, gen_rtx_MEM (SImode, t)); } + + /* Ensure that scheduling pass does not move insns across __alloca + call. */ + emit_insn (gen_blockage (const0_rtx)); } if (frame.save_regs_using_mov && !TARGET_RED_ZONE) -- Summary: -mtune=pentium4 -O2 with sjlj EH breaks stack probe worker on windows32 targets Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dannysmith at users dot sourceforge dot net CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-mingw32 GCC host triplet: i686-pc-mingw32 GCC target triplet: i686-pc-mingw32 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15551