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] Allow pragma Inline_Always to overrule -fno-inline


Prior to this change, -fno-inline was stopping all the inlining
unconditionally, even when requested with a pragma Inline_Always.

This was inconsistent with the behavior of the "always_inline" gcc attribute,
and this change fixes this.

It also removes an internal shortcircuit which was preventing consistency
checks of the various inlining pragmas attached to a subprogram.

For the following suprogram, the call to p1 must always be inlined
regardless of -fno-inline, and the call to p2 must not be inlined in
presence of -fno-inline:

procedure Intra is
   
   x : integer;
   pragma Import (C, X);
   pragma Volatile (X);
   
   procedure p1;
   pragma Inline_Always (p1);
   
   procedure p2;
   pragma Inline (p2);
   
   procedure p1 is begin x := 1; end;
   procedure p2 is begin x := 2; end;
begin
   p1;
   p2;
end;

And for the code below:

procedure Bogus is
   
   x : integer;
   pragma Import (C, X);
   pragma Volatile (X);
   
   procedure p1;
   pragma Inline_Always (p1);
   pragma No_Inline (p1);
   
   procedure p2;
   pragma Inline (p2);
   pragma No_Inline (p2);
   
   procedure p1 is begin x := 1; end;
   procedure p2 is begin x := 2; end;
begin
   p1;
   p2;
end;

The compiler must flag inconsistencies between No_Inline and Inline or
Inline_Always with or without -fno-inline on the command line.

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

2015-02-20  Olivier Hainque  <hainque@adacore.com>

	* opt.ads: Replace Opt.Suppress_All_Inlining by two separate
	flags controlling the actual FE inlining out of pragma Inline
	and pragma Inline_Always.
	* adabkend.adb (Scan_Compiler_Arguments): Set both flags to True
	on -fno-inline, which disables all inlining in compilers with
	an Ada back-end and without back-end inlining support.
	* back_end.adb (Scan_Back_End_Switches): Set the Inline related
	flag to True on -fno-inline and leave Inline_Always alone for
	gcc back-ends.
	* back_end.ads (Scan_Compiler_Arguments): Adjust spec wrt the
	names of the Opt flags it sets.
	* gnat1drv.adb (Adjust_Global_Switches): Remove test on
	Opt.Suppress_All_Inlining in the Back_End_Inlining computation.
	* sem_prag.adb (Make_Inline): Remove early return conditioned
	on Opt.Suppress_All_Inlining.
	* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Use the flags to
	disable the calls to Build_Body_To_Inline otherwise triggered
	by pragma Inline or Inline_Always. This will prevent actual
	front-end inlining of the subprogram on calls.

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]