LWN.net Logo

The cost of inline functions

The cost of inline functions

Posted May 3, 2004 8:20 UTC (Mon) by eru (subscriber, #2753)
Parent article: The cost of inline functions

Doesn't this also depend a lot on the processor architecture? I used to work with a SPARC and there I found that in the GCC of the time, turning on automatic inlining was usually a pessimization for my applications. I assumed that this is because non-inlined calls to simple functions on the SPARC chips are cheap. Most arguments are passed in registers, and the register window mechanism greatly reduces the instructions needed to save/restore caller's register-allocated variables.

I would argue that "inline" as a language feature is just like the "register" storage class. It should not be used unless inlining really is necessary for low-level reasons, and normally the compiler should be left to make inlining decisions based on its knowledge of the target processor trade-offs.


(Log in to post comments)

The cost of inline functions

Posted May 9, 2004 7:54 UTC (Sun) by hs (guest, #15495) [Link]

not necessarily. it depends a lot on the function code and what the optimizer does: in some situations things like constant propagation and commeon subexpression detection can make most of the inlined code go away. <p>
with some optimizations it takes good judgement to decide whether to activate them or not

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds