[PATCH] D143137: [RISCV] Permit tail call to an externally-defined function with weak linkage
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 07:58:33 PST 2023
reames added a comment.
I don't believe this is, in general, legal to do for RISCV psABI. The problem is that a weak symbol can resolve to the address 0, and that 0 may be outside the addressable range of a pcrelative call/branch sequence. There is disagreement between the linkers as to whether such sequences should be rewritten to a different instruction sequence. For non-tail calls, we end up emitting an explicit load through the GOT and call sequence.
Note that this concern does not apply in all code models. (I believe medlow is not effected, but double check!) You can look at the code which emits the GOT lookup for general calls, and there's probably cases where we can emit the direct tail call. We just need to restrict it appropriately.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143137/new/
https://reviews.llvm.org/D143137
More information about the llvm-commits
mailing list