]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Temporary tweak new expansion of contracts
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 5 Sep 2022 15:51:34 +0000 (17:51 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 12 Sep 2022 08:16:52 +0000 (10:16 +0200)
commitca4b9801e2b83cf22ba87ba2b30e450cbb0b6150
tree6decf5098283a05f09706e02a3519b1f32b9d58d
parent9ccd61dfee0f21cf049653cfdaf2c28750ebe3cd
[Ada] Temporary tweak new expansion of contracts

In the case of a function, the new expansion of contracts makes use of an
extended return statement to store the result of the function in the return
object while the post-conditions are evaluated.

Unfortunately GNAT does not elide the copy of the return object for extended
return statements for the time being, so this scheme incurs an extra copy of
the return value on the primary or secondary stack, as well as an additional
pair of calls to Adjust/Finalize when the return type needs finalization.

This temporarily changes the expansion to use a block statement containing a
renaming, which does not incur the extra copy provided that it is manually
adjusted to be recognized by the existing "tail call" optimization present
in the Expand_Simple_Function_Return routine.

gcc/ada/

* contracts.adb (uild_Subprogram_Contract_Wrapper): Remove useless
local variable. In the case of a function, replace the extended
return statement by a block statement declaring a renaming of the
call to the local subprogram after removing side effects manually.
(Expand_Subprogram_Contract): Adjust description accordingly.
* exp_ch6.adb (Expand_Ctrl_Function_Call): Rewrite obsolete
comment and do not apply the transformation twice.
* sem_attr.adb (Analyze_Attribute_Old_Result): Now expect a block
statement instead of an extended return statement.
gcc/ada/contracts.adb
gcc/ada/exp_ch6.adb
gcc/ada/sem_attr.adb