Re: Merging identical functions in GCC

2006-09-16 Thread Michael Popov
Daniel Berlin wrote: Actually, even for non-POD types, it catches a lot of templatized member functions that mainly depend on size (but they are still container classes). Just another ( maybe stupid :-) ) idea. What about "partial merge"? static int x = 0; void a() { printf( "aaa" ); x

Re: Merging identical functions in GCC

2006-09-16 Thread Michael Popov
Mark Mitchell wrote: Anyhow, I think that a combination of compiler/linker help and programmer help are useful. There are some cases where you can do this automatically, and others where you might need programmer help. Just as -ffast-math is useful, so might -fmerge-functions or __attribute_

Re: Merging identical functions in GCC

2006-09-15 Thread Michael Popov
Daniel Berlin wrote: 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 com

Re: Merging identical functions in GCC

2006-09-15 Thread Michael Popov
Steven Bosscher wrote: Isn't this what you describe here the same as COMDAT? Well, MS VC have an option "enable COMDAT folding" - which turns ON merging of identical functions. BTW, this is linker option... should it be addressed to GCC's LTO? I'm not sure if function body is equivalent to "COM

Merging identical functions in GCC

2006-09-15 Thread Michael Popov
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