-
-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement --icf=safe
#484
Comments
|
I'll try to implement this next week. |
Closes: rui314#484 Signed-off-by: Tatsuyuki Ishi <[email protected]>
I filed a feature request to GCC to ask if GCC can support |
@ishitatsuyuki Are you interested in adding a |
Sure. Not really familiar with the GNU codebase, but I could certainly try that. |
Nice! Then please go ahead and send a patch to GNU binutils. I'm totally unfamiliar with binutils too. Let me reopen this issue to track this feature request on our side. |
I've submitted the first revision of the patch to binutils, and I'm currently addressing the review comments. One of the topics raised was that .llvm_addrsig's design doesn't work well with
It doesn't look like we're receiving strong objection against adding the LLVM extensions in binutils yet, but we need to be aware that adopting .llvm_addrsig might not be the best for various ELF toolchain compatibility. |
Identical Code Folding (ICF) is a powerful optimization to reduce the size of a linker output. It merges functions that happen to be compiled to the identical machine code that behave exactly the same.
The downside of doing this is the optimization per se violates the specification of the C/C++ language specs. In these languages, taking pointers of two distinctive functions must result in two non-equivalent pointer values. However, if we optimize two distinctive functions into a single function, that resulting two pointers will have the same value.
Currently, mold supports only
--icf=all
. That instructs the linker to do the optimization anyway.Other linkers, notably LLVM lld, supports
--icf=safe
. It uses.llvm_addrsig
sections to identify functions that are safe to merge. Functions that are not mentioned in the section are not address-taken (no one takes its pointer), so they are safe to merge.We should support
--icf=safe
in the same manner as LLVM lld.The text was updated successfully, but these errors were encountered: