This makes the TOC register save a component. If -msave-toc-indirect is not explicitly disabled, it enables it, and then moves the prologue code generated for that to a better place. So far this only matters for indirect calls (for direct calls the save is done in the PLT stub). The restore is always done directly after the bl insn (the compiler generates a nop there, the linker replaces it with a load).
- config/rs6000/rs6000.c (machine_function): Add a bool, "toc_is_wrapped_separately". (rs6000_option_override_internal): Enable OPTION_MASK_SAVE_TOC_INDIRECT if it wasn't explicitly set or unset, we are optimizing for speed, and doing separate shrink-wrapping. (rs6000_get_separate_components): Enable the TOC component if saving the TOC register in the prologue. (rs6000_components_for_bb): Handle the TOC component. (rs6000_emit_prologue_components): Store the TOC register where needed. (rs6000_set_handled_components): Mark TOC as handled, if handled. (rs6000_emit_prologue): Don't save the TOC if that is already done.
bc889798b8f rs6000: Separate shrink-wrapping for the TOC register
gcc/ChangeLog | 14 ++++++++++++++
gcc/config/rs6000/rs6000.c | 33 ++++++++++++++++++++++++++++++++-
2 files changed, 46 insertions(+), 1 deletion(-)