public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Roland Dreier <rdreier@cisco.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>,
	Rob Landley <rob@landley.net>,
	linux-kernel@vger.kernel.org
Subject: Re: Status of CONFIG_FORCED_INLINING?
Date: Thu, 24 May 2007 19:57:10 +0200	[thread overview]
Message-ID: <20070524175710.GD4470@stusta.de> (raw)
In-Reply-To: <ada3b1m87pa.fsf@cisco.com>

On Thu, May 24, 2007 at 10:14:41AM -0700, Roland Dreier wrote:
>  > A function only belongs into a header file if we always want it inlined, 
>  > otherwise it belongs into a C file.
> 
> Again, why?  Why don't we trust the compiler to decide if a function
> should be inlined or not, even if the definition happens to be in a .h
> file?
> 
> It seems like a perfectly valid optimization for the compiler to only
> emit code once for a function and then call it where it is used, even
> if that function happens to be defined in a .h file.

The compiler will always inline it when it's called once from a C file, 
and it might not inline it there when it's called more than once from 
another C file. So in the end, we have it not only out-of-line but also 
inlined in several places.

Functions in header files should either be extremely short so that 
inlining them makes sense, or always optimize to something extremely 
short after being inlined.

If it's an optimization to emit the code only once, then it's a bug that 
it's in a header file.

>  - R.

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


  parent reply	other threads:[~2007-05-24 17:57 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-23 19:10 Status of CONFIG_FORCED_INLINING? Rob Landley
2007-05-23 19:42 ` Arjan van de Ven
2007-05-23 21:22   ` Adrian Bunk
2007-05-23 21:28     ` Roland Dreier
2007-05-24 12:38       ` Robert P. J. Day
2007-05-24 16:55         ` Rob Landley
2007-05-24 17:10       ` Adrian Bunk
2007-05-24 17:14         ` Roland Dreier
2007-05-24 17:47           ` Rob Landley
2007-05-24 17:47             ` Arjan van de Ven
2007-05-24 18:14               ` Rob Landley
2007-05-24 17:55             ` Roland Dreier
2007-05-24 18:07               ` Adrian Bunk
2007-05-24 18:32                 ` Roland Dreier
2007-05-24 22:41                   ` Adrian Bunk
2007-05-24 17:57           ` Adrian Bunk [this message]
2007-05-23 21:31     ` Arjan van de Ven
2007-05-24 17:12       ` Adrian Bunk
2007-05-24 16:29     ` Jan Engelhardt
2007-05-24 17:14       ` Adrian Bunk
2007-05-24 17:17         ` Arjan van de Ven
2007-05-24 17:40       ` Rob Landley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070524175710.GD4470@stusta.de \
    --to=bunk@stusta.de \
    --cc=arjan@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdreier@cisco.com \
    --cc=rob@landley.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox