https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115097

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #5)
[...]
>   /* If aggregate_value_p is true, then we can return the bare RESULT_DECL.
>      Recall that aggregate_value_p is FALSE for any aggregate type that is
>      returned in registers.  If we're returning values in registers, then
>      we don't want to extend the lifetime of the RESULT_DECL, particularly
>      across another call.  In addition, for those aggregates for which
>      hard_function_value generates a PARALLEL, we'll die during normal
>      expansion of structure assignments; there's special code in
> expand_return
>      to handle this case that does not exist in expand_expr.  */
> 
> but the code does something else, using a new temporary register
> (here !aggregate_value_p).  The following fixes that.
> 
> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
> index b0ed58ed0f9..e4cf5438e39 100644
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -1873,7 +1873,8 @@ gimplify_return_expr (tree stmt, gimple_seq *pre_p)
>       to handle this case that does not exist in expand_expr.  */
>    if (!result_decl)
>      result = NULL_TREE;
> -  else if (aggregate_value_p (result_decl, TREE_TYPE
> (current_function_decl)))
> +  else if (aggregate_value_p (result_decl, TREE_TYPE
> (current_function_decl))
> +          || !is_gimple_reg_type (TREE_TYPE (result_decl)))
>      {
>        if (!poly_int_tree_p (DECL_SIZE (result_decl)))
>         {

That said, this likely breaks exactly what the comment says but this should
be then worked around during RTL expansion and not gimplification (but
of course historically that was the same time).

Reply via email to