Not logged in
Log in now
Create an account
Subscribe to LWN
Pencil, Pencil, and Pencil
Dividing the Linux desktop
LWN.net Weekly Edition for June 13, 2013
A report from pgCon 2013
Little things that matter in language design
But in practice does it actually do so?
> every time one #includes <cstream>, the compiler generates several stubs which turn out to be identical and unnecessarily duplicated
I assume you mean <iostream>, and AFAIK LTO doesn't change that situation at all (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44952 for a suggestion to make it do so, and other suggestions that wouldn't rely on LTO.)
Link-time optimization for the kernel
Posted Aug 22, 2012 13:37 UTC (Wed) by andikleen (guest, #39006)
There were some linker based approaches for this though (it only really needs a checksum per function)
Posted Aug 22, 2012 18:19 UTC (Wed) by stevenb (guest, #11536)
// Identical Code Folding Algorithm
// Detecting identical functions is done here and the basic algorithm
// is as follows. A checksum is computed on each foldable section using
// its contents and relocations. If the symbol name corresponding to
// a relocation is known it is used to compute the checksum. If the
// symbol name is not known the stringified name of the object and the
// section number pointed to by the relocation is used. The checksums
// are stored as keys in a hash map and a section is identical to some
// other section if its checksum is already present in the hash map.
// Checksum collisions are handled by using a multimap and explicitly
// checking the contents when two sections have the same checksum.
// However, two functions A and B with identical text but with
// relocations pointing to different foldable sections can be identical if
// the corresponding foldable sections to which their relocations point to
// turn out to be identical. Hence, this checksumming process must be
// done repeatedly until convergence is obtained.
Whether this works with LTO, I don't know. And I suppose it requires -ffunction-sections but I'm not sure about that either.
Not a very helpful post, sorry ;-)
Posted Aug 22, 2012 22:43 UTC (Wed) by andikleen (guest, #39006)
Posted Aug 23, 2012 10:05 UTC (Thu) by jwakely (subscriber, #60262)
Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds