Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uwm.edu!bionet!agate!shelby!portia.stanford.edu!dhinds From: dhinds@portia.Stanford.EDU (David Hinds) Newsgroups: comp.arch Subject: Re: Inlining subroutines at link time Message-ID: <1990Jul3.215128.23026@portia.Stanford.EDU> Date: 3 Jul 90 21:51:28 GMT References: <1990Jul3.194348.21178@msuinfo.cl.msu.edu> <9595@brazos.Rice.edu> Organization: AIR, Stanford University Lines: 33 In article <9595@brazos.Rice.edu> preston@titan.rice.edu (Preston Briggs) writes: >In article <1990Jul3.194348.21178@msuinfo.cl.msu.edu> riordanmr@clvax1.cl.msu.edu (Mark Riordan) writes: >>I just came across a CDC NOS/VE manual describing a facility to >>inline FORTRAN routines after compilation (essentially during linking). > >There's a rumour that some Unix C compilers do similar things. >Generally though, it seems a waste, particularly for Fortran. ^^^^^^^^^^^^^^^^^^^^^^^^ >Consider the time spent in a subroutine versus a savings of two >instructions -- hardly worth the time to specify an extra compile flag. Geez, is this a cheap shot, or what? FORTRAN has its weaknesses, but inefficiency is not one of them. I know of no other language that can be as effectively optimized. The time savings might be significant if paging/caching overhead is included in the calculation. >Inlining before optimization has the potential for being a lot >more interesting. The hard part is choosing (automatically) >routines to inline. It's fairly easy to eliminate most of the >calls in a program, but is the code any faster? Often not. >On many systems, inlining actually produces slower code in many cases, >despite all the obvious intuitions. It's particularly frustrating >in view of the hefty time penalties paid to optimize the >resulting humongous routines. > The MIPS compiler front-ends can all generate intermediate "ucode" object files. These are linked, then passed to a procedure merge program to inline things. This then goes through the global optimizer, and on to the code generator. The inliner can use feedback from the profiler to decide where it is most useful. -David Hinds dhinds@popserver.stanford.edu