From c8d3e08887ee020e9b7b21d17481289ffd2275c9 Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Thu, 21 Jan 2016 17:32:28 +0000 Subject: [PATCH] re PR target/63354 (gcc -pg -mprofile-kernel creates unused stack frames on leaf functions on ppc64le) [gcc] 2016-01-21 Anton Blanchard Bill Schmidt 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 Bill Schmidt PR target/63354 * gcc.target/powerpc/pr63354.c: New test. Co-Authored-By: Bill Schmidt From-SVN: r232684 --- gcc/ChangeLog | 9 +++++++++ gcc/config/rs6000/linux64.h | 3 +++ gcc/config/rs6000/rs6000.c | 8 ++++++++ gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.target/powerpc/pr63354.c | 11 +++++++++++ 5 files changed, 37 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr63354.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c72db017bae..ab7dc3a4efa 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2016-01-21 Anton Blanchard + Bill Schmidt + + 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 * config/microblaze/microblaze.c diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h index 20077e1aa71..fefa0c4eef3 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 b0ce68e5b38..4c70f67b0a8 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 843ccac194d..35fb4fc7762 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-01-21 Anton Blanchard + Bill Schmidt + + PR target/63354 + * gcc.target/powerpc/pr63354.c: New test. + 2016-01-21 Vladimir Makarov 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 index 00000000000..dd2858336e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr63354.c @@ -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; +} -- 2.30.2