The option from D116070 does not work as intended and will not be needed when
hidden visibility is used. A function needs ENDBR if it may be reached
indirectly. If we make ThinLTO combine the address-taken property (close to
!GV.use_empty() && !GV.hasAtLeastLocalUnnamedAddr()), then the condition can
be expressed with:
AddressTaken || (!F.hasLocalLinkage() && (VisibleToRegularObj || !F.hasHiddenVisibility()))
The current F.hasAddressTaken() condition does not take into acount of
address-significance in another bitcode file or ELF relocatable file.
For the Linux kernel, it uses relocatable linking. lld/ELF uses a
conservative approach by setting all VisibleToRegularObj to true.
Using the non-relocatable semantics may under-estimate
VisibleToRegularObj. As @pcc mentioned on
https://github.com/ClangBuiltLinux/linux/issues/1737#issuecomment-1343414686
, we probably need a symbol list to supply additional
VisibleToRegularObj symbols (not part of the relocatable LTO link).