From: segher Date: Thu, 29 Oct 2015 19:27:22 +0000 (+0000) Subject: rs6000: Save the PIC reg when needed X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=41c3cc7c2c643e90c72e3adaf52d5e170d501582;p=thirdparty%2Fgcc.git rs6000: Save the PIC reg when needed The PIC reg (r30) needs to be saved whenever the prologue sets it up, not just if it is used elsewhere in the function. Without this patch the prologue for such a function will modify r30 without saving it first, leading to disaster back in its callers. This happened in the testsuite for -m32 libgfortran and libstdc++, bootstrapped with -mlra, many hundred times. 2015-10-29 Segher Boessenkool * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Move this function earlier in the file. (first_reg_to_save): Use rs6000_reg_live_or_pic_offset_p instead of df_regs_ever_live_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@229552 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 75ba2e83d449..50fc56f022d1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2015-10-29 Segher Boessenkool + + * config/rs6000/rs6000.c (rs6000_reg_live_or_pic_offset_p): Move this + function earlier in the file. + (first_reg_to_save): Use rs6000_reg_live_or_pic_offset_p instead of + df_regs_ever_live_p. + 2015-10-29 Segher Boessenkool * lra-constraints.c (process_address_1): Handle (mem:BLK (scratch)) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 21b43476181e..bbdd1425eebb 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -22016,6 +22016,27 @@ save_reg_p (int r) return !call_used_regs[r] && df_regs_ever_live_p (r); } +/* Determine whether the gp REG is really used. */ + +static bool +rs6000_reg_live_or_pic_offset_p (int reg) +{ + /* If the function calls eh_return, claim used all the registers that would + be checked for liveness otherwise. This is required for the PIC offset + register with -mminimal-toc on AIX, as it is advertised as "fixed" for + register allocation purposes in this case. */ + + return (((crtl->calls_eh_return || df_regs_ever_live_p (reg)) + && (!call_used_regs[reg] + || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM + && !TARGET_SINGLE_PIC_BASE + && TARGET_TOC && TARGET_MINIMAL_TOC))) + || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM + && !TARGET_SINGLE_PIC_BASE + && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0) + || (DEFAULT_ABI == ABI_DARWIN && flag_pic)))); +} + /* Return the first fixed-point register that is required to be saved. 32 if none. */ @@ -22033,7 +22054,7 @@ first_reg_to_save (void) && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0) || (DEFAULT_ABI == ABI_DARWIN && flag_pic) || (TARGET_TOC && TARGET_MINIMAL_TOC)) - && df_regs_ever_live_p (RS6000_PIC_OFFSET_TABLE_REGNUM)) + && rs6000_reg_live_or_pic_offset_p (RS6000_PIC_OFFSET_TABLE_REGNUM)) first_reg = RS6000_PIC_OFFSET_TABLE_REGNUM; #if TARGET_MACHO @@ -24232,27 +24253,6 @@ rs6000_emit_move_from_cr (rtx reg) emit_insn (gen_movesi_from_cr (reg)); } -/* Determine whether the gp REG is really used. */ - -static bool -rs6000_reg_live_or_pic_offset_p (int reg) -{ - /* If the function calls eh_return, claim used all the registers that would - be checked for liveness otherwise. This is required for the PIC offset - register with -mminimal-toc on AIX, as it is advertised as "fixed" for - register allocation purposes in this case. */ - - return (((crtl->calls_eh_return || df_regs_ever_live_p (reg)) - && (!call_used_regs[reg] - || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM - && !TARGET_SINGLE_PIC_BASE - && TARGET_TOC && TARGET_MINIMAL_TOC))) - || (reg == RS6000_PIC_OFFSET_TABLE_REGNUM - && !TARGET_SINGLE_PIC_BASE - && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0) - || (DEFAULT_ABI == ABI_DARWIN && flag_pic)))); -} - /* Return whether the split-stack arg pointer (r12) is used. */ static bool