[all-commits] [llvm/llvm-project] cd3486: [lld-macho] Implement ObjC category merging (-objc...
alx32 via All-commits
all-commits at lists.llvm.org
Tue Mar 19 13:14:51 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cd34860705607ba804e20753f3ef4f2d4392df57
https://github.com/llvm/llvm-project/commit/cd34860705607ba804e20753f3ef4f2d4392df57
Author: alx32 <103613512+alx32 at users.noreply.github.com>
Date: 2024-03-19 (Tue, 19 Mar 2024)
Changed paths:
M lld/MachO/Driver.cpp
M lld/MachO/InputSection.h
M lld/MachO/ObjC.cpp
M lld/MachO/ObjC.h
M lld/MachO/Options.td
A lld/test/MachO/objc-category-merging-complete-test.s
A lld/test/MachO/objc-category-merging-extern-class-minimal.s
Log Message:
-----------
[lld-macho] Implement ObjC category merging (-objc_category_merging) (#85727)
This change adds a flag to lld to enable category merging for MachoO +
ObjC.
It adds the '-objc_category_merging' flag for enabling this option and
uses the existing '-no_objc_category_merging' flag for disabling it.
In ld64, this optimization is enabled by default, but in lld, for now,
we require explicitly passing the '-objc_category_merging' flag in order
to enable it.
Behavior: if in the same link unit, multiple categories are extending
the same class, then they get merged into a single category.
Ex: Cat1(method1+method2,protocol1) + Cat2(method3+method4,protocol2,
property1) = Cat1_2(method1+method2+method3+method4,
protocol1+protocol2, property1)
Notes on implementation decisions made in this diff:
There is a possibility to further improve the current implementation by
directly merging the category data into the base class (if the base
class is present in the link unit) - this improvement may be done as a
follow-up. This improved functionality is already present in ld64.
We do the merging on the raw inputSections - after dead-stripping
(categories can't be dead stripped anyway).
The changes are mostly self-contained to ObjC.cpp, except for adding a
new flag (linkerOptimizeReason) to ConcatInputSection and StringPiece to
mark that this data has been optimized away. Another way to do it would
have been to just mark the pieces as not 'live' but this would cause the
old symbols to show up in the linker map as being dead-stripped - even
if dead-stripping is disabled. This flag allows us to match the ld64
behavior.
Note: This is a re-land of
https://github.com/llvm/llvm-project/pull/82928 after fixing using
already freed memory in `generatedSectionData`. This issue was detected
by ASAN build.
---------
Co-authored-by: Alex B <alexborcan at meta.com>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list