From 2bfa54844650a8583d41e06717a7374d9d53fd6e Mon Sep 17 00:00:00 2001 From: Hristian Kirtchev Date: Fri, 2 Sep 2011 09:45:45 +0000 Subject: [PATCH] exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Do not create TSS routine Finalize_Address when compiling in Alfa mode. 2011-09-02 Hristian Kirtchev * exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Do not create TSS routine Finalize_Address when compiling in Alfa mode. (Expand_Freeze_Record_Type): Do not create TSS routine Finalize_Address when compiling in Alfa mode. * exp_ch4.adb (Expand_Allocator_Expression): Do not produce a call to Set_Finalize_Address in Alfa mode because Finalize_Address is not built. (Expand_N_Allocator): Do not produce a call to Set_Finalize_Address in Alfa mode because Finalize_Address is not built. * exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Do not produce a call to primitive Set_Finalize_Address in Alfa mode because Finalize_Address is not built. * exp_ch7.adb (Build_Finalization_Master): Do not create finalization masters in Afa mode since they are not needed. (Build_Finalizer): Do not create scope and library-level finalizers in Alfa mode since they are not needed. * exp_util.adb (Build_Allocate_Deallocate_Proc): Do not expand "new" and "free" when applied to controlled objects in Alfa mode since this is not needed. From-SVN: r178456 --- gcc/ada/ChangeLog | 22 ++++++++++++++++++++++ gcc/ada/exp_ch3.adb | 17 +++++++++++++---- gcc/ada/exp_ch4.adb | 35 ++++++++++++++++++++++++++--------- gcc/ada/exp_ch6.adb | 12 ++++++++---- gcc/ada/exp_ch7.adb | 20 ++++++++++++++++++++ gcc/ada/exp_util.adb | 7 +++++++ 6 files changed, 96 insertions(+), 17 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 238a8cd5408..98abf03e371 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,25 @@ +2011-09-02 Hristian Kirtchev + + * exp_ch3.adb (Expand_Freeze_Class_Wide_Type): Do not create + TSS routine Finalize_Address when compiling in Alfa mode. + (Expand_Freeze_Record_Type): Do not create TSS routine + Finalize_Address when compiling in Alfa mode. + * exp_ch4.adb (Expand_Allocator_Expression): Do not produce a + call to Set_Finalize_Address in Alfa mode because Finalize_Address is + not built. + (Expand_N_Allocator): Do not produce a call to + Set_Finalize_Address in Alfa mode because Finalize_Address is not built. + * exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Do not + produce a call to primitive Set_Finalize_Address in Alfa mode because + Finalize_Address is not built. + * exp_ch7.adb (Build_Finalization_Master): Do not create + finalization masters in Afa mode since they are not needed. + (Build_Finalizer): Do not create scope and library-level + finalizers in Alfa mode since they are not needed. + * exp_util.adb (Build_Allocate_Deallocate_Proc): Do not expand + "new" and "free" when applied to controlled objects in Alfa mode since + this is not needed. + 2011-09-02 Vincent Celier * prj-nmsc.db: (Check_Stand_Alone_Library): For SALs, allow diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb index 464fdef4024..56d0fa2ef6b 100644 --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -5634,6 +5634,12 @@ package body Exp_Ch3 is elsif CodePeer_Mode then return; + + -- Do not create TSS routine Finalize_Address when compiling in Alfa + -- mode because it is not necessary and results in useless expansion. + + elsif Alfa_Mode then + return; end if; -- Create the body of TSS primitive Finalize_Address. This automatically @@ -6379,11 +6385,14 @@ package body Exp_Ch3 is -- Create the body of TSS primitive Finalize_Address. This must -- be done before the bodies of all predefined primitives are - -- created. If Def_Id is limited, Stream_Input and Streap_Read - -- may produce build-in-place allocations and for that the - -- expander needs Finalize_Address. + -- created. If Def_Id is limited, Stream_Input and Stream_Read + -- may produce build-in-place allocations and for those the + -- expander needs Finalize_Address. Do not create the body of + -- Finalize_Address in Alfa mode since it is not needed. - Make_Finalize_Address_Body (Def_Id); + if not Alfa_Mode then + Make_Finalize_Address_Body (Def_Id); + end if; Predef_List := Predefined_Primitive_Bodies (Def_Id, Renamed_Eq); Append_Freeze_Actions (Def_Id, Predef_List); diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 91d79e30fbe..4e652eb2234 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -1149,12 +1149,19 @@ package body Exp_Ch4 is -- Generate: -- Set_Finalize_Address (FM, FD'Unrestricted_Access); - -- Since .NET/JVM compilers do not support address arithmetic, - -- this call is skipped. The same is done for CodePeer because - -- primitive Finalize_Address is never generated. Do not create - -- this call if there is no allocator available any more. + -- Do not generate this call in the following cases: + -- + -- * .NET/JVM - these targets do not support address arithmetic + -- and unchecked conversion, key elements of Finalize_Address. + -- + -- * Alfa mode - the call is useless and results in unwanted + -- expansion. + -- + -- * CodePeer mode - TSS primitive Finalize_Address is not + -- created in this mode. if VM_Target = No_VM + and then not Alfa_Mode and then not CodePeer_Mode and then Present (Finalization_Master (PtrT)) and then Present (Temp_Decl) @@ -3481,9 +3488,12 @@ package body Exp_Ch4 is end if; -- The finalization master must be inserted and analyzed as part of - -- the current semantic unit. + -- the current semantic unit. This form of expansion is not carried + -- out in Alfa mode because it is useless. - if No (Finalization_Master (PtrT)) then + if No (Finalization_Master (PtrT)) + and then not Alfa_Mode + then Set_Finalization_Master (PtrT, Current_Anonymous_Master); end if; end if; @@ -3979,10 +3989,17 @@ package body Exp_Ch4 is -- Set_Finalize_Address -- (FM, FD'Unrestricted_Access); - -- Do not generate the above for CodePeer compilations - -- because primitive Finalize_Address is never built. + -- Do not generate this call in the following cases: + -- + -- * Alfa mode - the call is useless and results in + -- unwanted expansion. + -- + -- * CodePeer mode - TSS primitive Finalize_Address is + -- not created in this mode. - elsif not CodePeer_Mode then + elsif not Alfa_Mode + and then not CodePeer_Mode + then Insert_Action (N, Make_Set_Finalize_Address_Call (Loc => Loc, diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 5df20678f1d..fd85a038871 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -6519,7 +6519,7 @@ package body Exp_Ch6 is begin -- Ada 2005 (AI-251): In class-wide interface objects we displace - -- "this" to reference the base of the object --- required to get + -- "this" to reference the base of the object required to get -- access to the TSD of the object. if Is_Class_Wide_Type (Etype (Exp)) @@ -7245,10 +7245,14 @@ package body Exp_Ch6 is then null; - -- Do not generate the call to Make_Set_Finalize_Address for - -- CodePeer compilations because Finalize_Address is never built. + -- Do not generate the call to Set_Finalize_Address in Alfa mode + -- because it is not necessary and results in unwanted expansion. + -- This expansion is also not carried out in CodePeer mode because + -- Finalize_Address is never built. - elsif not CodePeer_Mode then + elsif not Alfa_Mode + and then not CodePeer_Mode + then Insert_Action (Allocator, Make_Set_Finalize_Address_Call (Loc, Typ => Etype (Function_Id), diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb index 73ae23da94c..15980234386 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -888,6 +888,12 @@ package body Exp_Ch7 is and then not Is_Controlled (Desig_Typ) then return; + + -- Do not create finalization masters in Alfa mode because they result + -- in unwanted expansion. + + elsif Alfa_Mode then + return; end if; declare @@ -2689,6 +2695,13 @@ package body Exp_Ch7 is begin Fin_Id := Empty; + -- Do not perform this expansion in Alfa mode because it is not + -- necessary. + + if Alfa_Mode then + return; + end if; + -- Step 1: Extract all lists which may contain controlled objects or -- library-level tagged types. @@ -2844,6 +2857,13 @@ package body Exp_Ch7 is -- which belongs to a protected type. begin + -- Do not perform this expansion in Alfa mode because we do not create + -- finalizers in the first place. + + if Alfa_Mode then + return; + end if; + -- The At_End handler should have been assimilated by the finalizer pragma Assert (No (At_End_Proc (HSS))); diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index f3d4c9a2346..022f5f63612 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -480,6 +480,13 @@ package body Exp_Util is -- Start of processing for Build_Allocate_Deallocate_Proc begin + -- Do not perform this expansion in Alfa mode because it is not + -- necessary. + + if Alfa_Mode then + return; + end if; + -- Obtain the attributes of the allocation / deallocation if Nkind (N) = N_Free_Statement then -- 2.30.2