This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add sequence check to leaf_function_p


This is a followup from: https://gcc.gnu.org/ml/gcc-patches/2016-11/msg02916.html

Add an assert to leaf_function_p to ensure it is not called from a
prolog or epilog sequence (which would incorrectly return true in a
non-leaf function).  There are several targets which still call
leaf_function_p, and while most appear safe or appear aware of the
issue, it is likely not all such calls are safe.  This check enables
any such latent bugs to be found.

Bootstrap OK on AArch64.

2017-05-11  Wilco Dijkstra  <wdijkstr@arm.com>

	* final.c (leaf_function_p): Check we are not in a sequence.
--

diff --git a/gcc/final.c b/gcc/final.c
index 820162b2d28d734901375017cf0c7a3095e8903e..c9aa610d2696738342f61b9c944a7a2f18e7497c 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -4309,6 +4309,9 @@ leaf_function_p (void)
 {
   rtx_insn *insn;
 
+  /* Check we are not in a prologue or epilogue sequence.  */
+  gcc_assert (!in_sequence_p ());
+
   /* 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 ())


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]