aboutsummaryrefslogtreecommitdiff
path: root/libcxx/include/__algorithm/comp.h
diff options
context:
space:
mode:
authorEllis Hoag <ellis.sparky.hoag@gmail.com>2025-10-03 09:38:10 -0700
committerGitHub <noreply@github.com>2025-10-03 16:38:10 +0000
commitd0e98909d28be377408b1e52fa35423a2236036c (patch)
tree53eaae4425254b84169d638b0b33c9ed43c3bb3c /libcxx/include/__algorithm/comp.h
parent3add28bf3f53c01d1f321ae061ecbfdc83b1172e (diff)
downloadllvm-d0e98909d28be377408b1e52fa35423a2236036c.zip
llvm-d0e98909d28be377408b1e52fa35423a2236036c.tar.gz
llvm-d0e98909d28be377408b1e52fa35423a2236036c.tar.bz2
[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.
Diffstat (limited to 'libcxx/include/__algorithm/comp.h')
0 files changed, 0 insertions, 0 deletions