re PR target/63354 (gcc -pg -mprofile-kernel creates unused stack frames on leaf...
authorAnton Blanchard <anton@samba.org>
Thu, 21 Jan 2016 17:32:28 +0000 (17:32 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Thu, 21 Jan 2016 17:32:28 +0000 (17:32 +0000)
[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.

Co-Authored-By: Bill Schmidt <wschmidt@linux.vnet.ibm.com>
From-SVN: r232684

gcc/ChangeLog
gcc/config/rs6000/linux64.h
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr63354.c [new file with mode: 0644]

index c72db017bae0ac62ec233e8508b22dd14156a752..ab7dc3a4efa5e62a7e3e5ae376a684a76fa3a673 100644 (file)
@@ -1,3 +1,12 @@
+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.
+
 2016-01-21  Ajit Agarwal  <ajitkum@xilinx.com>
 
        * config/microblaze/microblaze.c
index 20077e1aa712aec3f0f625b365dc14dada3899c6..fefa0c4eef305fc756e6ada67f6c2fd6dfdc569b 100644 (file)
@@ -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 b0ce68e5b3896437f6048de1c5b7f0f224875328..4c70f67b0a8353e24e1f9cdcf366d7f461e90625 100644 (file)
@@ -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 843ccac194dfe8c7f3a7578a42289df38d5dbc6d..35fb4fc7762d6b4448201f25a7a941b4adcda56e 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2016-01-21  Vladimir Makarov  <vmakarov@redhat.com>
 
        PR rtl-optimization/68990
diff --git a/gcc/testsuite/gcc.target/powerpc/pr63354.c b/gcc/testsuite/gcc.target/powerpc/pr63354.c
new file mode 100644 (file)
index 0000000..dd28583
--- /dev/null
@@ -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;
+}