[llvm] [AArch64] Use a frame record for non-leaf outlined functions on MachO (PR #213711)

Zhaoxuan Jiang via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 9 22:30:00 PDT 2026


nocchijiang wrote:

> 2. Cost model. The +4 is now charged only when the frame record is selected, for the extra `mov x29, sp`, not unwind metadata. Modeling the unwind info itself is harder. ICF folds outlined functions and their entries, and both `__eh_frame` and `__unwind_info` are structured, so one more entry does not cost a fixed number of bytes. I tried a few tuning knobs and did not find a clear direction, so I have left it out here as before.

I ran the same kind of tuning experiments downstream and also found no clear direction - it's part of why I never upstreamed my patch. Since we've independently hit the same wall, I'm fine with leaving it unmodeled here.

> 3. The extra `mov x29, sp`. I do not think runtime cost is the concern, since it is one cheap ALU op and outlining can be kept off hot code anyway. With compact unwind, ICF can fold these functions in LLD today, saving `__text` size and potentially improving page faults at start-up. It should also make unwinding cheaper, potentially improving performance for backtraces and profilers.

My worry was the accumulated 4 bytes per affected outlined function regressing startup page faults. But with 16K pages on Darwin, it takes 4K affected outlined functions in the startup working set to add a single page. I was probably overthinking it.

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


More information about the llvm-commits mailing list