diff mbox

Add sequence check to leaf_function_p

Message ID AM5PR0802MB2610F06D3157957A336F7DF683E20@AM5PR0802MB2610.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Wilco Dijkstra May 12, 2017, 4:29 p.m. UTC
Alexander Monakov wrote:
> As I understand, we need to ensure that get_insns call retrieves the topmost
> sequence corresponding to the function body, not any current subsequence that
> could have been started via start_sequence.  Therefore the 'prolog or epilog'
> part is a bit misleading, we could be in a subsequence for other reasons, and
> we need to reject those as well.  So, ...

It's most likely that if this assert triggers, it is from a prolog or epilog sequence.

> ... can the comment please be reworded to match the code, if it's necessary to
> have a comment here at all?  E.g. "Ensure we walk the entire function body after
> the following get_insns call".

I've changed to to "Ensure we walk the entire function body."

Wilco

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

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

Comments

Jeff Law May 12, 2017, 5:47 p.m. UTC | #1
On 05/12/2017 10:29 AM, Wilco Dijkstra wrote:
> Alexander Monakov wrote:
>> As I understand, we need to ensure that get_insns call retrieves the topmost
>> sequence corresponding to the function body, not any current subsequence that
>> could have been started via start_sequence.  Therefore the 'prolog or epilog'
>> part is a bit misleading, we could be in a subsequence for other reasons, and
>> we need to reject those as well.  So, ...
> 
> It's most likely that if this assert triggers, it is from a prolog or epilog sequence.
> 
>> ... can the comment please be reworded to match the code, if it's necessary to
>> have a comment here at all?  E.g. "Ensure we walk the entire function body after
>> the following get_insns call".
> 
> I've changed to to "Ensure we walk the entire function body."
> 
> Wilco
> 
> 2017-05-11  Wilco Dijkstra  <wdijkstr@arm.com>
> 
> 	* final.c (leaf_function_p): Check we are not in a sequence.
OK.
jeff
diff mbox

Patch

diff --git a/gcc/final.c b/gcc/final.c
index 820162b2d28d734901375017cf0c7a3095e8903e..e61b78b0a915df748fcf3d73cd46db855cf7a1c6 100644
--- a/gcc/final.c
+++ b/gcc/final.c
@@ -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 ())