From: Alan Modra Date: Fri, 18 Sep 2020 13:33:11 +0000 (+0930) Subject: [RS6000] PR97107, libgo fails to build for power10 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=199baa71f7a6c8f255afdda03cd3b2644f8f0fcd;p=gcc.git [RS6000] PR97107, libgo fails to build for power10 Calls from split-stack code to non-split-stack code need to expand mapped stack memory via __morestack. Even tail calls. __morestack is quite a surprising function on powerpc in that it calls back to its caller, and a tail call will continue running in the context of extra mapped stack. PR target/97107 * config/rs6000/rs6000-internal.h (struct rs6000_stack): Improve calls_p comment. * config/rs6000/rs6000-logue.c (rs6000_stack_info): Likewise. (rs6000_expand_split_stack_prologue): Emit the prologue for functions that make a sibling call. --- diff --git a/gcc/config/rs6000/rs6000-internal.h b/gcc/config/rs6000/rs6000-internal.h index 9caef013a71..32681b6cece 100644 --- a/gcc/config/rs6000/rs6000-internal.h +++ b/gcc/config/rs6000/rs6000-internal.h @@ -32,7 +32,7 @@ typedef struct rs6000_stack { int cr_save_p; /* true if the CR reg needs to be saved */ unsigned int vrsave_mask; /* mask of vec registers to save */ int push_p; /* true if we need to allocate stack space */ - int calls_p; /* true if the function makes any calls */ + int calls_p; /* true if there are non-sibling calls */ int world_save_p; /* true if we're saving *everything*: r13-r31, cr, f14-f31, vrsave, v20-v31 */ enum rs6000_abi abi; /* which ABI to use */ diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c index 0f88ec19929..d90cd5736e1 100644 --- a/gcc/config/rs6000/rs6000-logue.c +++ b/gcc/config/rs6000/rs6000-logue.c @@ -714,7 +714,7 @@ rs6000_stack_info (void) info->altivec_size = 16 * (LAST_ALTIVEC_REGNO + 1 - info->first_altivec_reg_save); - /* Does this function call anything? */ + /* Does this function call anything (apart from sibling calls)? */ info->calls_p = (!crtl->is_leaf || cfun->machine->ra_needs_full_frame); /* Determine if we need to save the condition code registers. */ @@ -5479,7 +5479,18 @@ rs6000_expand_split_stack_prologue (void) gcc_assert (flag_split_stack && reload_completed); if (!info->push_p) - return; + { + /* We need the -fsplit-stack prologue for functions that make + tail calls. Tail calls don't count against crtl->is_leaf. + Note that we are called inside a sequence. get_insns will + just return that (as yet empty) sequence, so instead we + access the function rtl with get_topmost_sequence. */ + for (insn = get_topmost_sequence ()->first; insn; insn = NEXT_INSN (insn)) + if (CALL_P (insn)) + break; + if (!insn) + return; + } if (global_regs[29]) {