Skip to content

Commit

Permalink
Add an assert to leaf_function_p to ensure it is not called from a
Browse files Browse the repository at this point in the history
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.

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


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248240 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
wilco committed May 18, 2017
1 parent 6f3e4f4 commit 6e0eb5c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2017-05-18 Wilco Dijkstra <wdijkstr@arm.com>

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

2017-05-18 Martin Liska <mliska@suse.cz>

* cfgrtl.c (rtl_verify_edges): Remove usage of TDF_RTL.
Expand Down
3 changes: 3 additions & 0 deletions gcc/final.c
Original file line number Diff line number Diff line change
Expand Up @@ -4309,6 +4309,9 @@ leaf_function_p (void)
{
rtx_insn *insn;

/* Ensure we walk the entire function body. */
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 ())
Expand Down

0 comments on commit 6e0eb5c

Please sign in to comment.