From d4e4e88a4c1b13bc480603ad96672ce079e32ffb Mon Sep 17 00:00:00 2001 From: Bob Duff Date: Tue, 20 Aug 2019 09:50:24 +0000 Subject: [PATCH] [Ada] Improve efficiency of aggregates with <> The generated code has been improved so that aggregates with <> are more efficient. No change in behavior; no test. 2019-08-20 Bob Duff gcc/ada/ * exp_aggr.adb (Expand_Array_Aggregate): Use build-in-place in the nonlimited case in STEP 4. This improves the efficiency of things like (1 .. 1000 => <>). We still generate some code for that, unfortunately, but it is much improved. (Aggr_Assignment_OK_For_Backend): Return false if <> components are present. From-SVN: r274739 --- gcc/ada/ChangeLog | 9 +++++++++ gcc/ada/exp_aggr.adb | 10 +++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 56cb3085097..ddf17cc6135 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2019-08-20 Bob Duff + + * exp_aggr.adb (Expand_Array_Aggregate): Use build-in-place in + the nonlimited case in STEP 4. This improves the efficiency of + things like (1 .. 1000 => <>). We still generate some code for + that, unfortunately, but it is much improved. + (Aggr_Assignment_OK_For_Backend): Return false if <> components + are present. + 2019-08-20 Bob Duff * exp_ch6.adb (Needs_BIP_Alloc_Form): Call diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index c3eba3c3f93..7f11b4105bd 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -5233,6 +5233,12 @@ package body Exp_Aggr is Value : Uint; begin + -- Back end doesn't know about <> + + if Has_Default_Init_Comps (N) then + return False; + end if; + -- Recurse as far as possible to find the innermost component type Ctyp := Etype (N); @@ -6292,9 +6298,7 @@ package body Exp_Aggr is -- previously excluded controlled components but this is an old -- oversight: the rules in 7.6 (17) are clear. - if (not Has_Default_Init_Comps (N) - or else Is_Limited_Type (Etype (N))) - and then Comes_From_Source (Parent_Node) + if Comes_From_Source (Parent_Node) and then Parent_Kind = N_Object_Declaration and then Present (Expression (Parent_Node)) and then not -- 2.30.2