comp.lang.ada
 help / color / mirror / Atom feed
* Inlining issues (GNAT 3.13p, OA 7.2.1)
@ 2001-12-19 12:51 Gautier Write-only-address
  0 siblings, 0 replies; only message in thread
From: Gautier Write-only-address @ 2001-12-19 12:51 UTC (permalink / raw)
  To: comp.lang.ada

Hello!

Does anyone know why GNAT 3.13p (Windows) doesn't want to inline
a function when it is a generic parameter, but does it if the
function is at library level ?
Interestingly, ObjectAda don't do it for both generic parameter
variants.
Of course I know that any compiler has right to inline or not
to inline. Just curious, and "all ears" for turnarounds...
Test code below, with "markers" to recognize parts in assembler output.
TIA, Gautier
-----------------------------------------------------------------------
-- Inlining problem:
--
--  GNAT 3.13p does inline external library-level function Bing5678
--    as generic parameter, but doesn't want to inline function Bing1234
--    Test: gcc -S -O2 -gnatpn Test_Generic_Inline.adb
--
--  OA 7.2.1 says:
--
--    test_generic_inline.adb: Warning: line 51 col 13 LRM:6.3.2(6), Body
--    for subprogram is not available or comes after this call, Generating
--    out-of-line call (In instance of generic Bingo_generic at
--    test_generic_inline.adb: line 46 col 25)
--
--    test_generic_inline.adb: Warning: line 52 col 13 LRM:6.3.2(6), Body
--    for subprogram is not available or comes after this call, Generating
--    out-of-line call (In instance of generic Bingo_generic at
--    test_generic_inline.adb: line 46 col 25)
--
--    LRM:6.3.2(6): "For each call, an implementation is free to follow
--                   or to ignore the recommendation expressed by the 
pragma"

with Ada.Text_IO;                       use Ada.Text_IO;
with Bing5678;

procedure Test_Generic_Inline is

  function Bing1234( x,y: Integer ) return Integer is
  pragma inline(Bing1234);
    mxy: Integer;
  begin
    mxy:= x*1234 + y*4321;
    return mxy;
  end Bing1234;

  type Tablo is array(integer range <>,integer range <>) of integer;

  generic
    with function Bing( x,y: Integer ) return Integer;
    pragma inline(Bing);
  procedure Bingo_generic(t: in out Tablo);

  procedure Bingo_generic(t: in out Tablo) is
  begin
    for x in t'range(1) loop
      for y in t'range(2) loop
        t(x,y):= t(x,y)+Bing(x,y);
      end loop;
    end loop;
  end Bingo_generic;

  procedure Bingo_instance is new Bingo_generic(Bing1234);
  procedure Bingo_outside_instance is new Bingo_generic(Bing5678);

  procedure Bingo(t: in out Tablo) is
  begin
    for x in t'range(1) loop
      for y in t'range(2) loop
        t(x,y):= t(x,y)+Bing1234(x,y);
      end loop;
    end loop;
  end Bingo;

  t1: Tablo(1..100,1..100);


begin
  t1:= (others=>(others=>0));
  t1(1,1):= 10203040;
  Bingo(t1);
  t1(1,1):= 40302010;
  Bingo_instance(t1);
  t1(1,1):= 50607080;
  Bingo_outside_instance(t1);
  t1(1,1):= 80604020;

  for x in t1'range(1) loop
    for y in t1'range(2) loop
      Put(integer'image(t1(x,y)));
    end loop;
  end loop;

end Test_Generic_Inline;

function Bing5678( x,y: Integer ) return Integer is
pragma inline(Bing5678);
pragma pure(Bing5678);
  mxy: Integer;
begin
  mxy:= x*5678 + y*8765;
  return mxy;
end Bing5678;


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-12-19 12:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-19 12:51 Inlining issues (GNAT 3.13p, OA 7.2.1) Gautier Write-only-address

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox