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


On 15 Sep 2006 09:27:32 -0700, Ian Lance Taylor <iant@google.com> wrote:
"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.

Yup, that's what i've got. It works when they generate value wise identical code (effectively it allows as different of code your value numbering can determine is the same). There are of course, collisions possible in the hash, and in the absolute worst case, it is possible to end up with no warning but wrong results. In particular, if you get a collision and the length of the functions happens to be the same, i don't believe the linker will complain about the symbol size changing.


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