From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,23ade4b42d9cb5f0 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-20 15:28:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeed.icl.net!newsfeed.fjserv.net!xara.net!gxn.net!195.149.39.220.MISMATCH!news-peer.gradwell.net!not-for-mail Newsgroups: comp.lang.ada From: porton@ex-code.com (Victor Porton) Date: Tue, 21 Jan 2003 02:27:56 +0500 References: <3e2b7777$0$33930$bed64819@news.gradwell.net> Organization: Extreme Code Software (http://ex-code.com) Subject: Re: Eliminating copying in Gnat Mime-Version: 1.0 X-Newsreader: knews 1.0b.1 Content-Type: text/plain; charset=us-ascii X-URL: http://www.ex-code.com/ Message-ID: <3e2c8625$0$33922$bed64819@news.gradwell.net> NNTP-Posting-Date: 20 Jan 2003 23:28:37 GMT NNTP-Posting-Host: 195.149.39.13 X-Trace: 1043105317 news.gradwell.net 33922 mail2news/195.149.39.13 X-Complaints-To: news-abuse@gradwell.net Xref: archiver1.google.com comp.lang.ada:33258 Date: 2003-01-20T23:28:37+00:00 List-Id: In article , Stephen Leake writes: > porton@ex-code.com (Victor Porton) writes: > >> Is it possible to cause Gnat to not do unnecessary copying >> when calling this fynction? >> >> If T is a controlled type, it calls Adjust 3(!) times even if I >> compile with optimization ("-O3 -gnatN"). > > Post complete code that demonstrates this; maybe I'll have other > suggestions. > >> It is in Gnat-3.14p. May be it was fixed in Gnat-3.2/3.15p? I don't see any relevant problems about inlining even if all warnings are on (however it does not inline an unrelevant library function). But Adjust is called 3 times :-( -- m.adb -- with P; procedure M is function Pass(X: P.T) return P.T is pragma Inline(Pass); begin return X; end; X: P.T; Y: P.T := Pass(X); begin null; end M; -- p.ads -- with Ada.Finalization; package P is type T is new Ada.Finalization.Controlled with null record; procedure Adjust(Object: in out T); end P; -- p.adb -- with Ada.Text_IO; package body P is procedure Adjust (Object: in out T) is begin Ada.Text_IO.Put_Line("QWER"); end Adjust; end P;