+2014-05-05 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
+
+ * target.def: Add new target hook.
+ * doc/tm.texi: Regenerate.
+ * targhooks.h (default_keep_leaf_when_profiled): Add prototype.
+ * targhooks.c (default_keep_leaf_when_profiled): New function.
+
+ * config/s390/s390.c (s390_keep_leaf_when_profiled): New function.
+ (TARGET_KEEP_LEAF_WHEN_PROFILED): Define.
+
2014-05-05 Bin Cheng <bin.cheng@arm.com>
PR tree-optimization/60363
return const0_rtx;
}
+/* We call mcount before the function prologue. So a profiled leaf
+ function should stay a leaf function. */
+
+static bool
+s390_keep_leaf_when_profiled ()
+{
+ return true;
+}
/* Output assembly code for the trampoline template to
stdio stream FILE.
#undef TARGET_LIBCALL_VALUE
#define TARGET_LIBCALL_VALUE s390_libcall_value
+#undef TARGET_KEEP_LEAF_WHEN_PROFILED
+#define TARGET_KEEP_LEAF_WHEN_PROFILED s390_keep_leaf_when_profiled
+
#undef TARGET_FIXED_CONDITION_CODE_REGS
#define TARGET_FIXED_CONDITION_CODE_REGS s390_fixed_condition_code_regs
the function prologue. Normally, the profiling code comes after.
@end defmac
+@deftypefn {Target Hook} bool TARGET_KEEP_LEAF_WHEN_PROFILED (void)
+This target hook returns true if the target wants the leaf flag for the current function to stay true even if it calls mcount. This might make sense for targets using the leaf flag only to determine whether a stack frame needs to be generated or not and for which the call to mcount is generated before the function prologue.
+@end deftypefn
+
@node Tail Calls
@subsection Permitting tail calls
@cindex tail calls
the function prologue. Normally, the profiling code comes after.
@end defmac
+@hook TARGET_KEEP_LEAF_WHEN_PROFILED
+
@node Tail Calls
@subsection Permitting tail calls
@cindex tail calls
{
rtx insn;
- if (crtl->profile || profile_arc_flag)
+ /* Some back-ends (e.g. s390) want leaf functions to stay leaf
+ functions even if they call mcount. */
+ if (crtl->profile && !targetm.keep_leaf_when_profiled ())
return 0;
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
bool, (void),
default_profile_before_prologue)
+/* Return true if a leaf function should stay leaf even with profiling
+ enabled. */
+DEFHOOK
+(keep_leaf_when_profiled,
+ "This target hook returns true if the target wants the leaf flag for\
+ the current function to stay true even if it calls mcount. This might\
+ make sense for targets using the leaf flag only to determine whether a\
+ stack frame needs to be generated or not and for which the call to\
+ mcount is generated before the function prologue.",
+ bool, (void),
+ default_keep_leaf_when_profiled)
+
/* Modify and return the identifier of a DECL's external name,
originally identified by ID, as required by the target,
(eg, append @nn to windows32 stdcall function names).
return reg_raw_mode[regno];
}
+/* Return true if a leaf function should stay leaf even with profiling
+ enabled. */
+
+bool
+default_keep_leaf_when_profiled ()
+{
+ return false;
+}
+
/* Return true if the state of option OPTION should be stored in PCH files
and checked by default_pch_valid_p. Store the option's current state
in STATE if so. */
extern section * default_function_section(tree decl, enum node_frequency freq,
bool startup, bool exit);
extern enum machine_mode default_get_reg_raw_mode (int);
+extern bool default_keep_leaf_when_profiled ();
extern void *default_get_pch_validity (size_t *);
extern const char *default_pch_valid_p (const void *, size_t);
+2014-05-05 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
+
+ * gcc.target/s390/leaf-profile.c: New testcase.
+
2014-05-05 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
* gcc.dg/hoist-register-pressure-1.c: Replace int with long.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z900 -pg" } */
+
+int
+foo ()
+{
+}
+/* Make sure no stack frame is generated. */
+/* { dg-final { scan-assembler-not "ahi" { target s390-*-* } } } */
+/* { dg-final { scan-assembler-not "aghi" { target s390x-*-* } } } */