public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, rs6000] Fix PR63354
@ 2016-01-21 16:50 Bill Schmidt
  2016-01-21 17:28 ` David Edelsohn
  2016-02-06 20:35 ` Andreas Schwab
  0 siblings, 2 replies; 13+ messages in thread
From: Bill Schmidt @ 2016-01-21 16:50 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, anton

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.


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;
+}


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-02-18 21:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-21 16:50 [PATCH, rs6000] Fix PR63354 Bill Schmidt
2016-01-21 17:28 ` David Edelsohn
2016-01-22  3:21   ` Bill Schmidt
2016-01-22  5:42     ` Bill Schmidt
2016-01-22 14:42       ` David Edelsohn
2016-01-22 15:51       ` Joseph Myers
2016-01-22 15:56         ` Bill Schmidt
2016-01-24  1:18       ` Jan-Benedict Glaw
2016-01-25  2:18         ` Bill Schmidt
2016-01-25 13:55           ` David Edelsohn
2016-01-25 14:07             ` Bill Schmidt
2016-02-06 20:35 ` Andreas Schwab
2016-02-18 21:19   ` Bill Schmidt

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).