s390.c (override_options): Don't emit an error when -mstack-size is used without providing -mstack-guard.

2007-03-07  Andreas Krebbel  <krebbel1@de.ibm.com>

	* config/s390/s390.c (override_options): Don't emit an error when
	-mstack-size is used without providing -mstack-guard.
	(s390_emit_prologue): Choose stack_guard value automatically if not
	provided via command line.
	* doc/invoke.texi: Adjust description of -mstack-guard and -mstack-size.

From-SVN: r122655
This commit is contained in:
Andreas Krebbel 2007-03-07 09:11:12 +00:00 committed by Andreas Krebbel
parent 170bdabaa2
commit 690e7b63cf
3 changed files with 58 additions and 24 deletions

View File

@ -1,3 +1,11 @@
2007-03-07 Andreas Krebbel <krebbel1@de.ibm.com>
* config/s390/s390.c (override_options): Don't emit an error when
-mstack-size is used without providing -mstack-guard.
(s390_emit_prologue): Choose stack_guard value automatically if not
provided via command line.
* doc/invoke.texi: Adjust description of -mstack-guard and -mstack-size.
2007-03-07 Richard Sandiford <richard@codesourcery.com> 2007-03-07 Richard Sandiford <richard@codesourcery.com>
* config/i386/i386.c (output_set_got): Add a GOT initialization * config/i386/i386.c (output_set_got): Add a GOT initialization

View File

@ -1437,9 +1437,7 @@ override_options (void)
if (s390_stack_size) if (s390_stack_size)
{ {
if (!s390_stack_guard) if (s390_stack_guard >= s390_stack_size)
error ("-mstack-size implies use of -mstack-guard");
else if (s390_stack_guard >= s390_stack_size)
error ("stack size must be greater than the stack guard value"); error ("stack size must be greater than the stack guard value");
else if (s390_stack_size > 1 << 16) else if (s390_stack_size > 1 << 16)
error ("stack size must not be greater than 64k"); error ("stack size must not be greater than 64k");
@ -7245,21 +7243,47 @@ s390_emit_prologue (void)
if (s390_stack_size) if (s390_stack_size)
{ {
HOST_WIDE_INT stack_check_mask = ((s390_stack_size - 1) HOST_WIDE_INT stack_guard;
& ~(s390_stack_guard - 1));
rtx t = gen_rtx_AND (Pmode, stack_pointer_rtx,
GEN_INT (stack_check_mask));
if (TARGET_64BIT) if (s390_stack_guard)
gen_cmpdi (t, const0_rtx); stack_guard = s390_stack_guard;
else else
gen_cmpsi (t, const0_rtx); {
/* If no value for stack guard is provided the smallest power of 2
larger than the current frame size is chosen. */
stack_guard = 1;
while (stack_guard < cfun_frame_layout.frame_size)
stack_guard <<= 1;
}
emit_insn (gen_conditional_trap (gen_rtx_EQ (CCmode, if (cfun_frame_layout.frame_size >= s390_stack_size)
gen_rtx_REG (CCmode, {
CC_REGNUM), warning (0, "frame size of function %qs is "
const0_rtx), HOST_WIDE_INT_PRINT_DEC
const0_rtx)); " bytes exceeding user provided stack limit of "
HOST_WIDE_INT_PRINT_DEC " bytes. "
"An unconditional trap is added.",
current_function_name(), cfun_frame_layout.frame_size,
s390_stack_size);
emit_insn (gen_trap ());
}
else
{
HOST_WIDE_INT stack_check_mask = ((s390_stack_size - 1)
& ~(stack_guard - 1));
rtx t = gen_rtx_AND (Pmode, stack_pointer_rtx,
GEN_INT (stack_check_mask));
if (TARGET_64BIT)
gen_cmpdi (t, const0_rtx);
else
gen_cmpsi (t, const0_rtx);
emit_insn (gen_conditional_trap (gen_rtx_EQ (CCmode,
gen_rtx_REG (CCmode,
CC_REGNUM),
const0_rtx),
const0_rtx));
}
} }
if (s390_warn_framesize > 0 if (s390_warn_framesize > 0

View File

@ -12789,17 +12789,19 @@ sized arrays. This is generally a bad idea with a limited stack size.
@item -mstack-size=@var{stack-size} @item -mstack-size=@var{stack-size}
@opindex mstack-guard @opindex mstack-guard
@opindex mstack-size @opindex mstack-size
These arguments always have to be used in conjunction. If they are present the s390 If these options are provided the s390 back end emits additional instructions in
back end emits additional instructions in the function prologue which trigger a trap the function prologue which trigger a trap if the stack size is @var{stack-guard}
if the stack size is @var{stack-guard} bytes above the @var{stack-size} bytes above the @var{stack-size} (remember that the stack on s390 grows downward).
(remember that the stack on s390 grows downward). These options are intended to If the @var{stack-guard} option is omitted the smallest power of 2 larger than
be used to help debugging stack overflow problems. The additionally emitted code the frame size of the compiled function is chosen.
causes only little overhead and hence can also be used in production like systems These options are intended to be used to help debugging stack overflow problems.
without greater performance degradation. The given values have to be exact The additionally emitted code causes only little overhead and hence can also be
powers of 2 and @var{stack-size} has to be greater than @var{stack-guard} without used in production like systems without greater performance degradation. The given
exceeding 64k. values have to be exact powers of 2 and @var{stack-size} has to be greater than
@var{stack-guard} without exceeding 64k.
In order to be efficient the extra code makes the assumption that the stack starts In order to be efficient the extra code makes the assumption that the stack starts
at an address aligned to the value given by @var{stack-size}. at an address aligned to the value given by @var{stack-size}.
The @var{stack-guard} option can only be used in conjunction with @var{stack-size}.
@end table @end table
@node Score Options @node Score Options