From: Piotr Trojanek <troja...@adacore.com> When GNAT was operating in ASIS mode, it was writing internal tables to files, so we annotated record types for elements stored in these tables with representation clauses to avoid holes with potentially uninitialized data.
Since ASIS mode has been now deconstructed and we no longer write internal tables to files, we can remove explicit representation clauses and rely on the data layout chosen by the compiler. Code cleanup; behavior is unaffected. gcc/ada/ChangeLog: * lib.ads (Unit_Record): Remove representation clauses and filler components * lib-load.adb, lib-writ.adb: Remove initialization of data fillers. * nlists.adb (Allocate_List_Tables): Remove explicit initialization. * repinfo.adb (Exp_Node): Remove representation clauses. * sinput.ads (Source_File_Record): Likewise. * urealp.adb (Ureal_Entry): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/lib-load.adb | 6 ------ gcc/ada/lib-writ.adb | 4 ---- gcc/ada/lib.ads | 41 ------------------------------------ gcc/ada/nlists.adb | 11 +--------- gcc/ada/repinfo.adb | 14 ------------- gcc/ada/sinput.ads | 50 ++------------------------------------------ gcc/ada/urealp.adb | 14 ------------- 7 files changed, 3 insertions(+), 137 deletions(-) diff --git a/gcc/ada/lib-load.adb b/gcc/ada/lib-load.adb index 46de9111147..bdeea1c8a75 100644 --- a/gcc/ada/lib-load.adb +++ b/gcc/ada/lib-load.adb @@ -226,13 +226,11 @@ package body Lib.Load is Fatal_Error => Error_Detected, Generate_Code => False, Has_RACW => False, - Filler => False, Ident_String => Empty, Is_Predefined_Renaming => Ren_Name, Is_Predefined_Unit => Pre_Name or Ren_Name, Is_Internal_Unit => Pre_Name or Ren_Name or GNAT_Name, - Filler2 => False, Loading => False, Main_Priority => Default_Main_Priority, @@ -374,13 +372,11 @@ package body Lib.Load is Fatal_Error => None, Generate_Code => True, Has_RACW => False, - Filler => False, Ident_String => Empty, Is_Predefined_Renaming => Ren_Name, Is_Predefined_Unit => Pre_Name or Ren_Name, Is_Internal_Unit => Pre_Name or Ren_Name or GNAT_Name, - Filler2 => False, Loading => True, Main_Priority => Default_Main_Priority, @@ -760,13 +756,11 @@ package body Lib.Load is Fatal_Error => None, Generate_Code => False, Has_RACW => False, - Filler => False, Ident_String => Empty, Is_Predefined_Renaming => Ren_Name, Is_Predefined_Unit => Pre_Name or Ren_Name, Is_Internal_Unit => Pre_Name or Ren_Name or GNAT_Name, - Filler2 => False, Loading => True, Main_Priority => Default_Main_Priority, diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb index ccb0bd2a175..b7a7f129de9 100644 --- a/gcc/ada/lib-writ.adb +++ b/gcc/ada/lib-writ.adb @@ -116,12 +116,10 @@ package body Lib.Writ is Fatal_Error => None, Generate_Code => False, Has_RACW => False, - Filler => False, Ident_String => Empty, Is_Predefined_Renaming => False, Is_Internal_Unit => False, Is_Predefined_Unit => False, - Filler2 => False, Loading => False, Main_Priority => -1, Main_CPU => -1, @@ -175,12 +173,10 @@ package body Lib.Writ is Fatal_Error => None, Generate_Code => False, Has_RACW => False, - Filler => False, Ident_String => Empty, Is_Predefined_Renaming => False, Is_Internal_Unit => True, Is_Predefined_Unit => True, - Filler2 => False, Loading => False, Main_Priority => -1, Main_CPU => -1, diff --git a/gcc/ada/lib.ads b/gcc/ada/lib.ads index c902ca217a6..c22db30219e 100644 --- a/gcc/ada/lib.ads +++ b/gcc/ada/lib.ads @@ -871,55 +871,14 @@ private Has_RACW : Boolean; Dynamic_Elab : Boolean; No_Elab_Code_All : Boolean; - Filler : Boolean; Loading : Boolean; OA_Setting : Character; Is_Predefined_Renaming : Boolean; Is_Internal_Unit : Boolean; Is_Predefined_Unit : Boolean; - Filler2 : Boolean; end record; - -- The following representation clause ensures that the above record - -- has no holes. We do this so that when instances of this record are - -- written by Tree_Gen, we do not write uninitialized values to the file. - - for Unit_Record use record - Unit_File_Name at 0 range 0 .. 31; - Unit_Name at 4 range 0 .. 31; - Munit_Index at 8 range 0 .. 31; - Expected_Unit at 12 range 0 .. 31; - Source_Index at 16 range 0 .. 31; - Cunit at 20 range 0 .. 31; - Cunit_Entity at 24 range 0 .. 31; - Dependency_Num at 28 range 0 .. 31; - Ident_String at 32 range 0 .. 31; - Main_Priority at 36 range 0 .. 31; - Main_CPU at 40 range 0 .. 31; - Primary_Stack_Count at 44 range 0 .. 31; - Sec_Stack_Count at 48 range 0 .. 31; - Serial_Number at 52 range 0 .. 31; - Version at 56 range 0 .. 31; - Error_Location at 60 range 0 .. 31; - Fatal_Error at 64 range 0 .. 7; - Generate_Code at 65 range 0 .. 7; - Has_RACW at 66 range 0 .. 7; - Dynamic_Elab at 67 range 0 .. 7; - No_Elab_Code_All at 68 range 0 .. 7; - Filler at 69 range 0 .. 7; - OA_Setting at 70 range 0 .. 7; - Loading at 71 range 0 .. 7; - - Is_Predefined_Renaming at 72 range 0 .. 7; - Is_Internal_Unit at 73 range 0 .. 7; - Is_Predefined_Unit at 74 range 0 .. 7; - Filler2 at 75 range 0 .. 7; - end record; - - for Unit_Record'Size use 76 * 8; - -- This ensures that we did not leave out any fields - package Units is new Table.Table ( Table_Component_Type => Unit_Record, Table_Index_Type => Unit_Number_Type, diff --git a/gcc/ada/nlists.adb b/gcc/ada/nlists.adb index e5228f5a6f1..a01819902f0 100644 --- a/gcc/ada/nlists.adb +++ b/gcc/ada/nlists.adb @@ -125,19 +125,10 @@ package body Nlists is -------------------------- procedure Allocate_List_Tables (N : Node_Or_Entity_Id) is - Old_Last : constant Node_Or_Entity_Id'Base := Next_Node.Last; - begin - pragma Assert (N >= Old_Last); + pragma Assert (N >= Next_Node.Last); Next_Node.Set_Last (N); Prev_Node.Set_Last (N); - - -- Make sure we have no uninitialized junk in any new entries added. - - for J in Old_Last + 1 .. N loop - Next_Node.Table (J) := Empty; - Prev_Node.Table (J) := Empty; - end loop; end Allocate_List_Tables; ------------ diff --git a/gcc/ada/repinfo.adb b/gcc/ada/repinfo.adb index cd4b6643974..a6dff7cc743 100644 --- a/gcc/ada/repinfo.adb +++ b/gcc/ada/repinfo.adb @@ -77,20 +77,6 @@ package body Repinfo is Op3 : Node_Ref_Or_Val; end record; - -- The following representation clause ensures that the above record - -- has no holes. We do this so that when instances of this record are - -- written, we do not write uninitialized values to the file. - - for Exp_Node use record - Expr at 0 range 0 .. 31; - Op1 at 4 range 0 .. 31; - Op2 at 8 range 0 .. 31; - Op3 at 12 range 0 .. 31; - end record; - - for Exp_Node'Size use 16 * 8; - -- This ensures that we did not leave out any fields - package Rep_Table is new Table.Table ( Table_Component_Type => Exp_Node, Table_Index_Type => Nat, diff --git a/gcc/ada/sinput.ads b/gcc/ada/sinput.ads index 0a9602fd7e2..49423f072d6 100644 --- a/gcc/ada/sinput.ads +++ b/gcc/ada/sinput.ads @@ -793,8 +793,9 @@ private Full_Ref_Name : File_Name_Type; Instance : Instance_Id; Num_SRef_Pragmas : Nat; - First_Mapped_Line : Logical_Line_Number; Source_Text : Source_Buffer_Ptr; + Inlined_Call : Source_Ptr; + First_Mapped_Line : Logical_Line_Number; Source_First : Source_Ptr; Source_Last : Source_Ptr; Source_Checksum : Word; @@ -803,7 +804,6 @@ private Unit : Unit_Number_Type; Time_Stamp : Time_Stamp_Type; File_Type : Type_Of_File; - Inlined_Call : Source_Ptr; Inlined_Body : Boolean; Inherited_Pragma : Boolean; License : License_Type; @@ -839,52 +839,6 @@ private Index : Source_File_Index := 123456789; -- for debugging end record; - -- The following representation clause ensures that the above record - -- has no holes. We do this so that when instances of this record are - -- written by Tree_Gen, we do not write uninitialized values to the file. - - AS : constant Pos := Standard'Address_Size; - - for Source_File_Record use record - File_Name at 0 range 0 .. 31; - Reference_Name at 4 range 0 .. 31; - Debug_Source_Name at 8 range 0 .. 31; - Full_Debug_Name at 12 range 0 .. 31; - Full_File_Name at 16 range 0 .. 31; - Full_Ref_Name at 20 range 0 .. 31; - Instance at 48 range 0 .. 31; - Num_SRef_Pragmas at 24 range 0 .. 31; - First_Mapped_Line at 28 range 0 .. 31; - Source_First at 32 range 0 .. 31; - Source_Last at 36 range 0 .. 31; - Source_Checksum at 40 range 0 .. 31; - Last_Source_Line at 44 range 0 .. 31; - Template at 52 range 0 .. 31; - Unit at 56 range 0 .. 31; - Time_Stamp at 60 range 0 .. 8 * Time_Stamp_Length - 1; - File_Type at 74 range 0 .. 7; - Inlined_Call at 88 range 0 .. 31; - Inlined_Body at 75 range 0 .. 0; - Inherited_Pragma at 75 range 1 .. 1; - License at 76 range 0 .. 7; - Keyword_Casing at 77 range 0 .. 7; - Identifier_Casing at 78 range 0 .. 15; - Sloc_Adjust at 80 range 0 .. 31; - Lines_Table_Max at 84 range 0 .. 31; - Index at 92 range 0 .. 31; - - -- The following fields are pointers, so we have to specialize their - -- lengths using pointer size, obtained above as Standard'Address_Size. - -- Note that Source_Text is a fat pointer, so it has size = AS*2. - - Source_Text at 96 range 0 .. AS * 2 - 1; - Lines_Table at 96 range AS * 2 .. AS * 3 - 1; - Logical_Lines_Table at 96 range AS * 3 .. AS * 4 - 1; - end record; -- Source_File_Record - - for Source_File_Record'Size use 96 * 8 + AS * 4; - -- This ensures that we did not leave out any fields - package Source_File is new Table.Table (Table_Component_Type => Source_File_Record, Table_Index_Type => Source_File_Index, diff --git a/gcc/ada/urealp.adb b/gcc/ada/urealp.adb index cad1e662e18..103deb0e8e6 100644 --- a/gcc/ada/urealp.adb +++ b/gcc/ada/urealp.adb @@ -48,20 +48,6 @@ package body Urealp is -- Flag set if value is negative end record; - -- The following representation clause ensures that the above record - -- has no holes. We do this so that when instances of this record are - -- written, we do not write uninitialized values to the file. - - for Ureal_Entry use record - Num at 0 range 0 .. 31; - Den at 4 range 0 .. 31; - Rbase at 8 range 0 .. 31; - Negative at 12 range 0 .. 31; - end record; - - for Ureal_Entry'Size use 16 * 8; - -- This ensures that we did not leave out any fields - package Ureals is new Table.Table ( Table_Component_Type => Ureal_Entry, Table_Index_Type => Ureal'Base, -- 2.43.0