On Thu, 1 Dec 2011, Diego Novillo wrote:

> On Thu, Dec 1, 2011 at 07:08, Richard Guenther <rguent...@suse.de> wrote:
> > Sure, but then you can still have the issue of an inconsistency.
> 
> Not if we make the edge attribute secondary to the statement
> attribute.  Given that can_inline_edge_p() is the *only* tester for
> this attribute, what I was thinking was to change can_inline_edge_p()
> to:
> 
> diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
> index 3dadf8d..e3c6b3c 100644
> --- a/gcc/ipa-inline.c
> +++ b/gcc/ipa-inline.c
> @@ -246,6 +246,14 @@ can_inline_edge_p (struct cgraph_edge *e, bool report)
>    struct function *caller_cfun = DECL_STRUCT_FUNCTION (e->caller->decl);
>    struct function *callee_cfun
>      = callee ? DECL_STRUCT_FUNCTION (callee->decl) : NULL;
> +  bool call_stmt_cannot_inline_p;
> +
> +  /* If E has a call statement in it, use the inline attribute from
> +     the statement, otherwise use the inline attribute in E.  Edges
> +     will not have statements when working in WPA mode.  */
> +  call_stmt_cannot_inline_p = (e->call_stmt)
> +                             ? gimple_call_cannot_inline_p (e->call_stmt)
> +                             : e->call_stmt_cannot_inline_p;
> 
>    if (!caller_cfun && e->caller->clone_of)
>      caller_cfun = DECL_STRUCT_FUNCTION (e->caller->clone_of->decl);
> @@ -270,7 +278,7 @@ can_inline_edge_p (struct cgraph_edge *e, bool report)
>        e->inline_failed = CIF_OVERWRITABLE;
>        return false;
>      }
> -  else if (e->call_stmt_cannot_inline_p)
> +  else if (call_stmt_cannot_inline_p)
>      {
>        e->inline_failed = CIF_MISMATCHED_ARGUMENTS;
>        inlinable = false;
> @@ -343,14 +351,6 @@ can_inline_edge_p (struct cgraph_edge *e, bool report)
>         }
>      }
> 
> -  /* Be sure that the cannot_inline_p flag is up to date.  */
> -  gcc_checking_assert (!e->call_stmt
> -                      || (gimple_call_cannot_inline_p (e->call_stmt)
> -                          == e->call_stmt_cannot_inline_p)
> -                      /* In -flto-partition=none mode we really keep
> things out of
> -                         sync because call_stmt_cannot_inline_p is
> set at cgraph
> -                         merging when function bodies are not there yet.  */
> -                      || (in_lto_p && !gimple_call_cannot_inline_p
> (e->call_stmt)));
>    if (!inlinable && report)
>      report_inline_failed_reason (e);
>    return inlinable;
> 
> 
> 
> > Thus, would you then remove the remaining asserts?
> 
> The asserts disappear because we have weakened the meaning of the edge
> attribute.  It is only usable when there is no statement on it.  The
> question now is, how do we know that the attribute is not lying?  This
> only happens in WPA mode, so it would then become an issue of
> pessimization, not correctness.

The above looks ok to me, but I don't want the
gimple_call_set_cannot_inline change (if it is in the tree - I have
not yet recovered from three weeks of vacation).  The edge attribute
is "recomputed" when necessary.

> > I believe in the end the proper fix is to _not_ throw away
> > cgraph edges all the time, but keep them up-to-date and thus
> > make the stmt flag not necessary.
> 
> Make it a pure cgraph attribute?  Sure, anything that gets rid of the
> dual attribute is the way to go.  There are not very many invocations
> to the gimple attribute, but I don't know how big a change that is.

The issue with that change would be to preserve the cgraph edges.
Though when we create them we always have the call stmt available
and thus could re-compute that flag.  Honza?

> > Which pass did the folding of the stmt but did not adjust the
> > edge flag?
> 
> The new call to gimple_call_set_cannot_inline added by this patch:

Sure, but what _pass_ changed the call stmt and called fold_stmt
on it?  The patch merely changes the flag during folding.

Richard.

Reply via email to