nocchijiang wrote:

I'm not comfortable with direct calls bypassing the thunk by default. At the 
very least it should be behind a flag. These functions get a thunk because 
their address is significant, and that address is also where tools act on the 
function: a breakpoint, a DTrace pid entry probe, or an inline hook patching 
its entry. Today all of them see every call. With this change they only see 
calls through a pointer, so the same function behaves differently depending on 
how it's called.

Some of the cost described in the description comes from where the thunks are 
placed. They're appended after every other input section, so without an order 
file a call to a thunk-folded function first jumps to the end of `__text`, 
which could be a long jump in a large binary. I have a patch that instead puts 
each thunk where the function it replaces was in the input order. The caller's 
jump then reaches a thunk at the original function's distance.

I also have another patch ready that keeps fewer functions address-significant. 
Safe ICF applies Apple ld's address-taken heuristic when `__llvm_addrsig` is 
missing or marks a function. A function then stays unique only if it's exported 
or something other than a branch references it. That should noticeably reduce 
the number of thunks, and with them the calls this PR is trying to shorten.

https://github.com/llvm/llvm-project/pull/239472
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to