[Ada] Improve speed of discriminated return types
authorBob Duff <duff@adacore.com>
Tue, 20 Aug 2019 09:50:19 +0000 (09:50 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 20 Aug 2019 09:50:19 +0000 (09:50 +0000)
commitcf0e5ca723edbb63719ca075fce3f84eb8e43553
treecd0ad2fd4b60b699963083199c6eae5157111a3c
parent31fde973e5cb886dca17e61b84a72a26a81487ad
[Ada] Improve speed of discriminated return types

The compiler now generates faster code for functions that return
discriminated types in many cases where the size is known at compile
time.

2019-08-20  Bob Duff  <duff@adacore.com>

gcc/ada/

* exp_ch6.adb (Needs_BIP_Alloc_Form): Call
Requires_Transient_Scope rather than checking constrainedness
and so forth.  We have previously improved
Requires_Transient_Scope to return False in various cases,
notably a limited record with an access discriminant. This
change takes advantage of that to avoid using the secondary
stack for functions returning such types.
(Make_Build_In_Place_Call_In_Allocator): Be consistent by
calling Needs_BIP_Alloc_Form rather than Is_Constrained and so
forth.
* sem_ch4.adb (Analyze_Allocator): The above change causes the
compiler to generate code that is not legal Ada, in particular
an uninitialized allocator for indefinite subtype.  This is
harmless, so we suppress the error message in this case.

From-SVN: r274738
gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/sem_ch4.adb