[all-commits] [llvm/llvm-project] d0e989: [lld][MachO] Tail merge strings (#161262)
Ellis Hoag via All-commits
all-commits at lists.llvm.org
Fri Oct 3 09:38:34 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d0e98909d28be377408b1e52fa35423a2236036c
https://github.com/llvm/llvm-project/commit/d0e98909d28be377408b1e52fa35423a2236036c
Author: Ellis Hoag <ellis.sparky.hoag at gmail.com>
Date: 2025-10-03 (Fri, 03 Oct 2025)
Changed paths:
M lld/MachO/Config.h
M lld/MachO/Driver.cpp
M lld/MachO/Options.td
M lld/MachO/SyntheticSections.cpp
M lld/docs/ReleaseNotes.rst
A lld/test/MachO/cstring-tailmerge-objc.s
A lld/test/MachO/cstring-tailmerge.s
A lld/test/MachO/order-file-cstring-tailmerge.s
Log Message:
-----------
[lld][MachO] Tail merge strings (#161262)
Add the flag `--tail-merge-strings` to enable tail merging of cstrings.
For example, if we have strings `mystring\0` and `ring\0`, we could
place `mystring\0` at address `0x1000` and `ring\0` at address `0x1004`
and have them share the same underlying data.
It turns out that many ObjC method names can be tail merged. For
example, `error:` and `doFoo:error:`. On a large iOS binary, we saw
nearly a 15% size improvement in the `__TEXT__objc_methname` section and
negligible impact on link time.
```
$ bloaty --domain=vm merged.o.stripped -- base.o.stripped
VM SIZE
--------------
+95% +5.85Ki [__TEXT]
-2.4% -239Ki __TEXT,__cstring
-14.5% -710Ki __TEXT,__objc_methname
-1.0% -944Ki TOTAL
```
Tail merging for MachO was originally removed in
https://github.com/llvm/llvm-project/commit/7c269db779ff3950bac2e25ea78b14b4e2b8b247.
The previous implementation used `StringTableBuilder`, but that was
removed in
https://github.com/llvm/llvm-project/commit/4308f031cd0c679c539914608134b9c8046743b3
to ensure deduplicated strings are aligned correctly. This
implementation ensures that tail merged strings are also aligned
correctly.
Special thanks to nocchijiang for pointing this out in
https://github.com/llvm/llvm-project/pull/158720#issuecomment-3310416030.
Depends on https://github.com/llvm/llvm-project/pull/161253.
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