Windows stack probes and large argument passing
Joseph S. Myers
joseph@codesourcery.com
Tue Mar 4 01:02:00 GMT 2008
On Windows targets, functions requiring large stack frames need to
call __alloca to touch all the stack pages used in the right order.
This is done in the function prologue, but if
-mno-accumulate-outgoing-args (most likely implied by -Os) then extra
stack may be required by function calls passing large arguments, and
no __alloca calls are done for that extra stack allocation.
The generic compiler code doesn't appear to have support for calling
extra functions like this when it wishes to modify the stack pointer.
Instead, it seems simplest to force -maccumulate-outgoing-args to on
for targets requiring this stack probing. There is already code doing
so for cases where it's needed for unwind tables.
Tested with no regressions with cross to i686-mingw32, where it fixes:
FAIL: gcc.c-torture/execute/pr28982b.c execution, -Os
OK to commit?
2008-03-03 Joseph Myers <joseph@codesourcery.com>
* config/i386/i386.c (override_options): Force
-maccumulate-outgoing-args on if TARGET_STACK_PROBE.
testsuite:
2008-03-03 Joseph Myers <joseph@codesourcery.com>
* gcc.target/i386/sse-10.c: Don't use
-mno-accumulate-outgoing-args on *-*-mingw* *-*-cygwin*.
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c (revision 132840)
+++ gcc/config/i386/i386.c (working copy)
@@ -2700,6 +2700,18 @@
target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
}
+ /* If stack probes are required, the space used for large function
+ arguments on the stack must also be probed, so enable
+ -maccumulate-outgoing-args so this happens in the prologue. */
+ if (TARGET_STACK_PROBE
+ && !(target_flags & MASK_ACCUMULATE_OUTGOING_ARGS))
+ {
+ if (target_flags_explicit & MASK_ACCUMULATE_OUTGOING_ARGS)
+ warning (0, "stack probing requires -maccumulate-outgoing-args "
+ "for correctness");
+ target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS;
+ }
+
/* For sane SSE instruction set generation we need fcomi instruction.
It is safe to enable all CMOVE instructions. */
if (TARGET_SSE)
Index: gcc/testsuite/gcc.target/i386/sse-10.c
===================================================================
--- gcc/testsuite/gcc.target/i386/sse-10.c (revision 132840)
+++ gcc/testsuite/gcc.target/i386/sse-10.c (working copy)
@@ -1,6 +1,7 @@
/* PR 17930 */
/* { dg-do run } */
/* { dg-options "-O1 -msse2 -mfpmath=sse -mno-accumulate-outgoing-args -fno-omit-frame-pointer" } */
+/* { dg-options "-O1 -msse2 -mfpmath=sse -fno-omit-frame-pointer" { target *-*-mingw* *-*-cygwin* } } */
#include "sse2-check.h"
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Gcc-patches
mailing list