This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug target/15551] [3.4/3.5? Regression] -mtune=pentium4 -O2with sjlj EH breaks stack probe worker on windows32 targets
- From: Kelley Cook <kcook at gcc dot gnu dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 08 Jun 2004 06:21:34 -0400
- Subject: Re: [Bug target/15551] [3.4/3.5? Regression] -mtune=pentium4 -O2with sjlj EH breaks stack probe worker on windows32 targets
- References: <20040520075803.15551.dannysmith@users.sourceforge.net> <20040607200100.30313.qmail@sourceware.org>
After deciphering the twisty passages. I think this is a more correct fix.
The problem was not really a scheduling problem, it was that the Win32
alloca routine was not marking that it affected memory, so gcc felt free
to move stuff writing to the __alloca region before the call to __alloca.
I still need to regtest it (as that is REALLY slow on cygwin), but it
survived a c,c++ bootstrap on i686-pc-cygwin and fixed the bug (writing
to unalloca memory) as evidenced by below:
$ diff -u pm-gcc_35_orig.s pm-p4new.s
--- pm-gcc_35_orig.s 2004-06-01 14:25:47.170950500 -0400
+++ pm-p4new.s 2004-06-07 15:26:04.193903000 -0400
@@ -23,26 +23,26 @@
movl %esp, %ebp
pushl %edi
pushl %esi
- movl $___gxx_personality_sj0, -20052(%ebp)
- movl $LLSDA1422, -20048(%ebp)
pushl %ebx
- movl $L4, -20040(%ebp)
call __alloca
movl $16, %eax
andl $-16, %esp
call __alloca
leal -24(%ebp), %eax
+ movl $___gxx_personality_sj0, -20052(%ebp)
movl %eax, -20044(%ebp)
leal -20076(%ebp), %eax
- movl %esp, -20036(%ebp)
+ movl $LLSDA1422, -20048(%ebp)
movl %eax, (%esp)
+ movl $L4, -20040(%ebp)
+ movl %esp, -20036(%ebp)
call __Unwind_SjLj_Register
call ___main
movl $256, (%esp)
movl $-1, -20072(%ebp)
call __Znwj
- movl %eax, -20080(%ebp)
movl $16, 8(%esp)
+ movl %eax, -20080(%ebp)
movl $LC0, 4(%esp)
movl %eax, (%esp)
movl $1, -20072(%ebp)
This patch was against mainline, OK if it passed a complete regtest
(which I should be able to check up on at work this morning)?
The patch also applies to 3.4 and passed an all languages bootstrap;
I'll also regtest it there.
Mark, after a week on mainline, would this be OK for 3.4.1 assuming that
it also passes?
Kelley Cook
2004-06-07 Kelley Cook <kcook@gcc.gnu.org>
* config/i386/i386.c (ix86_expand_prologue): Mark win32 allocate insn
as prologue.
* config/i386/i386.md (allocate_stack): Clobber alloca memory.
(allocate_stack_worker_postreload): Likewise.
(allocate_stack_worker_rex64): Likewise.
(allocate_stack_worker_rex64_postreload): Likewise.
(allocate_stack_worker_1): Likewise.
diff -upd ../../../../gcc-orig/gcc/config/i386/i386.c ./i386.c
--- ../../../../gcc-orig/gcc/config/i386/i386.c 2004-06-02 13:34:35.000000000 -0400
+++ ./i386.c 2004-06-07 15:38:53.587909000 -0400
@@ -5280,7 +5280,8 @@ ix86_expand_prologue (void)
if (eax_live)
{
- emit_insn (gen_push (eax));
+ insn = emit_insn (gen_push (eax));
+ RTX_FRAME_RELATED_P (insn) = 1;
allocate -= 4;
}
@@ -5293,7 +5294,8 @@ ix86_expand_prologue (void)
if (eax_live)
{
rtx t = plus_constant (stack_pointer_rtx, allocate);
- emit_move_insn (eax, gen_rtx_MEM (SImode, t));
+ insn = emit_move_insn (eax, gen_rtx_MEM (SImode, t));
+ RTX_FRAME_RELATED_P (insn) = 1;
}
}
diff -upd ../../../../gcc-orig/gcc/config/i386/i386.md ./i386.md
--- ../../../../gcc-orig/gcc/config/i386/i386.md 2004-06-07 12:08:14.587894000 -0400
+++ ./i386.md 2004-06-07 15:38:02.133408000 -0400
@@ -18304,6 +18304,7 @@
[(unspec:SI [(match_operand:SI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
(set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
(clobber (match_scratch:SI 1 "=0"))
+ (clobber (mem:BLK (scratch)))
(clobber (reg:CC 17))]
"!TARGET_64BIT && TARGET_STACK_PROBE"
"call\t__alloca"
@@ -18315,6 +18316,7 @@
UNSPEC_STACK_PROBE)
(set (reg:SI 7) (minus:SI (reg:SI 7) (match_dup 0)))
(clobber (match_dup 0))
+ (clobber (mem:BLK (scratch)))
(clobber (reg:CC 17))])]
""
"")
@@ -18323,6 +18325,7 @@
[(unspec:DI [(match_operand:DI 0 "register_operand" "a")] UNSPEC_STACK_PROBE)
(set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
(clobber (match_scratch:DI 1 "=0"))
+ (clobber (mem:BLK (scratch)))
(clobber (reg:CC 17))]
"TARGET_64BIT && TARGET_STACK_PROBE"
"call\t__alloca"
@@ -18334,6 +18337,7 @@
UNSPEC_STACK_PROBE)
(set (reg:DI 7) (minus:DI (reg:DI 7) (match_dup 0)))
(clobber (match_dup 0))
+ (clobber (mem:BLK (scratch)))
(clobber (reg:CC 17))])]
""
"")
@@ -18345,6 +18349,7 @@
(clobber (reg:CC 17))])
(parallel [(set (reg:SI 7)
(minus:SI (reg:SI 7) (match_dup 1)))
+ (clobber (mem:BLK (scratch)))
(clobber (reg:CC 17))])]
"TARGET_STACK_PROBE"
{