This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Merging identical functions in GCC


"Steven Bosscher" <stevenb.gcc@gmail.com> writes:

> Isn't this what you describe here the same as COMDAT?

Not exactly.  COMDAT means that the compiler can generate multiple
instances of, say, the list<int> functions, and only one version will
be included in the final executable.  However, if you use both
list<int> and list<long>, they will both wind up in the executable.

The proposal here is that in the case where list<int> and list<long>
generate identical code, only one version winds up in the executable,
with two symbols associated with it.

I think Danny has a 75% implementation based on hashing the RTL for a
section and using that to select the COMDAT section signature.  Or the
hashing can be done in the linker, but it still needs compiler help to
know when it is permissible.

Ian

> On 9/15/06, Michael Popov <pmike2001@mail.ru> wrote:
> > Hello!
> >
> > There is very good blog post about the problem:
> > http://vladimir_prus.blogspot.com/2005/03/duplicate-function-bodies.html
> > > A couple of days ago I've learned that the Microsoft linker can merge
> > > functions with binary identical bodies. Looks rather good idea,
> >  > especially with templates, and it seems that gcc does not implement this.
> >
> > Will GCC support this feature?
> > It might be very useful in some cases, reduce code size and locality.
> >
> >
> > Some info about possible problems can be found here:
> > http://blogs.msdn.com/oldnewthing/archive/2005/03/22/400373.aspx
> >
> > So, due to incompatibilities with debugging and C/C++ standards
> > this feature should be optional and disabled by default.
> >
> >
> > Best regards,
> > Michael
> >


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]