summaryrefslogtreecommitdiff
path: root/lld/MachO/MapFile.cpp
diff options
context:
space:
mode:
authoralx32 <103613512+alx32@users.noreply.github.com>2024-09-05 16:36:21 -0700
committerGitHub <noreply@github.com>2024-09-05 16:36:21 -0700
commitd1756165a9066f907b88d51dd8e3ffee15a8cc1e (patch)
tree401a769f249c2554d4080624497a152e0c611e97 /lld/MachO/MapFile.cpp
parent1be9a80768a03ea9bd2bfbb03762b2bc3c350007 (diff)
[lld-macho][arm64] Enhance safe ICF with thunk-based deduplication (#106573)
Currently, our `safe` ICF mode only merges non-address-significant code, leaving duplicate address-significant functions in the output. This patch introduces `safe_thunks` ICF mode, which keeps a single master copy of each function and replaces address-significant duplicates with thunks that branch to the master copy. Currently `--icf=safe_thunks` is only supported for `arm64` architectures. **Perf stats for a large binary:** | ICF Option | Total Size | __text Size | __unwind_info | % total | |-------------------|------------|-------------|---------------------|---------------------------| | `--icf=none` | 91.738 MB | 55.220 MB | 1.424 MB | 0% | | `--icf=safe` | 85.042 MB | 49.572 MB | 1.168 MB | 7.30% | | `--icf=safe_thunks` | 84.650 MB | 49.219 MB | 1.143 MB | 7.72% | | `--icf=all` | 82.060 MB | 48.726 MB | 1.111 MB | 10.55% | So overall we can expect a `~0.45%` binary size reduction for a typical large binary compared to the `--icf=safe` option. **Runtime:** Linking the above binary took ~10 seconds. Comparing the link performance of --icf=safe_thunks vs --icf=safe, a ~2% slowdown was observed.
Diffstat (limited to 'lld/MachO/MapFile.cpp')
-rw-r--r--lld/MachO/MapFile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp
index 5bcaeca48da2..9c0621622ae2 100644
--- a/lld/MachO/MapFile.cpp
+++ b/lld/MachO/MapFile.cpp
@@ -156,7 +156,7 @@ static void printNonLazyPointerSection(raw_fd_ostream &os,
}
static uint64_t getSymSizeForMap(Defined *sym) {
- if (sym->wasIdenticalCodeFolded)
+ if (sym->identicalCodeFoldingKind == Symbol::ICFFoldKind::Body)
return 0;
return sym->size;
}