[PATCH] D17529: ELF: Implement ICF.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 17:11:32 PST 2016
ruiu created this revision.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
This patch is in my queue for a long period of time, so I'd like
to flush this although it is not still compatible with most C++
This patch implements the same algorithm as LLD/COFF's ICF. I'm
not going to repeat the same description about how it works, so you
want to read the comment in ICF.cpp in this patch. This algorithm
should be more powerful than GNU gold ICF algorithm. It can even
merge mutually-recursive functions (which is harder than one might
The lacking feature is "safe" version of ICF. This merges all
identical sections. That is not compatible with C/C++ language
requirement that two distinct functions must not have the address.
I think violation this rule breaks many C++ ABIs.
GNU gold implements so-called "safe ICF" that identifies functions
that are safe to merge by heuristics -- for example, gold think
that constructors are safe to merge because there is no way to
take an address of a constructor in C++. We have a different idea
which David Majnemer suggested, which is to add NOPs at beginning
of merged functions so that two or more pointers can have distinct
values. We can do whichever we want, but this patch does not
include neither one.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 27931 bytes
Desc: not available
More information about the llvm-commits