This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: empty function optimizations
- To: Ken Clark <ken at gesn dot com>
- Subject: Re: empty function optimizations
- From: Michael Meissner <meissner at cygnus dot com>
- Date: Tue, 11 Jul 2000 13:21:37 -0400
- Cc: gcc at gcc dot gnu dot org
- References: <NCBBIGGNCKBDKCCGPEOAIEDFDKAA.ken@gesn.com>
On Tue, Jul 11, 2000 at 11:57:28AM -0700, Ken Clark wrote:
> On Mon, 10 Jul 2000, Philipp Rumpf wrote:
> > On Sat, Jul 08, 2000 at 09:50:38PM +0200, Geert Uytterhoeven wrote:
> > > My idea was to replace empty and most simple functions by predefined
> dummy(),
> > > dummy_zeros(), dummy_ones() and dummy_einval() functions, so they appear
> only
> > > once in a kernel image. But is it worth the effort? Note that you don't
> compile
> > > all code into your favorite kernel image, only the parts you need for
> your
> > > hardware, so you won't catch all empty functions at once.
> >
> > This really should be a gcc/ld thing. If/when we moved
> to -ffunction-sections,
> > all that would be required is a "merge identical read-only ELF sections"
> > option to ld (or a standalone hack to do the same thing).
>
>
> This came up on the Linux kernel list yesterday, but I have been thinking
> about this for a long time. In our C++ project, we use container templates
> fairly heavily. The problem is that often the templates generate function
> code that is independent of the class, or maybe only dependent on the class
> sizeof. With hundreds of classes it really adds up.
>
> Would collecting all the identical code at link time be as easy as it
> sounds, or are there complications?
Well there is the obvious problem that you can no longer set breakpoints on an
empty function without setting breakpoints on every function.
There is a secondary problem in that ISO C has an expectation that functions
are at a unique address. This would break down if the user stores the address
of a function into a pointer, and then compares the pointer for equality
against another function (which is also empty).
--
Michael Meissner, Red Hat, Inc.
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work: meissner@redhat.com phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org fax: +1 978-692-4482