From b15eacc7da352ad393b29bd35b71019f1da2af7d Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@gcc.gnu.org>
Date: Tue, 3 May 2011 07:20:01 +0000
Subject: [PATCH] re PR target/48723 (ICE on function returning structure with
 -fstack-check on corei7-avx)

	PR target/48723
	* config/i386/i386.c (ix86_expand_prologue): Do not probe the stack
	for -fstack-check if the size to allocate is negative.

From-SVN: r173288
---
 gcc/ChangeLog          | 8 +++++++-
 gcc/config/i386/i386.c | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 026a90b54693..043f73aa7f23 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2011-05-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR target/48723
+	* config/i386/i386.c (ix86_expand_prologue): Do not probe the stack
+	for -fstack-check if the size to allocate is negative.
+
 2011-05-02  Lawrence Crowl  <crowl@google.com>
 
 	* timevar.h (timevar_cond_start): Remove unused POP_TIMEVAR_AND_RETURN.
@@ -941,7 +947,7 @@
 	* system.h (ENUM_BITFIELD): Remove.
 
 2011-04-25  Maxim Kuvyrkov  <maxim@codesourcery.com>
-	    Eric Botcazou <ebotcazou@adacore.com>
+	    Eric Botcazou  <ebotcazou@adacore.com>
 
 	* combine.c (combine_simplify_rtx): Avoid mis-simplifying conditionals
 	for STORE_FLAG_VALUE==-1 case.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 558eff119367..c164c7074de6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -10619,8 +10619,8 @@ ix86_expand_prologue (void)
     }
 
   /* The stack has already been decremented by the instruction calling us
-     so we need to probe unconditionally to preserve the protection area.  */
-  if (flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
+     so probe if the size is non-negative to preserve the protection area.  */
+  if (allocate >= 0 && flag_stack_check == STATIC_BUILTIN_STACK_CHECK)
     {
       /* We expect the registers to be saved when probes are used.  */
       gcc_assert (int_registers_saved);
-- 
GitLab