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] Avoid useless copy caused by address clause


An address clause marks both operands as Treat_As_Volatile, which was
being treated as real volatile for the purpose of doing call by  copy
when passing to a non-volatile type. This is clearly an unnecessary
inefficiency and is corrected by this patch.

Test program:

package Pbr is
    type Ba is array (1 .. 1000) of Integer;
    procedure Fba (O : out Ba);
    B : Ba;
end Pbr;

with Pbr; use Pbr;
procedure Cbr is
    J : Integer;
    for J'Address use B'Address;
begin
    Fba (B);
end;

Output from -gnatG before patch:

with pbr;
use pbr;
with system;

procedure cbr is
   j : integer;
   for j'address use pbr__b'address;
begin
   T1b : pbr__ba;
   pbr__fba (T1b);
   pbr__b := T1b;
   return;
end cbr;

Output from -gnatG after patch:

with pbr;
use pbr;
with system;

procedure cbr is
   j : integer;
   for j'address use pbr__b'address;
begin
   pbr__fba (pbr__b);
   return;
end cbr;

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

2009-06-24  Robert Dewar  <dewar@adacore.com>

	* exp_ch6.adb (Expand_Actuals): Use Is_Volatile, not Treat_As_Volatile
	in deciding to do call-by-copy code.

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]