From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25660 invoked by alias); 4 Nov 2009 19:19:40 -0000 Received: (qmail 25648 invoked by uid 22791); 4 Nov 2009 19:19:38 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_05 X-Spam-Check-By: sourceware.org Received: from moene.org (HELO moene.org) (82.95.66.103) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 04 Nov 2009 19:19:33 +0000 Received: from [127.0.0.1] (ident=toon) by moene.org with esmtp (Exim 4.69) (envelope-from ) id 1N5lOE-0002ra-Te; Wed, 04 Nov 2009 20:19:30 +0100 Message-ID: <4AF1D3C2.3000001@moene.org> Date: Wed, 04 Nov 2009 19:19:00 -0000 From: Toon Moene User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: Jan Hubicka CC: gcc mailing list Subject: Whole program optimization and functions-only-called-once. Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-11/txt/msg00082.txt.bz2 Jan, I had some time to study the example I sent you a couple of weeks ago. According to visible inspection of the source code, there are 5 functions (subroutines in Fortran parlance) that are called once: MAIN calls HLPROG calls GEMINI calls SL2TIM calls PHCALL calls PHTASK I.e., the last five should be candidates for inlining of "functions only called once". However, ccrPOljB.o.047i.inline says: Deciding on functions called once: Considering gemini_.clone.1 size 11443. Called once from hlprog 462 insns. Inlined into hlprog which now has 10728 size for a net change of -12620 size. Considering hlprog size 10728. Called once from main 7 insns. Not inlined because --param large-function-growth limit reached. Inlined 1 calls, eliminated 1 functions, size 45477 turned to 32857 size. The dump option -fdump-ipa-all also gives me the call graph, of which I copy here the relevant part: phcall_.clone.3/11(-1) @0x7fd198c16400 (clone of phcall/33) availability:local 8281 time, 972 benefit 1351 size, 291 benefit 984 bytes stack usage reachable local finalized inlinable called by: sl2tim/49 (0.44 per call) sl2tim_.clone.0/16 (0.44 per call) phtask_.clone.2/12(-1) @0x7fd198c16500 (clone of phtask/41) availability:local 26416 time, 4268 benefit 4541 size, 880 benefit 480 bytes stack usage reachable local finalized inlinable called by: phcall_.clone.3/11 (3.52 per call) phcall/33 (3.52 per call) sl2tim_.clone.0/16(-1) @0x7fd198c16900 (clone of sl2tim/49) availability:local 207312 time, 26617 benefit 5169 size, 941 benefit 3856 bytes stack usage reachable local finalized inlinable called by: gemini_.clone.1/40 (1.00 per call) gemini/0 (1.00 per call) gemini_.clone.1phtask/40(-1) @0x7fd198c35000 (inline copy in hlprog/17) (clone of gemini/0) availability:local 147324 time, 2770 benefit 11443 size, 1177 benefit 11635 bytes stack usage reachable local finalized inlinable called by: hlprog/17 (3.57 per call) (inlined) phtask/41(-1) @0x7fd198c35100 availability:local 26416 time, 4268 benefit 4541 size, 880 benefit 480 bytes stack usage reachable body local finalized inlinable called by: phcall/33(-1) @0x7fd198c33a00 availability:local 8281 time, 972 benefit 1351 size, 291 benefit 984 bytes stack usage reachable body local finalized inlinable called by: hlprog/17(-1) @0x7fd198c16a00 availability:local 560 time, 10 benefit (516762 after inlining) 462 size, 1 benefit (10728 after inlining) 4216 bytes stack usage 15851 bytes after inlining reachable body local finalized inlinable called by: main/29 (1.00 per call) sl2tim/49(-1) @0x7fd198c35900 availability:local 207312 time, 26617 benefit 5169 size, 941 benefit 3856 bytes stack usage reachable body local finalized inlinable called by: gemini/0(-1) @0x7fd198bef800 availability:local 147324 time, 2770 benefit 11443 size, 1177 benefit 11635 bytes stack usage reachable body local finalized inlinable called by: So if we have to believe this summary, HLPROG is called by MAIN, but is not suitable for inlining (I can live with that). GEMINI is not called, but GEMINI.clone is (by HLPROG) and is inlined. SL2TIM is not called, but SL2TIM.clone is called by GEMINI and GEMINI.clone; because it is called twice, it is not considered a function-only-called-once. PHCALL is not called, but PHCALL.clone is called by SL2TIM and SL2TIM.clone; because it is called twice, it is not considered a function-only-called-once. PHTASK is not called, but PHTASK.clone is called by PHCALL and PHCALL.clone; because it is called twice, it is not considered a function-only-called-once. I don't think this is really what we want with functions-only-called-once: If only the .clone version of a function is used, than a function that's only called once *inside this clone* is a function-only-called-once. I hope this analysis helps, -- Toon Moene - e-mail: toon@moene.org - phone: +31 346 214290 Saturnushof 14, 3738 XG Maartensdijk, The Netherlands At home: http://moene.org/~toon/ Progress of GNU Fortran: http://gcc.gnu.org/gcc-4.5/changes.html