]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390.c (s390_emit_prologue): Omit issuing a
authorAndreas Krebbel <Andreas.Krebbel@de.ibm.com>
Tue, 30 Mar 2010 13:27:36 +0000 (13:27 +0000)
committerAndreas Krebbel <krebbel@gcc.gnu.org>
Tue, 30 Mar 2010 13:27:36 +0000 (13:27 +0000)
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: r157824

gcc/ChangeLog
gcc/config/s390/s390.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/s390/stackcheck1.c [new file with mode: 0644]

index 838e39de9d3417b3031405ad1b9e643fec591244..c68f8bf1983a5d9a3c0937b17ff8fc99de7a5420 100644 (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-27  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/42113
index 280358c0c3f6d2d2a51778691241a9db10cd50a8..9c806467e9f67fffda5d0c34b3bf961b1694e5a5 100644 (file)
@@ -7357,20 +7357,37 @@ 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)
-               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));
+             /* 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
+               {
+                 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));
+               }
            }
        }
 
index df9456535a45d948cf674b0d9a06fc2a3322aa76..124ff83675777314381ae0e8e9c85775a393e69f 100644 (file)
@@ -1,3 +1,7 @@
+2010-03-30  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
+
+       * gcc.target/s390/stackcheck1.c: New testcase.
+
 2010-03-21  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * gcc.target/powerpc/ppc-sdata-1.c: Require nonpic.
diff --git a/gcc/testsuite/gcc.target/s390/stackcheck1.c b/gcc/testsuite/gcc.target/s390/stackcheck1.c
new file mode 100644 (file)
index 0000000..f588833
--- /dev/null
@@ -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);
+}