Commit 5a978b9f by Segher Boessenkool Committed by Segher Boessenkool

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  <segher@kernel.crashing.org>

	* 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.

From-SVN: r229552
parent 823bb054
2015-10-29 Segher Boessenkool <segher@kernel.crashing.org> 2015-10-29 Segher Boessenkool <segher@kernel.crashing.org>
* 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 <segher@kernel.crashing.org>
* lra-constraints.c (process_address_1): Handle (mem:BLK (scratch)) * lra-constraints.c (process_address_1): Handle (mem:BLK (scratch))
by ignoring it. by ignoring it.
...@@ -22016,6 +22016,27 @@ save_reg_p (int r) ...@@ -22016,6 +22016,27 @@ save_reg_p (int r)
return !call_used_regs[r] && df_regs_ever_live_p (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 /* Return the first fixed-point register that is required to be
saved. 32 if none. */ saved. 32 if none. */
...@@ -22033,7 +22054,7 @@ first_reg_to_save (void) ...@@ -22033,7 +22054,7 @@ first_reg_to_save (void)
&& ((DEFAULT_ABI == ABI_V4 && flag_pic != 0) && ((DEFAULT_ABI == ABI_V4 && flag_pic != 0)
|| (DEFAULT_ABI == ABI_DARWIN && flag_pic) || (DEFAULT_ABI == ABI_DARWIN && flag_pic)
|| (TARGET_TOC && TARGET_MINIMAL_TOC)) || (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; first_reg = RS6000_PIC_OFFSET_TABLE_REGNUM;
#if TARGET_MACHO #if TARGET_MACHO
...@@ -24232,27 +24253,6 @@ rs6000_emit_move_from_cr (rtx reg) ...@@ -24232,27 +24253,6 @@ rs6000_emit_move_from_cr (rtx reg)
emit_insn (gen_movesi_from_cr (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. */ /* Return whether the split-stack arg pointer (r12) is used. */
static bool static bool
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment