public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Code cleanup of alignment representation clauses in dispatch tables
@ 2019-09-18  8:47 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2019-09-18  8:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: Javier Miranda

[-- Attachment #1: Type: text/plain, Size: 430 bytes --]

This patch does not modify the functionality of the compiler; it avoids
generating non-required alignment representation clauses for dispatch
tables.

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

2019-09-18  Javier Miranda  <miranda@adacore.com>

gcc/ada/

	* exp_disp.adb (Make_DT, Make_Secondary_DT): Remove generation
	of alignment representation clause for the following tables:
	Predef_Prims, Iface_DT, TSD, ITable, DT.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 9158 bytes --]

--- gcc/ada/exp_disp.adb
+++ gcc/ada/exp_disp.adb
@@ -4041,7 +4041,6 @@ package body Exp_Disp is
          --                     predef-prim-op-thunk-2'address,
          --                     ...
          --                     predef-prim-op-thunk-n'address);
-         --   for Predef_Prims'Alignment use Address'Alignment
 
          --  Create the thunks associated with the predefined primitives and
          --  save their entity to fill the aggregate.
@@ -4125,16 +4124,6 @@ package body Exp_Disp is
                 Object_Definition   => New_Occurrence_Of
                                          (Defining_Identifier (Decl), Loc),
                 Expression => New_Node));
-
-            Append_To (Result,
-              Make_Attribute_Definition_Clause (Loc,
-                Name       => New_Occurrence_Of (Predef_Prims, Loc),
-                Chars      => Name_Alignment,
-                Expression =>
-                  Make_Attribute_Reference (Loc,
-                    Prefix =>
-                      New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                    Attribute_Name => Name_Alignment)));
          end;
 
          --  Generate
@@ -4143,6 +4132,7 @@ package body Exp_Disp is
          --          (OSD_Table => (1 => <value>,
          --                           ...
          --                         N => <value>));
+         --   for OSD'Alignment use Address'Alignment;
 
          --   Iface_DT : Dispatch_Table (Nb_Prims) :=
          --               ([ Signature   => <sig-value> ],
@@ -4154,7 +4144,6 @@ package body Exp_Disp is
          --                                  prim-op-2'address,
          --                                  ...
          --                                  prim-op-n'address));
-         --   for Iface_DT'Alignment use Address'Alignment;
 
          --  Stage 3: Initialize the discriminant and the record components
 
@@ -4454,17 +4443,6 @@ package body Exp_Disp is
                Make_Aggregate (Loc,
                  Expressions => DT_Aggr_List)));
 
-         Append_To (Result,
-           Make_Attribute_Definition_Clause (Loc,
-             Name       => New_Occurrence_Of (Iface_DT, Loc),
-             Chars      => Name_Alignment,
-
-             Expression =>
-               Make_Attribute_Reference (Loc,
-                 Prefix         =>
-                   New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                 Attribute_Name => Name_Alignment)));
-
          if Exporting_Table then
             Export_DT (Typ, Iface_DT, Suffix_Index);
 
@@ -4946,7 +4924,6 @@ package body Exp_Disp is
 
          --  Generate:
          --    DT     : No_Dispatch_Table_Wrapper;
-         --    for DT'Alignment use Address'Alignment;
          --    DT_Ptr : Tag := !Tag (DT.NDT_Prims_Ptr'Address);
 
          if not Has_DT (Typ) then
@@ -4960,16 +4937,6 @@ package body Exp_Disp is
                     (RTE (RE_No_Dispatch_Table_Wrapper), Loc)));
 
             Append_To (Result,
-              Make_Attribute_Definition_Clause (Loc,
-                Name       => New_Occurrence_Of (DT, Loc),
-                Chars      => Name_Alignment,
-                Expression =>
-                  Make_Attribute_Reference (Loc,
-                    Prefix         =>
-                      New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                    Attribute_Name => Name_Alignment)));
-
-            Append_To (Result,
               Make_Object_Declaration (Loc,
                 Defining_Identifier => DT_Ptr,
                 Object_Definition   => New_Occurrence_Of (RTE (RE_Tag), Loc),
@@ -5008,7 +4975,6 @@ package body Exp_Disp is
 
          --  Generate:
          --    DT : Dispatch_Table_Wrapper (Nb_Prim);
-         --    for DT'Alignment use Address'Alignment;
          --    DT_Ptr : Tag := !Tag (DT.Prims_Ptr'Address);
 
          else
@@ -5037,16 +5003,6 @@ package body Exp_Disp is
                         Constraints => DT_Constr_List))));
 
             Append_To (Result,
-              Make_Attribute_Definition_Clause (Loc,
-                Name       => New_Occurrence_Of (DT, Loc),
-                Chars      => Name_Alignment,
-                Expression =>
-                  Make_Attribute_Reference (Loc,
-                    Prefix         =>
-                      New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                    Attribute_Name => Name_Alignment)));
-
-            Append_To (Result,
               Make_Object_Declaration (Loc,
                 Defining_Identifier => DT_Ptr,
                 Object_Definition   => New_Occurrence_Of (RTE (RE_Tag), Loc),
@@ -5161,7 +5117,6 @@ package body Exp_Disp is
       --            Tags_Table         => (0 => null,
       --                                   1 => Parent'Tag
       --                                   ...);
-      --   for TSD'Alignment use Address'Alignment
 
       TSD_Aggr_List := New_List;
 
@@ -5699,16 +5654,6 @@ package body Exp_Disp is
                          Make_Integer_Literal (Loc, Num_Ifaces),
                          Make_Aggregate (Loc, TSD_Ifaces_List)))));
 
-               Append_To (Result,
-                 Make_Attribute_Definition_Clause (Loc,
-                   Name       => New_Occurrence_Of (ITable, Loc),
-                   Chars      => Name_Alignment,
-                   Expression =>
-                     Make_Attribute_Reference (Loc,
-                       Prefix         =>
-                         New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                       Attribute_Name => Name_Alignment)));
-
                Iface_Table_Node :=
                  Make_Attribute_Reference (Loc,
                    Prefix         => New_Occurrence_Of (ITable, Loc),
@@ -5859,16 +5804,6 @@ package body Exp_Disp is
 
       Set_Is_True_Constant (TSD, Building_Static_DT (Typ));
 
-      Append_To (Result,
-        Make_Attribute_Definition_Clause (Loc,
-          Name       => New_Occurrence_Of (TSD, Loc),
-          Chars      => Name_Alignment,
-          Expression =>
-            Make_Attribute_Reference (Loc,
-              Prefix         =>
-                New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-              Attribute_Name => Name_Alignment)));
-
       --  Initialize or declare the dispatch table object
 
       if not Has_DT (Typ) then
@@ -5906,7 +5841,6 @@ package body Exp_Disp is
          --   DT : aliased constant No_Dispatch_Table :=
          --          (NDT_TSD       => TSD'Address;
          --           NDT_Prims_Ptr => 0);
-         --   for DT'Alignment use Address'Alignment;
 
          else
             Append_To (Result,
@@ -5918,16 +5852,6 @@ package body Exp_Disp is
                   New_Occurrence_Of (RTE (RE_No_Dispatch_Table_Wrapper), Loc),
                 Expression          => Make_Aggregate (Loc, DT_Aggr_List)));
 
-            Append_To (Result,
-              Make_Attribute_Definition_Clause (Loc,
-                Name       => New_Occurrence_Of (DT, Loc),
-                Chars      => Name_Alignment,
-                Expression =>
-                  Make_Attribute_Reference (Loc,
-                    Prefix         =>
-                      New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                    Attribute_Name => Name_Alignment)));
-
             Export_DT (Typ, DT);
          end if;
 
@@ -5940,7 +5864,6 @@ package body Exp_Disp is
       --                     predef-prim-op-2'address,
       --                     ...
       --                     predef-prim-op-n'address);
-      --   for Predef_Prims'Alignment use Address'Alignment
 
       --   DT : Dispatch_Table (Nb_Prims) :=
       --          (Signature => <sig-value>,
@@ -6025,16 +5948,6 @@ package body Exp_Disp is
             --  Remember aggregates initializing dispatch tables
 
             Append_Elmt (New_Node, DT_Aggr);
-
-            Append_To (Result,
-              Make_Attribute_Definition_Clause (Loc,
-                Name       => New_Occurrence_Of (Predef_Prims, Loc),
-                Chars      => Name_Alignment,
-                Expression =>
-                  Make_Attribute_Reference (Loc,
-                    Prefix         =>
-                      New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                    Attribute_Name => Name_Alignment)));
          end;
 
          --  Stage 1: Initialize the discriminant and the record components
@@ -6221,16 +6134,6 @@ package body Exp_Disp is
                                       Constraints => DT_Constr_List)),
                 Expression          => Make_Aggregate (Loc, DT_Aggr_List)));
 
-            Append_To (Result,
-              Make_Attribute_Definition_Clause (Loc,
-                Name       => New_Occurrence_Of (DT, Loc),
-                Chars      => Name_Alignment,
-                Expression =>
-                  Make_Attribute_Reference (Loc,
-                    Prefix         =>
-                      New_Occurrence_Of (RTE (RE_Integer_Address), Loc),
-                    Attribute_Name => Name_Alignment)));
-
             Export_DT (Typ, DT);
          end if;
       end if;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-18  8:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-18  8:47 [Ada] Code cleanup of alignment representation clauses in dispatch tables Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).