s390.c (s390_emit_prologue): Omit issuing a dynamic stack check if the mask would be zero.

2010-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* config/s390/s390.c (s390_emit_prologue): Omit issuing a dynamic
	stack check if the mask would be zero.

2010-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>

	* gcc.target/s390/stackcheck1.c: New testcase.

From-SVN: r157825
This commit is contained in:
Andreas Krebbel 2010-03-30 13:53:10 +00:00 committed by Andreas Krebbel
parent 40ae679932
commit a3e7e012bf
4 changed files with 51 additions and 9 deletions

View File

@ -1,3 +1,8 @@
2010-03-30 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* config/s390/s390.c (s390_emit_prologue): Omit issuing a dynamic
stack check if the mask would be zero.
2010-03-30 Seongbae Park <seongbae.park@gmail.com>
Jack Howarth <howarth@bromo.med.uc.edu>

View File

@ -7802,16 +7802,35 @@ s390_emit_prologue (void)
}
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)
emit_insn (gen_ctrapdi4 (gen_rtx_EQ (VOIDmode, t, const0_rtx),
t, const0_rtx, const0_rtx));
/* stack_guard has to be smaller than s390_stack_size.
Otherwise we would emit an AND with zero which would
not match the test under mask pattern. */
if (stack_guard >= s390_stack_size)
{
warning (0, "frame size of function %qs is "
HOST_WIDE_INT_PRINT_DEC
" bytes which is more than half the stack size. "
"The dynamic check would not be reliable. "
"No check emitted for this function.",
current_function_name(),
cfun_frame_layout.frame_size);
}
else
emit_insn (gen_ctrapsi4 (gen_rtx_EQ (VOIDmode, t, const0_rtx),
t, const0_rtx, const0_rtx));
{
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)
emit_insn (gen_ctrapdi4 (gen_rtx_EQ (VOIDmode,
t, const0_rtx),
t, const0_rtx, const0_rtx));
else
emit_insn (gen_ctrapsi4 (gen_rtx_EQ (VOIDmode,
t, const0_rtx),
t, const0_rtx, const0_rtx));
}
}
}

View File

@ -1,3 +1,7 @@
2010-03-30 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gcc.target/s390/stackcheck1.c: New testcase.
2010-03-29 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/43265

View File

@ -0,0 +1,14 @@
/* The automatically chosen stack guard value caused an ICE in that
case. */
/* { dg-do compile } */
/* { dg-options "-O2 -mstack-size=4096" } */
extern void bar (char *);
void
foo ()
{
char a[2500];
bar (a);
}