Page MenuHomePhabricator

[RISCV][compiler-rt] Add __riscv_restore_tailcall_N entry points
AcceptedPublic

Authored by edward-jones on Nov 18 2020, 8:36 AM.

Details

Summary

This introduces entry points to compiler-rt which allow the -msave-restore optimization to be applied to tail calls as well as ordinary calls.

Diff Detail

Event Timeline

edward-jones created this revision.Nov 18 2020, 8:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 18 2020, 8:36 AM
Herald added subscribers: Restricted Project, frasercrmck, NickHung and 28 others. · View Herald Transcript

Updated the implementation to closely match the __riscv_restore_N entry points.

lenary removed a subscriber: lenary.Apr 19 2021, 11:29 AM

It was pointed out in the RISC-V LLVM sync-up that these entry points could be in separate sections to allow -gc-sections to remove any unnecessary entry points. This would mitigate the code size penalty for small programs as only the required entry points would be pulled in, however it would require the linker script to behave and not reorder the sections, and would require some changes to ensure that the fallthrough function does not accidentally get collected.

Jim Wilson's [draft GNU implementation][1] has CFI directives. IIRC we also didn't add them to the non-tail Compiler-RT implementation but it would be good to take this opportunity to add them here.

[1]: https://github.com/riscv-non-isa/riscv-toolchain-conventions/files/7800168/sibling-call-save-restore.txt

compiler-rt/lib/builtins/riscv/restore_tailcall.S
104

Remove the "/9/8"?

Added CFI directives to the __riscv_restore_tailcall_<N> functions

luismarques accepted this revision.Jan 19 2022, 3:06 PM

LGTM. (Don't forget to address my old nit comment, "Remove the /9/8", before merging)
Let's discuss on D91719 when this work should be merged.

compiler-rt/lib/builtins/riscv/restore_tailcall.S
2

Maybe update the description to reflect tail call, if it fits.

This revision is now accepted and ready to land.Jan 19 2022, 3:06 PM