This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] New -fstack-check implementation (2/n)


> The middle-end parts are OK.  This is OK if it is OK with the x86
> backend maintainers.

Thanks a lot.  I installed yesterday the middle-end parts as well as the 
couple of testcases.  However, I overlooked that, on x86 and x86-64 Linux, 
the Ada runtime does some pattern matching on the form of probes to make sure 
that the stack pointer points to a valid page by the time execution resumes 
after the stack overflow exception is propagated.

So I've just installed as obvious the small tweak to the x86 back-end that 
changes the form of probes to IOR insns, they are shorter than the current 
probes and have been used in the Windows probing code since the beginning.

I'll re-resubmit the rest of the patch to the x86 back-end for approval.

Tested on i586-suse-linux and x86_64-suse-linux,


2009-11-04  Eric Botcazou  <ebotcazou@adacore.com>

        PR target/10127
        PR ada/20548
	* config/i386/i386.md (probe_stack_range): New expander.
	(logical operation peepholes): Do not split stack checking probes.


2009-11-04  Eric Botcazou  <ebotcazou@adacore.com>

	* ada/acats/norun.lst: Remove the stack checking tests.
	* ada/acats/run_acats: Limit the stack to 8MB.


-- 
Eric Botcazou
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 153881)
+++ config/i386/i386.md	(working copy)
@@ -19985,6 +19985,18 @@ (define_expand "allocate_stack"
   DONE;
 })
 
+;; Use IOR for stack probes, this is shorter.
+(define_expand "probe_stack"
+  [(match_operand 0 "memory_operand" "")]
+  ""
+{
+  if (GET_MODE (operands[0]) == DImode)
+    emit_insn (gen_iordi3 (operands[0], operands[0], const0_rtx));
+  else
+    emit_insn (gen_iorsi3 (operands[0], operands[0], const0_rtx));
+  DONE;
+})
+
 (define_expand "builtin_setjmp_receiver"
   [(label_ref (match_operand 0 "" ""))]
   "!TARGET_64BIT && flag_pic"
@@ -20488,7 +20500,9 @@ (define_peephole2
                      [(match_dup 0)
                       (match_operand:SI 1 "nonmemory_operand" "")]))
               (clobber (reg:CC FLAGS_REG))])]
-  "optimize_insn_for_speed_p () && ! TARGET_READ_MODIFY_WRITE"
+  "optimize_insn_for_speed_p () && ! TARGET_READ_MODIFY_WRITE
+   /* Do not split stack checking probes.  */
+   && GET_CODE (operands[3]) != IOR && operands[1] != const0_rtx"
   [(set (match_dup 2) (match_dup 0))
    (parallel [(set (match_dup 2)
                    (match_op_dup 3 [(match_dup 2) (match_dup 1)]))
@@ -20503,7 +20517,9 @@ (define_peephole2
                      [(match_operand:SI 1 "nonmemory_operand" "")
                       (match_dup 0)]))
               (clobber (reg:CC FLAGS_REG))])]
-  "optimize_insn_for_speed_p () && ! TARGET_READ_MODIFY_WRITE"
+  "optimize_insn_for_speed_p () && ! TARGET_READ_MODIFY_WRITE
+   /* Do not split stack checking probes.  */
+   && GET_CODE (operands[3]) != IOR && operands[1] != const0_rtx"
   [(set (match_dup 2) (match_dup 0))
    (parallel [(set (match_dup 2)
                    (match_op_dup 3 [(match_dup 1) (match_dup 2)]))
Index: testsuite/ada/acats/norun.lst
===================================================================
--- testsuite/ada/acats/norun.lst	(revision 153881)
+++ testsuite/ada/acats/norun.lst	(working copy)
@@ -1,10 +1,2 @@
-c52103x
-c52104x
-c52104y
-cb1010a
-cb1010c
-cb1010d
 templat
 # Tests must be sorted in alphabetical order
-# c52103x, c52104x, c52104y: -fstack-check doesn't work, PR middle-end/20548
-# cb1010a, cb1010c, cb1010d: likewise
Index: testsuite/ada/acats/run_acats
===================================================================
--- testsuite/ada/acats/run_acats	(revision 153881)
+++ testsuite/ada/acats/run_acats	(working copy)
@@ -52,4 +52,7 @@ echo exec gnatmake '"$@"' >> host_gnatma
 
 chmod +x host_gnatmake
 
+# Limit the stack to 8MB for stack checking
+ulimit -s 8192
+
 exec $testdir/run_all.sh ${1+"$@"}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]