This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: empty function optimizations
- To: ken at gesn dot com (Ken Clark)
- Subject: Re: empty function optimizations
- From: Joe Buck <jbuck at racerx dot synopsys dot com>
- Date: Tue, 11 Jul 2000 13:15:54 -0700 (PDT)
- Cc: gcc at gcc dot gnu dot org
> 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.
I would recommend explicitly factoring out the common code. Partial
specialization can be your friend here.
> Would collecting all the identical code at link time be as easy as it
> sounds, or are there complications?
Some conforming programs would break, but these are fairly obscure (e.g.
programs that compare function pointers). Debugging might get harder.
But if you factor out common code, you can get greater savings than the
compiler can find and your gains are portable.