This patch adjusts the behavior of the wavefront to incorporate frontend inlining support when compiling on AMMP or VM targets. This new support is temporarily available using -gnatd.k
These are the rules: * At -O0, or compiling on AAMP or VM targets, use fe inlining when inline_always is specified except if the function returns a controlled type. The deprecated switch -gnatN can be used at this level. * At other optimization levels use the fe inlining for both inline and inline_always in the following cases: - function returning a known at compile time constant - function returning a call to an intrinsic function - function returning an unconstrained type through an Ada 2005 extended return statement - function returning a call to a frontend-inlined function Use the back-end mechanism otherwise Tested on x86_64-pc-linux-gnu, committed on trunk 2012-03-09 Javier Miranda <mira...@adacore.com> * sem_ch6.adb (Check_Body_To_Inline): In AAMP and VM targets use frontend inlining at all optimization levels. * sem_util.adb (Must_Inline): In AAMP and VM targets, given that there is no inlining support in the backend, use also frontend inlining when compiling with optimizations enabled. * exp_ch6.adb (Expand_Call): Minor code reorganization.
Index: sem_util.adb =================================================================== --- sem_util.adb (revision 185136) +++ sem_util.adb (working copy) @@ -9422,7 +9422,13 @@ function Must_Inline (Subp : Entity_Id) return Boolean is begin - return Optimization_Level = 0 + -- AAMP and VM targets have no support for inlining in the backend. + -- Hence we do as much inlining as possible in the front end. + + return + (Optimization_Level = 0 + or else AAMP_On_Target + or else VM_Target /= No_VM) and then Has_Pragma_Inline (Subp) and then (Has_Pragma_Inline_Always (Subp) or else Front_End_Inlining); end Must_Inline; Index: exp_ch6.adb =================================================================== --- exp_ch6.adb (revision 185136) +++ exp_ch6.adb (working copy) @@ -3790,10 +3790,7 @@ Spec : constant Node_Id := Unit_Declaration_Node (Subp); begin - if Optimization_Level > 0 then - Do_Inline (Subp, Orig_Subp); - - elsif Must_Inline (Subp) then + if Must_Inline (Subp) then if In_Extended_Main_Code_Unit (Call_Node) and then In_Same_Extended_Unit (Sloc (Spec), Loc) and then not Has_Completion (Subp) @@ -3805,6 +3802,9 @@ else Do_Inline_Always (Subp, Orig_Subp); end if; + + elsif Optimization_Level > 0 then + Do_Inline (Subp, Orig_Subp); end if; -- The call may have been inlined or may have been passed to Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 185136) +++ sem_ch6.adb (working copy) @@ -4888,9 +4888,13 @@ Remove (Body_To_Analyze); -- Keep separate checks needed when compiling without optimizations + -- AAMP and VM targets have no support for inlining in the backend + -- and hence we use frontend inlining at all optimization levels. - if Optimization_Level = 0 then - + if Optimization_Level = 0 + or else AAMP_On_Target + or else VM_Target /= No_VM + then -- Cannot inline functions whose body has a call that returns an -- unconstrained type since the secondary stack is involved, and -- it is not worth inlining.