public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] pr 63354 - gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le
@ 2015-03-13 21:55 Martin Sebor
  2015-03-14 14:34 ` Segher Boessenkool
  0 siblings, 1 reply; 9+ messages in thread
From: Martin Sebor @ 2015-03-13 21:55 UTC (permalink / raw)
  To: Gcc Patch List; +Cc: anton

[-- Attachment #1: Type: text/plain, Size: 481 bytes --]

Attached is a patch that eliminates the unused stack frame
allocated by gcc 5 with -pg -mprofile-kernel on powepc64le
and brings the code into parity with previous gcc versions.

The patch doesn't do anything to change the emitted code
when -mprofile-kernel is used without -pg. Since the former
option isn't fully documented (as noted in pr 65372) it's
unclear what effect it should be expected to have without
-pg.

The patch was tested on {powerpc64,powerpc64le}-linux.

Martin

[-- Attachment #2: gcc-63354.patch --]
[-- Type: text/x-patch, Size: 1914 bytes --]

2015-03-13  Anton Blanchard  <anton@samba.org>

	PR target/63354
	* gcc/config/rs6000/linux64.h (ARGET_KEEP_LEAF_WHEN_PROFILED): Define.
	* cc/config/rs6000/rs6000.c (rs6000_keep_leaf_when_profiled). New
	function.

2015-03-13  Martin Sebor  <msebor@redhat.com>

	PR target/63354
	* gcc.target/powerpc/pr63354.c: New test.

diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 0879e7e..f51e892 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -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
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 3171eef..77731c56 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -24395,6 +24395,15 @@ 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 (void)
+{
+  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
diff --git a/gcc/testsuite/gcc.target/powerpc/pr63354.c b/gcc/testsuite/gcc.target/powerpc/pr63354.c
new file mode 100644
index 0000000..dd6ad08
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr63354.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { powerpc*-*-* } } } */
+/* { dg-options "-O2 -pg -mprofile-kernel" } */
+
+int foo (void)
+{
+  return 1;
+}
+
+/* { dg-final { scan-assembler "bl _mcount" } } */
+/* { dg-final { scan-assembler-not "\(addi|stdu\) 1," } } */

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

end of thread, other threads:[~2015-03-24 20:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-13 21:55 [PATCH] pr 63354 - gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le Martin Sebor
2015-03-14 14:34 ` Segher Boessenkool
2015-03-15 23:40   ` Martin Sebor
2015-03-17 22:34     ` Segher Boessenkool
2015-03-21 19:48     ` Iain Sandoe
2015-03-24  2:50       ` Martin Sebor
2015-03-24  8:26         ` Iain Sandoe
2015-03-24 20:18           ` Martin Sebor
2015-03-24 11:51         ` Segher Boessenkool

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