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

--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
https://gcc.gnu.org/g:b861785242450c8711aae6394751a75eadc4a0a9

commit r15-5129-gb861785242450c8711aae6394751a75eadc4a0a9
Author: Eric Botcazou <ebotca...@adacore.com>
Date:   Mon Oct 21 10:55:28 2024 +0200

    ada: Elide the copy in aggregate returns for nonlimited types

    This implements elision of the copy operation for aggregate returns, i.e.
    simple return statements whose expression is an aggregate, in the case of
    nonlimited by-reference types (the copy operation is already elided for
    limited types), which comprise controlled and tagged types.  This is the
    copy operation in the called function, that is to say the copy from the
    anonymous object built for the aggregate to the anonymous return object.

    The implementation simply extends that of limited types, which rewrites
    the simple return statement as an extended return statement internally
    and then leverages the built-in-place implementation of return objects
    for these statements.

    gcc/ada/ChangeLog:

            * exp_aggr.adb (Is_Build_In_Place_Aggregate_Return): Also return
            True for functions returning on the secondary stack or returning
            a by-reference type if the back end exposes its return slot.
            (Expand_Array_Aggregate): Call Is_Build_In_Place_Aggregate_Return
            to spot aggregates to be built in place.
            * exp_ch3.adb (Make_Allocator_For_Return): Add missing condition
            in assertion pragma deduced from Expand_Subtype_From_Expr.
            * exp_ch6.adb (Expand_Simple_Function_Return): Rewrite the
statement
            as an extended return statement if the expression is an aggregate
            whose expansion is delayed.  Properly relocate the expression in
            this case.
            * sem_ch6.adb: Add clauses for Exp_Aggr.
            (Analyze_Function_Return): Do not apply the predicate check to an
            aggregate whose expansion is delayed.  Extended the processing of
            case expressions to all conditional expressions.
  • [Bug ada/62042] missed copy elis... ebotcazou at gcc dot gnu.org via Gcc-bugs

Reply via email to