[Ada] Further optimization with uninitialized aggregates

Pierre-Marie de Rodat derodat@adacore.com
Wed Nov 25 13:27:24 GMT 2020

An object declaration for an unconstrained array includes an expression
(most often an aggregate) that provides the bounds for the object. If
the aggregate uses box initialization to provide those bounds, it is not
necessary to construct the aggregate to complete the object declaration:
the generated subtype of the aggregate is sufficient to create the object,
and there is no need to construct the aggregate. This optimization
prevents the construction of an empty aggregate and the useless
initialization code for the object.

Tested on x86_64-pc-linux-gnu, committed on trunk


	* freeze.adb (Is_Uninitialized_Aggregate): Move...
	* exp_util.adb (Is_Uninitialized_Aggregate): ... here.
	(Expand_Subtype_From_Expr): If the expression is an
	uninitialized aggregate, capture subtype for declared object and
	remove expression to suppress further superfluous expansion.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: text/x-diff
Size: 5383 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20201125/10fbf7af/attachment.bin>

More information about the Gcc-patches mailing list