* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP @ 2008-11-05 16:52 Uros Bizjak 2008-11-05 18:18 ` H.J. Lu 0 siblings, 1 reply; 17+ messages in thread From: Uros Bizjak @ 2008-11-05 16:52 UTC (permalink / raw) To: GCC Patches; +Cc: H.J. Lu Hello! > Here is the updated version. When we update stack boundary before > expanding a function, we don't need to check parm_stack_boundary > in expand_stack_alignment. Tested on Linux/ia32, Linux/Intel64 and > Linux/ia64. OK for trunk? > > Thanks. > > > -- > H.J. > ---- > gcc/ > > 2008-11-04 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. > > * config/i386/i386.c (ix86_function_ok_for_sibcall): Return > false if we need to align the outgoing stack. > (ix86_update_stack_boundary): Check parm_stack_boundary. > > gcc/testsuite/ > > 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> > > PR middle-end/37843 > * gcc.target/i386/align-main-3.c: New. > * gcc.target/i386/pr37843-1.c: Likewise. > * gcc.target/i386/pr37843-2.c: Likewise. > * gcc.target/i386/pr37843-3.c: Likewise. > > --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 08:33:41.000000000 -0800 > +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-04 08:33:41.000000000 -0800 > @@ -0,0 +1,14 @@ > +/* Test for stack alignment with sibcall optimization. */ > +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */ > It is enough to check for "target { *-*-linux* && ilp32 }", since we execute gcc.target/i386 for i?86 and x86_64 targets only. > --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 08:33:41.000000000 -0800 > +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-04 08:33:41.000000000 -0800 > @@ -0,0 +1,13 @@ > +/* Test for stack alignment with sibcall optimization. */ > +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */ > Same here. Thanks, Uros. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-05 16:52 PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP Uros Bizjak @ 2008-11-05 18:18 ` H.J. Lu 2008-11-11 12:19 ` H.J. Lu 2008-11-26 15:57 ` H.J. Lu 0 siblings, 2 replies; 17+ messages in thread From: H.J. Lu @ 2008-11-05 18:18 UTC (permalink / raw) To: Uros Bizjak, Ye, Joey, Guo, Xuepeng; +Cc: GCC Patches [-- Attachment #1: Type: text/plain, Size: 2247 bytes --] On Wed, Nov 5, 2008 at 8:49 AM, Uros Bizjak <ubizjak@gmail.com> wrote: > Hello! > >> Here is the updated version. When we update stack boundary before >> expanding a function, we don't need to check parm_stack_boundary >> in expand_stack_alignment. Tested on Linux/ia32, Linux/Intel64 and >> Linux/ia64. OK for trunk? >> >> Thanks. >> >> >> -- >> H.J. >> ---- >> gcc/ >> >> 2008-11-04 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. >> >> * config/i386/i386.c (ix86_function_ok_for_sibcall): Return >> false if we need to align the outgoing stack. >> (ix86_update_stack_boundary): Check parm_stack_boundary. >> >> gcc/testsuite/ >> >> 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> >> >> PR middle-end/37843 >> * gcc.target/i386/align-main-3.c: New. >> * gcc.target/i386/pr37843-1.c: Likewise. >> * gcc.target/i386/pr37843-2.c: Likewise. >> * gcc.target/i386/pr37843-3.c: Likewise. >> > >> --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 >> 08:33:41.000000000 -0800 >> +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-04 >> 08:33:41.000000000 -0800 >> @@ -0,0 +1,14 @@ >> +/* Test for stack alignment with sibcall optimization. */ >> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 >> } } } */ >> > > > It is enough to check for "target { *-*-linux* && ilp32 }", since we > execute gcc.target/i386 for i?86 and x86_64 targets only. > >> --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 >> 08:33:41.000000000 -0800 >> +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-04 >> 08:33:41.000000000 -0800 >> @@ -0,0 +1,13 @@ >> +/* Test for stack alignment with sibcall optimization. */ >> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 >> } } } */ >> > > Same here. > Here is the updated patch. Tested on Linux/ia32, Linux/Intel64 and Linux/ia64. OK for trunk? Thanks. -- H.J. [-- Attachment #2: gcc-sibcall-4.patch --] [-- Type: application/octet-stream, Size: 6604 bytes --] gcc/ 2008-11-04 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. * config/i386/i386.c (ix86_function_ok_for_sibcall): Return false if we need to align the outgoing stack. (ix86_update_stack_boundary): Check parm_stack_boundary. gcc/testsuite/ 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/37843 * gcc.target/i386/align-main-3.c: New. * gcc.target/i386/pr37843-1.c: Likewise. * gcc.target/i386/pr37843-2.c: Likewise. * gcc.target/i386/pr37843-3.c: Likewise. --- gcc/cfgexpand.c.sibcall 2008-10-09 07:05:53.000000000 -0700 +++ gcc/cfgexpand.c 2008-11-04 21:44:12.000000000 -0800 @@ -2218,7 +2218,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; @@ -2231,10 +2231,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 @@ -2249,15 +2245,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; @@ -2362,6 +2351,17 @@ gimple_expand_cfg (void) if (crtl->stack_protect_guard) stack_protect_prologue (); + /* Update stack boundary if needed. */ + if (SUPPORTS_STACK_ALIGNMENT) + { + 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 (); --- gcc/config/i386/i386.c.sibcall 2008-11-04 21:44:12.000000000 -0800 +++ gcc/config/i386/i386.c 2008-11-04 21:44:12.000000000 -0800 @@ -4116,6 +4116,11 @@ ix86_function_ok_for_sibcall (tree decl, && ix86_function_regparm (TREE_TYPE (decl), NULL) >= 3) return false; + /* If we need to align the outgoing stack, then sibcalling would + unalign the stack, which may break the called function. */ + if (ix86_incoming_stack_boundary < PREFERRED_STACK_BOUNDARY) + return false; + /* Otherwise okay. That also includes certain types of indirect calls. */ return true; } @@ -7765,6 +7770,11 @@ ix86_update_stack_boundary (void) TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl)))) ix86_incoming_stack_boundary = MIN_STACK_BOUNDARY; + /* The incoming stack frame has to be aligned at least at + parm_stack_boundary. */ + if (ix86_incoming_stack_boundary < crtl->parm_stack_boundary) + ix86_incoming_stack_boundary = crtl->parm_stack_boundary; + /* Stack at entrance of main is aligned by runtime. We use the smallest incoming stack boundary. */ if (ix86_incoming_stack_boundary > MAIN_STACK_BOUNDARY --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 21:44:12.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-05 09:58:01.000000000 -0800 @@ -0,0 +1,14 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-do compile { target { *-*-linux* && ilp32 } } } */ +/* { dg-options "-O2 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" } */ +/* { dg-final { scan-assembler "andl\[\\t \]*\\$-16,\[\\t \]*%\[re\]?sp" } } */ +/* { dg-final { scan-assembler "call\[\\t \]*foo" } } */ +/* { dg-final { scan-assembler-not "jmp\[\\t \]*foo" } } */ + +extern int foo (void); + +int +main () +{ + return foo (); +} --- gcc/testsuite/gcc.target/i386/pr37843-1.c.sibcall 2008-11-04 21:44:12.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/pr37843-1.c 2008-11-04 21:44:12.000000000 -0800 @@ -0,0 +1,12 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=5" } */ +/* { dg-final { scan-assembler "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ +/* { dg-final { scan-assembler "call\[\\t \]*foo" } } */ +/* { dg-final { scan-assembler-not "jmp\[\\t \]*foo" } } */ + +extern int foo (void); + +int bar (void) +{ + return foo(); +} --- gcc/testsuite/gcc.target/i386/pr37843-2.c.sibcall 2008-11-04 21:44:12.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/pr37843-2.c 2008-11-04 21:44:12.000000000 -0800 @@ -0,0 +1,12 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=6" } */ +/* { dg-final { scan-assembler-not "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ +/* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ +/* { dg-final { scan-assembler "jmp\[\\t \]*foo" } } */ + +extern int foo (void); + +int bar (void) +{ + return foo(); +} --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 21:44:12.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-05 09:58:13.000000000 -0800 @@ -0,0 +1,13 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-do compile { target { *-*-linux* && ilp32 } } } */ +/* { dg-options "-O2 -std=gnu99 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" } */ +/* { 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); + +int bar (_Decimal128 x) +{ + return foo(x); +} ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-05 18:18 ` H.J. Lu @ 2008-11-11 12:19 ` H.J. Lu 2008-11-19 18:27 ` H.J. Lu 2008-11-26 15:57 ` H.J. Lu 1 sibling, 1 reply; 17+ messages in thread From: H.J. Lu @ 2008-11-11 12:19 UTC (permalink / raw) To: Uros Bizjak, Ye, Joey, Guo, Xuepeng; +Cc: GCC Patches On Wed, Nov 5, 2008 at 10:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote: > On Wed, Nov 5, 2008 at 8:49 AM, Uros Bizjak <ubizjak@gmail.com> wrote: >> Hello! >> >>> Here is the updated version. When we update stack boundary before >>> expanding a function, we don't need to check parm_stack_boundary >>> in expand_stack_alignment. Tested on Linux/ia32, Linux/Intel64 and >>> Linux/ia64. OK for trunk? >>> >>> Thanks. >>> >>> >>> -- >>> H.J. >>> ---- >>> gcc/ >>> >>> 2008-11-04 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. >>> >>> * config/i386/i386.c (ix86_function_ok_for_sibcall): Return >>> false if we need to align the outgoing stack. >>> (ix86_update_stack_boundary): Check parm_stack_boundary. >>> >>> gcc/testsuite/ >>> >>> 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> >>> >>> PR middle-end/37843 >>> * gcc.target/i386/align-main-3.c: New. >>> * gcc.target/i386/pr37843-1.c: Likewise. >>> * gcc.target/i386/pr37843-2.c: Likewise. >>> * gcc.target/i386/pr37843-3.c: Likewise. >>> >> >>> --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 >>> 08:33:41.000000000 -0800 >>> +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-04 >>> 08:33:41.000000000 -0800 >>> @@ -0,0 +1,14 @@ >>> +/* Test for stack alignment with sibcall optimization. */ >>> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 >>> } } } */ >>> >> >> >> It is enough to check for "target { *-*-linux* && ilp32 }", since we >> execute gcc.target/i386 for i?86 and x86_64 targets only. >> >>> --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 >>> 08:33:41.000000000 -0800 >>> +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-04 >>> 08:33:41.000000000 -0800 >>> @@ -0,0 +1,13 @@ >>> +/* Test for stack alignment with sibcall optimization. */ >>> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 >>> } } } */ >>> >> >> Same here. >> > > Here is the updated patch. Tested on Linux/ia32, Linux/Intel64 and > Linux/ia64. OK for trunk? > > Thanks. > Ping. -- H.J. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-11 12:19 ` H.J. Lu @ 2008-11-19 18:27 ` H.J. Lu 0 siblings, 0 replies; 17+ messages in thread From: H.J. Lu @ 2008-11-19 18:27 UTC (permalink / raw) To: Uros Bizjak, Ye, Joey, Guo, Xuepeng; +Cc: GCC Patches On Mon, Nov 10, 2008 at 10:50 PM, H.J. Lu <hjl.tools@gmail.com> wrote: > On Wed, Nov 5, 2008 at 10:06 AM, H.J. Lu <hjl.tools@gmail.com> wrote: >> On Wed, Nov 5, 2008 at 8:49 AM, Uros Bizjak <ubizjak@gmail.com> wrote: >>> Hello! >>> >>>> Here is the updated version. When we update stack boundary before >>>> expanding a function, we don't need to check parm_stack_boundary >>>> in expand_stack_alignment. Tested on Linux/ia32, Linux/Intel64 and >>>> Linux/ia64. OK for trunk? >>>> >>>> Thanks. >>>> >>>> >>>> -- >>>> H.J. >>>> ---- >>>> gcc/ >>>> >>>> 2008-11-04 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. >>>> >>>> * config/i386/i386.c (ix86_function_ok_for_sibcall): Return >>>> false if we need to align the outgoing stack. >>>> (ix86_update_stack_boundary): Check parm_stack_boundary. >>>> >>>> gcc/testsuite/ >>>> >>>> 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> >>>> >>>> PR middle-end/37843 >>>> * gcc.target/i386/align-main-3.c: New. >>>> * gcc.target/i386/pr37843-1.c: Likewise. >>>> * gcc.target/i386/pr37843-2.c: Likewise. >>>> * gcc.target/i386/pr37843-3.c: Likewise. >>>> >>> >>>> --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 >>>> 08:33:41.000000000 -0800 >>>> +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-04 >>>> 08:33:41.000000000 -0800 >>>> @@ -0,0 +1,14 @@ >>>> +/* Test for stack alignment with sibcall optimization. */ >>>> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 >>>> } } } */ >>>> >>> >>> >>> It is enough to check for "target { *-*-linux* && ilp32 }", since we >>> execute gcc.target/i386 for i?86 and x86_64 targets only. >>> >>>> --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 >>>> 08:33:41.000000000 -0800 >>>> +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-04 >>>> 08:33:41.000000000 -0800 >>>> @@ -0,0 +1,13 @@ >>>> +/* Test for stack alignment with sibcall optimization. */ >>>> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 >>>> } } } */ >>>> >>> >>> Same here. >>> >> >> Here is the updated patch. Tested on Linux/ia32, Linux/Intel64 and >> Linux/ia64. OK for trunk? >> >> Thanks. >> > > Ping. > PING. -- H.J. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-05 18:18 ` H.J. Lu 2008-11-11 12:19 ` H.J. Lu @ 2008-11-26 15:57 ` H.J. Lu 2008-11-26 19:08 ` Jack Howarth 1 sibling, 1 reply; 17+ messages in thread From: H.J. Lu @ 2008-11-26 15:57 UTC (permalink / raw) To: Uros Bizjak, Ye, Joey, Guo, Xuepeng; +Cc: GCC Patches On Wed, Nov 05, 2008 at 10:06:57AM -0800, H.J. Lu wrote: > On Wed, Nov 5, 2008 at 8:49 AM, Uros Bizjak <ubizjak@gmail.com> wrote: > > Hello! > > > >> Here is the updated version. When we update stack boundary before > >> expanding a function, we don't need to check parm_stack_boundary > >> in expand_stack_alignment. Tested on Linux/ia32, Linux/Intel64 and > >> Linux/ia64. OK for trunk? > >> > >> Thanks. > >> > >> > >> -- > >> H.J. > >> ---- > >> gcc/ > >> > >> 2008-11-04 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. > >> > >> * config/i386/i386.c (ix86_function_ok_for_sibcall): Return > >> false if we need to align the outgoing stack. > >> (ix86_update_stack_boundary): Check parm_stack_boundary. > >> > >> gcc/testsuite/ > >> > >> 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> > >> > >> PR middle-end/37843 > >> * gcc.target/i386/align-main-3.c: New. > >> * gcc.target/i386/pr37843-1.c: Likewise. > >> * gcc.target/i386/pr37843-2.c: Likewise. > >> * gcc.target/i386/pr37843-3.c: Likewise. > >> > > > >> --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 > >> 08:33:41.000000000 -0800 > >> +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-04 > >> 08:33:41.000000000 -0800 > >> @@ -0,0 +1,14 @@ > >> +/* Test for stack alignment with sibcall optimization. */ > >> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 > >> } } } */ > >> > > > > > > It is enough to check for "target { *-*-linux* && ilp32 }", since we > > execute gcc.target/i386 for i?86 and x86_64 targets only. > > > >> --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 > >> 08:33:41.000000000 -0800 > >> +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-04 > >> 08:33:41.000000000 -0800 > >> @@ -0,0 +1,13 @@ > >> +/* Test for stack alignment with sibcall optimization. */ > >> +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 > >> } } } */ > >> > > > > Same here. > > > > Here is the updated patch. Tested on Linux/ia32, Linux/Intel64 and > Linux/ia64. OK for trunk? > Darwin doesn't support sibcall. I am checking it to mark them Linux only. H.J. --- Index: gcc.target/i386/pr37843-2.c =================================================================== --- gcc.target/i386/pr37843-2.c (revision 142193) +++ gcc.target/i386/pr37843-2.c (working copy) @@ -1,4 +1,5 @@ /* Test for stack alignment with sibcall optimization. */ +/* { dg-do compile { target *-*-linux* } } */ /* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=6" } */ /* { dg-final { scan-assembler-not "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ /* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ Index: gcc.target/i386/pr37843-1.c =================================================================== --- gcc.target/i386/pr37843-1.c (revision 142193) +++ gcc.target/i386/pr37843-1.c (working copy) @@ -1,4 +1,5 @@ /* Test for stack alignment with sibcall optimization. */ +/* { dg-do compile { target *-*-linux* } } */ /* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=5" } */ /* { dg-final { scan-assembler "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ /* { dg-final { scan-assembler "call\[\\t \]*foo" } } */ Index: ChangeLog =================================================================== --- ChangeLog (revision 142193) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2008-11-26 H.J. Lu <hongjiu.lu@intel.com> + + * gcc.target/i386/pr37843-1.c: Make it Linux only. + * gcc.target/i386/pr37843-2.c: Likewise. + 2008-11-25 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/37843 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-26 15:57 ` H.J. Lu @ 2008-11-26 19:08 ` Jack Howarth 2008-11-26 19:42 ` H.J. Lu 0 siblings, 1 reply; 17+ messages in thread From: Jack Howarth @ 2008-11-26 19:08 UTC (permalink / raw) To: H.J. Lu; +Cc: Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Wed, Nov 26, 2008 at 06:50:08AM -0800, H.J. Lu wrote: > > Darwin doesn't support sibcall. I am checking it to mark them Linux > only. > > > H.J. H.J., Could you expand on that comment? Is the problem with sibcall on Darwin that FSF gcc doesn't have the proper darwin specific changes to implement sibcall or is the problem that the darwin assembler or linker from Xcode doesn't properly support sibcall? If the problem is the latter, we could submit a radar bug report asking for sibcall support to be implemented in the cctools of Snow Leopard. Jack ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-26 19:08 ` Jack Howarth @ 2008-11-26 19:42 ` H.J. Lu 2008-11-26 20:07 ` Andrew Pinski 0 siblings, 1 reply; 17+ messages in thread From: H.J. Lu @ 2008-11-26 19:42 UTC (permalink / raw) To: Jack Howarth; +Cc: Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Wed, Nov 26, 2008 at 9:34 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote: > On Wed, Nov 26, 2008 at 06:50:08AM -0800, H.J. Lu wrote: >> >> Darwin doesn't support sibcall. I am checking it to mark them Linux >> only. >> >> >> H.J. > > H.J., > Could you expand on that comment? Is the problem with sibcall on > Darwin that FSF gcc doesn't have the proper darwin specific changes > to implement sibcall or is the problem that the darwin assembler or > linker from Xcode doesn't properly support sibcall? If the problem is > the latter, we could submit a radar bug report asking for sibcall > support to be implemented in the cctools of Snow Leopard. > Jack static bool ix86_function_ok_for_sibcall (tree decl, tree exp) { tree func; rtx a, b; /* If we are generating position-independent code, we cannot sibcall optimize any indirect call, or a direct call to a global function, as the PLT requires %ebx be live. */ if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl))) return false; Darwin returns false. -- H.J. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-26 19:42 ` H.J. Lu @ 2008-11-26 20:07 ` Andrew Pinski 2008-11-26 20:35 ` Jack Howarth 2008-11-28 16:03 ` Kaveh R. GHAZI 0 siblings, 2 replies; 17+ messages in thread From: Andrew Pinski @ 2008-11-26 20:07 UTC (permalink / raw) To: H.J. Lu; +Cc: Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Wed, Nov 26, 2008 at 10:02 AM, H.J. Lu <hjl.tools@gmail.com> wrote: > On Wed, Nov 26, 2008 at 9:34 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote: >> On Wed, Nov 26, 2008 at 06:50:08AM -0800, H.J. Lu wrote: >>> >>> Darwin doesn't support sibcall. I am checking it to mark them Linux >>> only. >>> >>> >>> H.J. >> >> H.J., >> Could you expand on that comment? Is the problem with sibcall on >> Darwin that FSF gcc doesn't have the proper darwin specific changes >> to implement sibcall or is the problem that the darwin assembler or >> linker from Xcode doesn't properly support sibcall? If the problem is >> the latter, we could submit a radar bug report asking for sibcall >> support to be implemented in the cctools of Snow Leopard. >> Jack > > static bool > ix86_function_ok_for_sibcall (tree decl, tree exp) > { > tree func; > rtx a, b; > > /* If we are generating position-independent code, we cannot sibcall > optimize any indirect call, or a direct call to a global function, > as the PLT requires %ebx be live. */ > if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl))) > return false; > > Darwin returns false. > Because darwin is always pic though binds_local_p should return true ... -- Pinski ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-26 20:07 ` Andrew Pinski @ 2008-11-26 20:35 ` Jack Howarth 2008-11-28 16:03 ` Kaveh R. GHAZI 1 sibling, 0 replies; 17+ messages in thread From: Jack Howarth @ 2008-11-26 20:35 UTC (permalink / raw) To: Andrew Pinski; +Cc: H.J. Lu, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Wed, Nov 26, 2008 at 10:14:25AM -0800, Andrew Pinski wrote: > On Wed, Nov 26, 2008 at 10:02 AM, H.J. Lu <hjl.tools@gmail.com> wrote: > > On Wed, Nov 26, 2008 at 9:34 AM, Jack Howarth <howarth@bromo.med.uc.edu> wrote: > >> On Wed, Nov 26, 2008 at 06:50:08AM -0800, H.J. Lu wrote: > >>> > >>> Darwin doesn't support sibcall. I am checking it to mark them Linux > >>> only. > >>> > >>> > >>> H.J. > >> > >> H.J., > >> Could you expand on that comment? Is the problem with sibcall on > >> Darwin that FSF gcc doesn't have the proper darwin specific changes > >> to implement sibcall or is the problem that the darwin assembler or > >> linker from Xcode doesn't properly support sibcall? If the problem is > >> the latter, we could submit a radar bug report asking for sibcall > >> support to be implemented in the cctools of Snow Leopard. > >> Jack > > > > static bool > > ix86_function_ok_for_sibcall (tree decl, tree exp) > > { > > tree func; > > rtx a, b; > > > > /* If we are generating position-independent code, we cannot sibcall > > optimize any indirect call, or a direct call to a global function, > > as the PLT requires %ebx be live. */ > > if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl))) > > return false; > > > > Darwin returns false. > > > > Because darwin is always pic though binds_local_p should return true ... > > -- Pinski Andrew, Is that true even if the code were compiled with -fno-PIC on darwin? Jack ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-26 20:07 ` Andrew Pinski 2008-11-26 20:35 ` Jack Howarth @ 2008-11-28 16:03 ` Kaveh R. GHAZI 2008-11-28 17:58 ` H.J. Lu 1 sibling, 1 reply; 17+ messages in thread From: Kaveh R. GHAZI @ 2008-11-28 16:03 UTC (permalink / raw) To: Andrew Pinski Cc: H.J. Lu, Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Wed, 26 Nov 2008, Andrew Pinski wrote: > On Wed, Nov 26, 2008 at 10:02 AM, H.J. Lu <hjl.tools@gmail.com> wrote: > >>> > >>> Darwin doesn't support sibcall. I am checking it to mark them Linux > >>> only. > >>> H.J. > >> > > static bool > > ix86_function_ok_for_sibcall (tree decl, tree exp) > > { > > tree func; > > rtx a, b; > > > > /* If we are generating position-independent code, we cannot sibcall > > optimize any indirect call, or a direct call to a global function, > > as the PLT requires %ebx be live. */ > > if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl))) > > return false; > > > > Darwin returns false. > > > > Because darwin is always pic though binds_local_p should return true ... > -- Pinski HJ, You should change the target selector from "*-*-linux*" to "nonpic" since you'll get a failure on linux with "-m32 -fpic", e.g: http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02492.html Note: pr37843-3.c is failing on the nonpic case as well. Even in your own testsuite results. E.g: http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02491.html --Kaveh -- Kaveh R. Ghazi ghazi@caip.rutgers.edu ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-28 16:03 ` Kaveh R. GHAZI @ 2008-11-28 17:58 ` H.J. Lu 2008-11-29 17:59 ` H.J. Lu 0 siblings, 1 reply; 17+ messages in thread From: H.J. Lu @ 2008-11-28 17:58 UTC (permalink / raw) To: Kaveh R. GHAZI Cc: Andrew Pinski, Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Fri, Nov 28, 2008 at 10:49:16AM -0500, Kaveh R. GHAZI wrote: > On Wed, 26 Nov 2008, Andrew Pinski wrote: > > > On Wed, Nov 26, 2008 at 10:02 AM, H.J. Lu <hjl.tools@gmail.com> wrote: > > >>> > > >>> Darwin doesn't support sibcall. I am checking it to mark them Linux > > >>> only. > > >>> H.J. > > >> > > > static bool > > > ix86_function_ok_for_sibcall (tree decl, tree exp) > > > { > > > tree func; > > > rtx a, b; > > > > > > /* If we are generating position-independent code, we cannot sibcall > > > optimize any indirect call, or a direct call to a global function, > > > as the PLT requires %ebx be live. */ > > > if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl))) > > > return false; > > > > > > Darwin returns false. > > > > > > > Because darwin is always pic though binds_local_p should return true ... > > -- Pinski > > HJ, > > You should change the target selector from "*-*-linux*" to "nonpic" since > you'll get a failure on linux with "-m32 -fpic", e.g: > > http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02492.html I am checking in this patch to make them for nonpic only. > > Note: pr37843-3.c is failing on the nonpic case as well. Even in your own > testsuite results. E.g: > > http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02491.html > See: http://gcc.gnu.org/ml/gcc-patches/2008-11/msg01309.html Thanks. H.J. --- Index: gcc.target/i386/pr37843-2.c =================================================================== --- gcc.target/i386/pr37843-2.c (revision 142258) +++ gcc.target/i386/pr37843-2.c (working copy) @@ -1,5 +1,5 @@ /* Test for stack alignment with sibcall optimization. */ -/* { dg-do compile { target *-*-linux* } } */ +/* { dg-do compile { target nonpic } } */ /* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=6" } */ /* { dg-final { scan-assembler-not "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ /* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ Index: gcc.target/i386/pr37843-1.c =================================================================== --- gcc.target/i386/pr37843-1.c (revision 142258) +++ gcc.target/i386/pr37843-1.c (working copy) @@ -1,5 +1,5 @@ /* Test for stack alignment with sibcall optimization. */ -/* { dg-do compile { target *-*-linux* } } */ +/* { dg-do compile { target nonpic } } */ /* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=5" } */ /* { dg-final { scan-assembler "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ /* { dg-final { scan-assembler "call\[\\t \]*foo" } } */ Index: ChangeLog =================================================================== --- ChangeLog (revision 142258) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2008-11-28 H.J. Lu <hongjiu.lu@intel.com> + + PR middle-end/37843 + * gcc.target/i386/pr37843-1.c: Make it nonpic targets only. + * gcc.target/i386/pr37843-2.c: Likewise. + 2008-11-28 Richard Guenther <rguenther@suse.de> PR tree-optimization/37955 ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-28 17:58 ` H.J. Lu @ 2008-11-29 17:59 ` H.J. Lu 2008-11-30 5:18 ` PING: PATCH: PR middle-end/37843:[4.4 Regression] unalignedstack " Kaveh R. Ghazi 0 siblings, 1 reply; 17+ messages in thread From: H.J. Lu @ 2008-11-29 17:59 UTC (permalink / raw) To: Kaveh R. GHAZI Cc: Andrew Pinski, Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Fri, Nov 28, 2008 at 08:30:35AM -0800, H.J. Lu wrote: > On Fri, Nov 28, 2008 at 10:49:16AM -0500, Kaveh R. GHAZI wrote: > > On Wed, 26 Nov 2008, Andrew Pinski wrote: > > > > > On Wed, Nov 26, 2008 at 10:02 AM, H.J. Lu <hjl.tools@gmail.com> wrote: > > > >>> > > > >>> Darwin doesn't support sibcall. I am checking it to mark them Linux > > > >>> only. > > > >>> H.J. > > > >> > > > > static bool > > > > ix86_function_ok_for_sibcall (tree decl, tree exp) > > > > { > > > > tree func; > > > > rtx a, b; > > > > > > > > /* If we are generating position-independent code, we cannot sibcall > > > > optimize any indirect call, or a direct call to a global function, > > > > as the PLT requires %ebx be live. */ > > > > if (!TARGET_64BIT && flag_pic && (!decl || !targetm.binds_local_p (decl))) > > > > return false; > > > > > > > > Darwin returns false. > > > > > > > > > > Because darwin is always pic though binds_local_p should return true ... > > > -- Pinski > > > > HJ, > > > > You should change the target selector from "*-*-linux*" to "nonpic" since > > you'll get a failure on linux with "-m32 -fpic", e.g: > > > > http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02492.html > > I am checking in this patch to make them for nonpic only. > > > > > Note: pr37843-3.c is failing on the nonpic case as well. Even in your own > > testsuite results. E.g: > > > > http://gcc.gnu.org/ml/gcc-testresults/2008-11/msg02491.html > > > > See: > > http://gcc.gnu.org/ml/gcc-patches/2008-11/msg01309.html > Even after middle-end patch is applied, pr37843-3.c only works with non-PIC. I am applying this patch. H.J. --- Index: gcc.target/i386/pr37843-3.c =================================================================== --- gcc.target/i386/pr37843-3.c (revision 142277) +++ gcc.target/i386/pr37843-3.c (working copy) @@ -1,5 +1,5 @@ /* Test for stack alignment with sibcall optimization. */ -/* { dg-do compile { target { *-*-linux* && ilp32 } } } */ +/* { dg-do compile { target { *-*-linux* && { ilp32 && nonpic } } } } */ /* { dg-options "-O2 -std=gnu99 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" } */ /* { dg-final { scan-assembler-not "andl\[\\t \]*\\$-16,\[\\t \]*%\[re\]?sp" } } */ /* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ Index: ChangeLog =================================================================== --- ChangeLog (revision 142277) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2008-11-29 H.J. Lu <hongjiu.lu@intel.com> + + PR middle-end/37843 + * gcc.target/i386/pr37843-3.c: Make it nonpic targets only. + 2008-11-29 Janus Weil <janus@gcc.gnu.org> Tobias Burnus <burnus@gcc.gnu.org> ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unalignedstack in maindue to tail call optimizatiP 2008-11-29 17:59 ` H.J. Lu @ 2008-11-30 5:18 ` Kaveh R. Ghazi 2008-11-30 8:52 ` H.J. Lu 0 siblings, 1 reply; 17+ messages in thread From: Kaveh R. Ghazi @ 2008-11-30 5:18 UTC (permalink / raw) To: H.J. Lu Cc: Andrew Pinski, Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches From: "H.J. Lu" <hjl.tools@gmail.com> > Even after middle-end patch is applied, pr37843-3.c only works with > non-PIC. I am applying this patch. > H.J. > --- > Index: gcc.target/i386/pr37843-3.c > =================================================================== > --- gcc.target/i386/pr37843-3.c (revision 142277) > +++ gcc.target/i386/pr37843-3.c (working copy) > @@ -1,5 +1,5 @@ > /* Test for stack alignment with sibcall optimization. */ > -/* { dg-do compile { target { *-*-linux* && ilp32 } } } */ > +/* { dg-do compile { target { *-*-linux* && { ilp32 && nonpic } } } } */ > /* { dg-options > "-O2 -std=gnu99 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" > } */ > /* { dg-final { scan-assembler-not "andl\[\\t \]*\\$-16,\[\\t > \]*%\[re\]?sp" } } */ > /* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ Why did you leave in *-*-linux* ? Other nonpic x86 targets should test it also IMHO. --Kaveh ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unalignedstack in maindue to tail call optimizatiP 2008-11-30 5:18 ` PING: PATCH: PR middle-end/37843:[4.4 Regression] unalignedstack " Kaveh R. Ghazi @ 2008-11-30 8:52 ` H.J. Lu 2008-11-30 15:47 ` Kaveh R. Ghazi 0 siblings, 1 reply; 17+ messages in thread From: H.J. Lu @ 2008-11-30 8:52 UTC (permalink / raw) To: Kaveh R. Ghazi Cc: Andrew Pinski, Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches On Sat, Nov 29, 2008 at 3:19 PM, Kaveh R. Ghazi <ghazi@caip.rutgers.edu> wrote: > From: "H.J. Lu" <hjl.tools@gmail.com> > >> Even after middle-end patch is applied, pr37843-3.c only works with >> non-PIC. I am applying this patch. >> H.J. >> --- >> Index: gcc.target/i386/pr37843-3.c >> =================================================================== >> --- gcc.target/i386/pr37843-3.c (revision 142277) >> +++ gcc.target/i386/pr37843-3.c (working copy) >> @@ -1,5 +1,5 @@ >> /* Test for stack alignment with sibcall optimization. */ >> -/* { dg-do compile { target { *-*-linux* && ilp32 } } } */ >> +/* { dg-do compile { target { *-*-linux* && { ilp32 && nonpic } } } } */ >> /* { dg-options "-O2 -std=gnu99 -mpreferred-stack-boundary=4 >> -mincoming-stack-boundary=2" } */ >> /* { dg-final { scan-assembler-not "andl\[\\t \]*\\$-16,\[\\t >> \]*%\[re\]?sp" } } */ >> /* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ > > Why did you leave in *-*-linux* ? Other nonpic x86 targets should test it > also IMHO. > Only Linux supports DFP. -- H.J. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unalignedstack in maindue to tail call optimizatiP 2008-11-30 8:52 ` H.J. Lu @ 2008-11-30 15:47 ` Kaveh R. Ghazi 0 siblings, 0 replies; 17+ messages in thread From: Kaveh R. Ghazi @ 2008-11-30 15:47 UTC (permalink / raw) To: H.J. Lu Cc: Andrew Pinski, Jack Howarth, Uros Bizjak, Ye, Joey, Guo, Xuepeng, GCC Patches From: "H.J. Lu" <hjl.tools@gmail.com> >> Why did you leave in *-*-linux* ? Other nonpic x86 targets should test >> it >> also IMHO. >> > > Only Linux supports DFP. > H.J. In that case you should change "*-*-linux*" to "dfp". We have a testsuite check for that. --Kaveh ^ permalink raw reply [flat|nested] 17+ messages in thread
* PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP
@ 2008-11-01 0:25 H.J. Lu
2008-11-04 17:54 ` H.J. Lu
0 siblings, 1 reply; 17+ messages in thread
From: H.J. Lu @ 2008-11-01 0:25 UTC (permalink / raw)
To: GCC Patches
On Fri, Oct 24, 2008 at 3:38 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Oct 17, 2008 at 10:06 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> H.J. Lu wrote:
>>
>>>
>>> The problem is sibcall optimization will use the incoming stack
>>> boundary as the outgoing stack boundary. It is OK as long as
>>> the incoming stack boundary >= the outgoing stack boundary.
>>> ix86_function_ok_for_sibcall needs to know the precise incoming
>>> stack boundary, which is set in expand_stack_alignment, to
>>> check if the incoming stack boundary >= the outgoing stack
>>> boundary.
>>>
>>> This patch moves updating stack boundary before
>>> TARGET_FUNCTION_OK_FOR_SIBCALL is called. It
>>> changes cfgexpand.c and i386.c. OK for trunk?
>>>
>>> Thanks.
>>>
>>> 2008-10-15 H.J. Lu <hongjiu.lu@intel.com>
>>> Joey Ye <joey.ye@intel.com>
>>>
>>> PR target/37843
>>> * cfgexpand.c (expand_stack_alignment): Move updating stack
>>> boundary to ...
>>> (gimple_expand_cfg): Here.
>>>
>>> * config/i386/i386.c (ix86_function_ok_for_sibcall): Return
>>> false if we need to align the outgoing stack.
>>> (ix86_update_stack_boundary): Check parm_stack_boundary.
>>>
>>> gcc/testsuite/
>>>
>>> 2008-10-15 H.J. Lu <hongjiu.lu@intel.com>
>>>
>>> PR target/37843
>>> * gcc.target/i386/align-main-3.c: New.
>>> * gcc.target/i386/pr37843-1.c: Likewise.
>>> * gcc.target/i386/pr37843-2.c: Likewise.
>>> * gcc.target/i386/pr37843-3.c: Likewise.
>>
>> x86 part is OK, but generic part needs middle-end review.
>>
>> Thanks,
>> Uros.
>>
>
> Could middle-end reviewers take a look at cfgexpand.c change?
>
Ping:
http://gcc.gnu.org/ml/gcc-patches/2008-10/msg00724.html
--
H.J.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP 2008-11-01 0:25 PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack " H.J. Lu @ 2008-11-04 17:54 ` H.J. Lu 0 siblings, 0 replies; 17+ messages in thread From: H.J. Lu @ 2008-11-04 17:54 UTC (permalink / raw) To: GCC Patches [-- Attachment #1: Type: text/plain, Size: 2772 bytes --] On Fri, Oct 31, 2008 at 4:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote: > On Fri, Oct 24, 2008 at 3:38 PM, H.J. Lu <hjl.tools@gmail.com> wrote: >> On Fri, Oct 17, 2008 at 10:06 AM, Uros Bizjak <ubizjak@gmail.com> wrote: >>> H.J. Lu wrote: >>> >>>> >>>> The problem is sibcall optimization will use the incoming stack >>>> boundary as the outgoing stack boundary. It is OK as long as >>>> the incoming stack boundary >= the outgoing stack boundary. >>>> ix86_function_ok_for_sibcall needs to know the precise incoming >>>> stack boundary, which is set in expand_stack_alignment, to >>>> check if the incoming stack boundary >= the outgoing stack >>>> boundary. >>>> >>>> This patch moves updating stack boundary before >>>> TARGET_FUNCTION_OK_FOR_SIBCALL is called. It >>>> changes cfgexpand.c and i386.c. OK for trunk? >>>> >>>> Thanks. >>>> >>>> 2008-10-15 H.J. Lu <hongjiu.lu@intel.com> >>>> Joey Ye <joey.ye@intel.com> >>>> >>>> PR target/37843 >>>> * cfgexpand.c (expand_stack_alignment): Move updating stack >>>> boundary to ... >>>> (gimple_expand_cfg): Here. >>>> >>>> * config/i386/i386.c (ix86_function_ok_for_sibcall): Return >>>> false if we need to align the outgoing stack. >>>> (ix86_update_stack_boundary): Check parm_stack_boundary. >>>> >>>> gcc/testsuite/ >>>> >>>> 2008-10-15 H.J. Lu <hongjiu.lu@intel.com> >>>> >>>> PR target/37843 >>>> * gcc.target/i386/align-main-3.c: New. >>>> * gcc.target/i386/pr37843-1.c: Likewise. >>>> * gcc.target/i386/pr37843-2.c: Likewise. >>>> * gcc.target/i386/pr37843-3.c: Likewise. >>> >>> x86 part is OK, but generic part needs middle-end review. >>> >>> Thanks, >>> Uros. >>> >> >> Could middle-end reviewers take a look at cfgexpand.c change? >> > Here is the updated version. When we update stack boundary before expanding a function, we don't need to check parm_stack_boundary in expand_stack_alignment. Tested on Linux/ia32, Linux/Intel64 and Linux/ia64. OK for trunk? Thanks. -- H.J. ---- gcc/ 2008-11-04 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. * config/i386/i386.c (ix86_function_ok_for_sibcall): Return false if we need to align the outgoing stack. (ix86_update_stack_boundary): Check parm_stack_boundary. gcc/testsuite/ 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/37843 * gcc.target/i386/align-main-3.c: New. * gcc.target/i386/pr37843-1.c: Likewise. * gcc.target/i386/pr37843-2.c: Likewise. * gcc.target/i386/pr37843-3.c: Likewise. [-- Attachment #2: gcc-sibcall-3.patch --] [-- Type: application/octet-stream, Size: 6650 bytes --] gcc/ 2008-11-04 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. * config/i386/i386.c (ix86_function_ok_for_sibcall): Return false if we need to align the outgoing stack. (ix86_update_stack_boundary): Check parm_stack_boundary. gcc/testsuite/ 2008-11-04 H.J. Lu <hongjiu.lu@intel.com> PR middle-end/37843 * gcc.target/i386/align-main-3.c: New. * gcc.target/i386/pr37843-1.c: Likewise. * gcc.target/i386/pr37843-2.c: Likewise. * gcc.target/i386/pr37843-3.c: Likewise. --- gcc/cfgexpand.c.sibcall 2008-10-10 16:25:09.000000000 -0700 +++ gcc/cfgexpand.c 2008-11-04 09:12:00.000000000 -0800 @@ -2218,7 +2218,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; @@ -2231,10 +2231,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 @@ -2249,15 +2245,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; @@ -2362,6 +2351,17 @@ gimple_expand_cfg (void) if (crtl->stack_protect_guard) stack_protect_prologue (); + /* Update stack boundary if needed. */ + if (SUPPORTS_STACK_ALIGNMENT) + { + 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 (); --- gcc/config/i386/i386.c.sibcall 2008-10-29 20:23:25.000000000 -0700 +++ gcc/config/i386/i386.c 2008-11-04 08:33:41.000000000 -0800 @@ -4116,6 +4116,11 @@ ix86_function_ok_for_sibcall (tree decl, && ix86_function_regparm (TREE_TYPE (decl), NULL) >= 3) return false; + /* If we need to align the outgoing stack, then sibcalling would + unalign the stack, which may break the called function. */ + if (ix86_incoming_stack_boundary < PREFERRED_STACK_BOUNDARY) + return false; + /* Otherwise okay. That also includes certain types of indirect calls. */ return true; } @@ -7764,6 +7769,11 @@ ix86_update_stack_boundary (void) TYPE_ATTRIBUTES (TREE_TYPE (current_function_decl)))) ix86_incoming_stack_boundary = MIN_STACK_BOUNDARY; + /* The incoming stack frame has to be aligned at least at + parm_stack_boundary. */ + if (ix86_incoming_stack_boundary < crtl->parm_stack_boundary) + ix86_incoming_stack_boundary = crtl->parm_stack_boundary; + /* Stack at entrance of main is aligned by runtime. We use the smallest incoming stack boundary. */ if (ix86_incoming_stack_boundary > MAIN_STACK_BOUNDARY --- gcc/testsuite/gcc.target/i386/align-main-3.c.sibcall 2008-11-04 08:33:41.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/align-main-3.c 2008-11-04 08:33:41.000000000 -0800 @@ -0,0 +1,14 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */ +/* { dg-options "-O2 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" } */ +/* { dg-final { scan-assembler "andl\[\\t \]*\\$-16,\[\\t \]*%\[re\]?sp" } } */ +/* { dg-final { scan-assembler "call\[\\t \]*foo" } } */ +/* { dg-final { scan-assembler-not "jmp\[\\t \]*foo" } } */ + +extern int foo (void); + +int +main () +{ + return foo (); +} --- gcc/testsuite/gcc.target/i386/pr37843-1.c.sibcall 2008-11-04 08:33:41.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/pr37843-1.c 2008-11-04 08:33:41.000000000 -0800 @@ -0,0 +1,12 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=5" } */ +/* { dg-final { scan-assembler "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ +/* { dg-final { scan-assembler "call\[\\t \]*foo" } } */ +/* { dg-final { scan-assembler-not "jmp\[\\t \]*foo" } } */ + +extern int foo (void); + +int bar (void) +{ + return foo(); +} --- gcc/testsuite/gcc.target/i386/pr37843-2.c.sibcall 2008-11-04 08:33:41.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/pr37843-2.c 2008-11-04 08:33:41.000000000 -0800 @@ -0,0 +1,12 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-options "-O2 -mpreferred-stack-boundary=6 -mincoming-stack-boundary=6" } */ +/* { dg-final { scan-assembler-not "and\[lq\]?\[\\t \]*\\$-64,\[\\t \]*%\[re\]?sp" } } */ +/* { dg-final { scan-assembler-not "call\[\\t \]*foo" } } */ +/* { dg-final { scan-assembler "jmp\[\\t \]*foo" } } */ + +extern int foo (void); + +int bar (void) +{ + return foo(); +} --- gcc/testsuite/gcc.target/i386/pr37843-3.c.sibcall 2008-11-04 08:33:41.000000000 -0800 +++ gcc/testsuite/gcc.target/i386/pr37843-3.c 2008-11-04 08:33:41.000000000 -0800 @@ -0,0 +1,13 @@ +/* Test for stack alignment with sibcall optimization. */ +/* { dg-do compile { target { { i?86-*-linux* x86_64-*-linux* } && ilp32 } } } */ +/* { dg-options "-O2 -std=gnu99 -mpreferred-stack-boundary=4 -mincoming-stack-boundary=2" } */ +/* { 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); + +int bar (_Decimal128 x) +{ + return foo(x); +} ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2008-11-30 14:56 UTC | newest] Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2008-11-05 16:52 PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack in maindue to tail call optimizatiP Uros Bizjak 2008-11-05 18:18 ` H.J. Lu 2008-11-11 12:19 ` H.J. Lu 2008-11-19 18:27 ` H.J. Lu 2008-11-26 15:57 ` H.J. Lu 2008-11-26 19:08 ` Jack Howarth 2008-11-26 19:42 ` H.J. Lu 2008-11-26 20:07 ` Andrew Pinski 2008-11-26 20:35 ` Jack Howarth 2008-11-28 16:03 ` Kaveh R. GHAZI 2008-11-28 17:58 ` H.J. Lu 2008-11-29 17:59 ` H.J. Lu 2008-11-30 5:18 ` PING: PATCH: PR middle-end/37843:[4.4 Regression] unalignedstack " Kaveh R. Ghazi 2008-11-30 8:52 ` H.J. Lu 2008-11-30 15:47 ` Kaveh R. Ghazi -- strict thread matches above, loose matches on Subject: below -- 2008-11-01 0:25 PING: PATCH: PR middle-end/37843:[4.4 Regression] unaligned stack " H.J. Lu 2008-11-04 17:54 ` H.J. Lu
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).