Message ID | 1453394918.22933.3.camel@gnopaine |
---|---|
State | New |
Headers | show |
On Thu, Jan 21, 2016 at 11:48 AM, Bill Schmidt <wschmidt@linux.vnet.ibm.com> wrote: > Hi, > > Anton Blanchard proposed a fix to his own bug report in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63354, but never submitted > the patch upstream. I've added a formal test case and am submitting on > his behalf. > > The patch simply ensures that we don't stack a frame for leaf procedures > when called with -pg -mprofile-kernel. The automatically generated > calls to _mcount occur prior to the prolog and do not require us to > stack a frame. > > Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no > regressions. Is this ok for trunk? > > Thanks, > Bill > > > [gcc] > > 2016-01-21 Anton Blanchard <anton@samba.org> > Bill Schmidt <wschmidt@linux.vnet.ibm.com> > > PR target/63354 > * config/rs6000/linux64.h (TARGET_KEEP_LEAF_WHEN_PROFILED): New > #define. > * config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled): New > function. > > [gcc/testsuite] > > 2016-01-21 Anton Blanchard <anton@samba.org> > Bill Schmidt <wschmidt@linux.vnet.ibm.com> > > PR target/63354 > * gcc.target/powerpc/pr63354.c: New test. Okay. Thanks, David
The testcase will need a slight adjustment, as currently it fails on powerpc64 with -m32 testing. Working on a fix. Bill On Thu, 2016-01-21 at 12:28 -0500, David Edelsohn wrote: > On Thu, Jan 21, 2016 at 11:48 AM, Bill Schmidt > <wschmidt@linux.vnet.ibm.com> wrote: > > Hi, > > > > Anton Blanchard proposed a fix to his own bug report in > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63354, but never submitted > > the patch upstream. I've added a formal test case and am submitting on > > his behalf. > > > > The patch simply ensures that we don't stack a frame for leaf procedures > > when called with -pg -mprofile-kernel. The automatically generated > > calls to _mcount occur prior to the prolog and do not require us to > > stack a frame. > > > > Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no > > regressions. Is this ok for trunk? > > > > Thanks, > > Bill > > > > > > [gcc] > > > > 2016-01-21 Anton Blanchard <anton@samba.org> > > Bill Schmidt <wschmidt@linux.vnet.ibm.com> > > > > PR target/63354 > > * config/rs6000/linux64.h (TARGET_KEEP_LEAF_WHEN_PROFILED): New > > #define. > > * config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled): New > > function. > > > > [gcc/testsuite] > > > > 2016-01-21 Anton Blanchard <anton@samba.org> > > Bill Schmidt <wschmidt@linux.vnet.ibm.com> > > > > PR target/63354 > > * gcc.target/powerpc/pr63354.c: New test. > > Okay. > > Thanks, David >
Bill Schmidt <wschmidt@linux.vnet.ibm.com> writes: > Index: gcc/testsuite/gcc.target/powerpc/pr63354.c > =================================================================== > --- gcc/testsuite/gcc.target/powerpc/pr63354.c (revision 0) > +++ gcc/testsuite/gcc.target/powerpc/pr63354.c (working copy) > @@ -0,0 +1,11 @@ > +/* Verify that we don't stack a frame for leaf functions when using > + -pg -mprofile-kernel. */ > + > +/* { dg-do compile { target { powerpc64*-*-* } } } */ > +/* { dg-options "-O2 -pg -mprofile-kernel" } */ > +/* { dg-final { scan-assembler-not "mtlr" } } */ > + > +int foo(void) > +{ > + return 1; > +} With -m32: FAIL: gcc.target/powerpc/pr63354.c (test for excess errors) Excess errors: /daten/gcc/gcc-20160205/gcc/testsuite/gcc.target/powerpc/pr63354.c:1:0: error: -mprofile-kernel not supported in this configuration Andreas.
Hi Andreas, Sorry I haven't responded sooner; I was on vacation and have been unpiling things since then. The test case had already been updated since the patch you cited, adding /* { dg-require-effective-target powerpc64 } */ Is this the version you're testing with? Thanks, Bill On Sat, 2016-02-06 at 21:35 +0100, Andreas Schwab wrote: > Bill Schmidt <wschmidt@linux.vnet.ibm.com> writes: > > > Index: gcc/testsuite/gcc.target/powerpc/pr63354.c > > =================================================================== > > --- gcc/testsuite/gcc.target/powerpc/pr63354.c (revision 0) > > +++ gcc/testsuite/gcc.target/powerpc/pr63354.c (working copy) > > @@ -0,0 +1,11 @@ > > +/* Verify that we don't stack a frame for leaf functions when using > > + -pg -mprofile-kernel. */ > > + > > +/* { dg-do compile { target { powerpc64*-*-* } } } */ > > +/* { dg-options "-O2 -pg -mprofile-kernel" } */ > > +/* { dg-final { scan-assembler-not "mtlr" } } */ > > + > > +int foo(void) > > +{ > > + return 1; > > +} > > With -m32: > > FAIL: gcc.target/powerpc/pr63354.c (test for excess errors) > Excess errors: > /daten/gcc/gcc-20160205/gcc/testsuite/gcc.target/powerpc/pr63354.c:1:0: error: -mprofile-kernel not supported in this configuration > > Andreas. >
Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 232677) +++ gcc/config/rs6000/linux64.h (working copy) @@ -59,6 +59,9 @@ extern int dot_symbols; #define TARGET_PROFILE_KERNEL profile_kernel +#undef TARGET_KEEP_LEAF_WHEN_PROFILED +#define TARGET_KEEP_LEAF_WHEN_PROFILED rs6000_keep_leaf_when_profiled + #define TARGET_USES_LINUX64_OPT 1 #ifdef HAVE_LD_LARGE_TOC #undef TARGET_CMODEL Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 232677) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -26237,6 +26237,14 @@ rs6000_output_function_prologue (FILE *file, rs6000_pic_labelno++; } +/* -mprofile-kernel code calls mcount before the function prolog, + so a profiled leaf function should stay a leaf function. */ +static bool +rs6000_keep_leaf_when_profiled () +{ + return TARGET_PROFILE_KERNEL; +} + /* Non-zero if vmx regs are restored before the frame pop, zero if we restore after the pop when possible. */ #define ALWAYS_RESTORE_ALTIVEC_BEFORE_POP 0 Index: gcc/testsuite/gcc.target/powerpc/pr63354.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr63354.c (revision 0) +++ gcc/testsuite/gcc.target/powerpc/pr63354.c (working copy) @@ -0,0 +1,11 @@ +/* Verify that we don't stack a frame for leaf functions when using + -pg -mprofile-kernel. */ + +/* { dg-do compile { target { powerpc64*-*-* } } } */ +/* { dg-options "-O2 -pg -mprofile-kernel" } */ +/* { dg-final { scan-assembler-not "mtlr" } } */ + +int foo(void) +{ + return 1; +}