[Ada] New debug switch to disable large static aggregates
authorBob Duff <duff@adacore.com>
Tue, 16 Mar 2021 19:45:48 +0000 (15:45 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 18 Jun 2021 08:36:49 +0000 (04:36 -0400)
gcc/ada/

* debug.adb: Document switch.
* exp_aggr.adb: If -gnatd_g was given, then do not bump the
limit to 500_000.

gcc/ada/debug.adb
gcc/ada/exp_aggr.adb

index e2c7228..0694f23 100644 (file)
@@ -145,7 +145,7 @@ package body Debug is
    --  d_d
    --  d_e  Ignore entry calls and requeue statements for elaboration
    --  d_f  Issue info messages related to GNATprove usage
-   --  d_g
+   --  d_g  Disable large static aggregates
    --  d_h  Disable the use of (perfect) hash functions for enumeration Value
    --  d_i  Ignore activations and calls to instances for elaboration
    --  d_j  Read JSON files and populate Repinfo tables (opposite of -gnatRjs)
@@ -965,6 +965,10 @@ package body Debug is
    --       beginners find them confusing. Set automatically by GNATprove when
    --       switch --info is used.
 
+   --  d_g  Disable large static aggregates. The maximum size for a static
+   --       aggregate will be fairly modest, which is useful if the compiler
+   --       is using too much memory and time at compile time.
+
    --  d_h  The compiler does not make use of (perfect) hash functions in the
    --       implementation of the Value attribute for enumeration types.
 
index 8f3147e..2e772ed 100644 (file)
@@ -684,9 +684,11 @@ package body Exp_Aggr is
    begin
       --  We bump the maximum size unless the aggregate has a single component
       --  association, which will be more efficient if implemented with a loop.
+      --  The -gnatd_g switch disables this bumping.
 
-      if No (Expressions (N))
-        and then No (Next (First (Component_Associations (N))))
+      if (No (Expressions (N))
+            and then No (Next (First (Component_Associations (N)))))
+        or else Debug_Flag_Underscore_G
       then
          Max_Aggr_Size := Max_Aggregate_Size (N);
       else