aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorH.J. Lu <hongjiu.lu@intel.com>2009-01-15 15:44:41 +0000
committerH.J. Lu <hjl@gcc.gnu.org>2009-01-15 07:44:41 -0800
commite939805b7bf63bec46a4b2de6f272d3f77238448 (patch)
tree26ee8baa1110a4cd957e834e172e0e3ca28e4648 /gcc
parent750900dba0c3d968f7d059c5dc1ff27a246f05f5 (diff)
downloadgcc-e939805b7bf63bec46a4b2de6f272d3f77238448.zip
gcc-e939805b7bf63bec46a4b2de6f272d3f77238448.tar.gz
gcc-e939805b7bf63bec46a4b2de6f272d3f77238448.tar.bz2
re PR middle-end/37843 (unaligned stack in main due to tail call optimization)
gcc/ 2009-01-15 H.J. Lu <hongjiu.lu@intel.com> Joey Ye <joey.ye@intel.com> PR middle-end/37843 * cfgexpand.c (expand_stack_alignment): Don't update stack boundary nor check incoming stack boundary here. (gimple_expand_cfg): Update stack boundary and check incoming stack boundary here. gcc/testsuite/ 2009-01-15 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/37843 * gcc.target/i386/pr37843-3.c: Replace _Decimal128 with __m128. Co-Authored-By: Joey Ye <joey.ye@intel.com> From-SVN: r143400
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/cfgexpand.c32
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/i386/pr37843-3.c12
4 files changed, 40 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bb99b6f..4afe53f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2009-01-15 H.J. Lu <hongjiu.lu@intel.com>
+ Joey Ye <joey.ye@intel.com>
+
+ PR middle-end/37843
+ * cfgexpand.c (expand_stack_alignment): Don't update stack
+ boundary nor check incoming stack boundary here.
+ (gimple_expand_cfg): Update stack boundary and check incoming
+ stack boundary here.
+
2009-01-15 Kenneth Zadeck <zadeck@naturalbridge.com>
* dce.c (find_call_stack_args, delete_unmarked_insns): Fixed
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index e0c328f..6d7fe77 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -2215,7 +2215,7 @@ static void
expand_stack_alignment (void)
{
rtx drap_rtx;
- unsigned int preferred_stack_boundary, incoming_stack_boundary;
+ unsigned int preferred_stack_boundary;
if (! SUPPORTS_STACK_ALIGNMENT)
return;
@@ -2228,10 +2228,6 @@ expand_stack_alignment (void)
gcc_assert (crtl->stack_alignment_needed
<= crtl->stack_alignment_estimated);
- /* Update stack boundary if needed. */
- if (targetm.calls.update_stack_boundary)
- targetm.calls.update_stack_boundary ();
-
/* Update crtl->stack_alignment_estimated and use it later to align
stack. We check PREFERRED_STACK_BOUNDARY if there may be non-call
exceptions since callgraph doesn't collect incoming stack alignment
@@ -2246,15 +2242,8 @@ expand_stack_alignment (void)
if (preferred_stack_boundary > crtl->stack_alignment_needed)
crtl->stack_alignment_needed = preferred_stack_boundary;
- /* The incoming stack frame has to be aligned at least at
- parm_stack_boundary. */
- if (crtl->parm_stack_boundary > INCOMING_STACK_BOUNDARY)
- incoming_stack_boundary = crtl->parm_stack_boundary;
- else
- incoming_stack_boundary = INCOMING_STACK_BOUNDARY;
-
crtl->stack_realign_needed
- = incoming_stack_boundary < crtl->stack_alignment_estimated;
+ = INCOMING_STACK_BOUNDARY < crtl->stack_alignment_estimated;
crtl->stack_realign_tried = crtl->stack_realign_needed;
crtl->stack_realign_processed = true;
@@ -2359,6 +2348,23 @@ gimple_expand_cfg (void)
if (crtl->stack_protect_guard)
stack_protect_prologue ();
+ /* Update stack boundary if needed. */
+ if (SUPPORTS_STACK_ALIGNMENT)
+ {
+ /* Call update_stack_boundary here to update incoming stack
+ boundary before TARGET_FUNCTION_OK_FOR_SIBCALL is called.
+ TARGET_FUNCTION_OK_FOR_SIBCALL needs to know the accurate
+ incoming stack alignment to check if it is OK to perform
+ sibcall optimization since sibcall optimization will only
+ align the outgoing stack to incoming stack boundary. */
+ if (targetm.calls.update_stack_boundary)
+ targetm.calls.update_stack_boundary ();
+
+ /* The incoming stack frame has to be aligned at least at
+ parm_stack_boundary. */
+ gcc_assert (crtl->parm_stack_boundary <= INCOMING_STACK_BOUNDARY);
+ }
+
/* Register rtl specific functions for cfg. */
rtl_register_cfg_hooks ();
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 237ce65..0876ea0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-01-15 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR middle-end/37843
+ * gcc.target/i386/pr37843-3.c: Replace _Decimal128 with __m128.
+
2009-01-15 Dodji Seketeli <dodji@redhat.com>
PR c++/38636
diff --git a/gcc/testsuite/gcc.target/i386/pr37843-3.c b/gcc/testsuite/gcc.target/i386/pr37843-3.c
index 505ff87..a475e41 100644
--- a/gcc/testsuite/gcc.target/i386/pr37843-3.c
+++ b/gcc/testsuite/gcc.target/i386/pr37843-3.c
@@ -1,13 +1,15 @@
/* Test for stack alignment with sibcall optimization. */
-/* { dg-do compile { target { *-*-linux* && { ilp32 && nonpic } } } } */
-/* { dg-options "-O2 -std=gnu99 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" } */
+/* { dg-do compile { target { ilp32 && nonpic } } } */
+/* { dg-options "-O2 -msse2 -mpreferred-stack-boundary=4 -mstackrealign" } */
/* { dg-final { scan-assembler-not "andl\[\\t \]*\\$-16,\[\\t \]*%\[re\]?sp" } } */
/* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */
/* { dg-final { scan-assembler "jmp\[\\t \]*foo" } } */
-extern int foo (_Decimal128);
+#include <emmintrin.h>
-int bar (_Decimal128 x)
+extern int foo (__m128, __m128, __m128, __m128);
+
+int bar (__m128 x1, __m128 x2, __m128 x3, __m128 x4)
{
- return foo(x);
+ return foo (x1, x2, x3, x4);
}