This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Lift inlining limitation with -gnatn


This change lifts a limitation of the inlining performed with -gnatn.  This
option doesn't cause subprograms that are instances of generic subprograms
declared inline to be inlined if they aren't instantiated in the current unit.

On the contrary, the deprecated -gnatN does have this effect.

The problem is that Add_Inlined_Body was marking the enclosing scope of the
subprogram as inlined whereas Add_Inlined_Subprogram expects the enclosing
code unit to be marked as inlined.  The change is to use the latter form in
both routines.  The call to My_G.Last_M in procedure P must be inlined with
-O -gnatn after this change.

-----
with Q; use Q;

procedure P is
  N : Natural;
begin
  My_G.Increment_M;
  N := My_G.Last_M;
  if N /= 1 then
    raise Program_Error;
  end if;
end;
-----
with G;

package Q is

  package My_G is new G (Natural);

end Q;
-----
generic

  type Index_Type is range <>;

package G is

  procedure Increment_M;

  function Last_M return Index_Type;
  pragma Inline (Last_M);

private

  Last_Val : Integer := 0;

end G;
-----
package body G is

  procedure Increment_M is
  begin
    Last_Val := Last_Val + 1;
  end;

  function Last_M return Index_Type is
  begin
    return Index_Type (Last_Val);
  end;

end G;
------

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

2011-08-02  Eric Botcazou  <ebotcazou@adacore.com>

	* inline.adb (Get_Code_Unit_Entity): New local function.  Returns the
	entity node for the unit containing the parameter.
	(Add_Inlined_Body): Use it to find the unit containing the subprogram.
	(Add_Inlined_Subprogram): Likewise.
	* gcc-interface/Make-lang.in: Update dependencies.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]