[llvm-branch-commits] [lld] [lld][MachO] Change direct branch targets to ICF bodies (PR #239472)

Zhaoxuan Jiang via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Nov 9 19:10:24 PST 2026


nocchijiang wrote:

That works when the debugger has the dSYM, but it isn't how we debug release packages. Loading the dSYM slows LLDB down drastically, so we usually debug without it: we look up the function's address in the link map and set an address breakpoint there. `--keep-icf-stabs` only changes the stabs, so the map still lists bar at the thunk, while direct calls no longer go there. The map ends up misleading us, with or without `--keep-icf-stabs,` so I think this needs the flag regardless.

On inline hooks, I think we mean different things. Ours aren't fishhook-style hooks that rebind symbol pointers, which `needsBinding()` would cover. At debug time we modify executable pages and patch the code at the function's address; for a thunk-folded function, that's the thunk's branch. We do this for an in-house profiler built on JIT, which we use for flame graphs, function hotness and similar. We don't use compile-time instrumentation, because that would need a rebuild of the whole project with all source available. A call only reaches the patched code if it goes through the function's address, so with this PR, direct calls go straight to the shared body and the profiler never sees them.

DTrace's pid provider works like an address breakpoint: it traps the function's entry address. I mentioned it as another example, but we don't rely on it; the two cases above are the ones that matter to us.

https://github.com/llvm/llvm-project/pull/239472


More information about the llvm-branch-commits mailing list