[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200705241347.43727.rob@landley.net>
Date: Thu, 24 May 2007 13:47:43 -0400
From: Rob Landley <rob@...dley.net>
To: Roland Dreier <rdreier@...co.com>
Cc: Adrian Bunk <bunk@...sta.de>,
Arjan van de Ven <arjan@...ux.intel.com>,
linux-kernel@...r.kernel.org
Subject: Re: Status of CONFIG_FORCED_INLINING?
On Thursday 24 May 2007 1:14 pm, 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?
Because the purpose of .h files is to be included in more than one .c file.
(Otherwise it should be a .c file.)
And if you #include a non-inlined definition in two .c files, the compiler
will emit two copies into two separate .o files. What you're hoping is that
the linker will notice they're identical and merge them, and last I checked I
couldn't even reliably get it to do that with constant strings.
> 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.
If we put it in a header, it's because we want it inlined. If we don't want
it inlined it SHOULDN'T BE IN THE HEADER.
If the compiler can emit a warning "inline insanely large", we can use that to
fix it. But a warning is not the same as silently doing something other than
what we told it to do.
> - R.
Rob
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists