This is the mail archive of the gcc@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]

Whole program optimization and functions-only-called-once.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]