On 10/10/13 18:41, Jeff Law wrote: > On 10/10/13 04:00, Andreas Krebbel wrote: >> On 09/10/13 21:46, Jeff Law wrote: >>> On 08/21/13 03:21, Andreas Krebbel wrote: >>>> [RFC] Allow functions calling mcount before prologue to be leaf functions >>>> http://gcc.gnu.org/ml/gcc-patches/2013-04/msg00993.html >>> I don't think this is necessarily correct for all targets. ISTM the >>> ability to consider a function calling mcount as a leaf needs to be a >>> property of the target. >> >> We have already "profile_before_prologue" as a target property. Shouldn't >> this be enough to decide >> upon this? When a function calls mcount before the prologue it shouldn't >> matter whether the function >> is leaf or not. > I don't think so, I think it'd break the PA's 32 bit ABI, maybe the 64 > bit ABI as well. It's the caller's responsibility to build a mini stack > frame if the function makes any calls. If the code in the prologue > expander uses "leafness" to make the decision about whether or not to > allocate the mini frame, then it'd do the wrong thing here.
Since it seems to be about PROFILE_HOOKS vs FUNCTION_PROFILER targets what about the following patch: Index: gcc/final.c =================================================================== *** gcc/final.c.orig 2013-10-11 18:51:53.928452672 +0200 --- gcc/final.c 2013-10-11 18:56:20.761359142 +0200 *************** leaf_function_p (void) *** 4237,4244 **** { rtx insn; ! if (crtl->profile || profile_arc_flag) return 0; for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) { --- 4237,4253 ---- { rtx insn; ! #ifdef PROFILE_HOOK ! /* PROFILE_HOOK emits code always after prologue. */ ! if (crtl->profile) return 0; + #else + /* This is for targets using the FUNCTION_PROFILER hook. If the + code is emitted before prologue the function might still be a + leaf function. */ + if (!targetm.profile_before_prologue () && crtl->profile) + return 0; + #endif for (insn = get_insns (); insn; insn = NEXT_INSN (insn)) { I've verified with a cross that on hppa target nothing changes when using -pg. Bye, -Andreas-