+2020-04-27 Xiong Hu Luo <luoxhu@linux.ibm.com>
+
+ PR target/91518
+ * config/rs6000/rs6000-logue.c (frame_pointer_needed_indeed):
+ New variable.
+ (rs6000_emit_prologue_components):
+ Check with frame_pointer_needed_indeed.
+ (rs6000_emit_epilogue_components): Likewise.
+ (rs6000_emit_prologue): Likewise.
+ (rs6000_emit_epilogue): Set frame_pointer_needed_indeed.
+
2020-04-25 David Edelsohn <dje.gcc@gmail.com>
* config/rs6000/rs6000-logue.c (rs6000_stack_info): Don't push a
static rs6000_stack_t stack_info;
+/* Set if HARD_FRAM_POINTER_REGNUM is really needed. */
+static bool frame_pointer_needed_indeed = false;
/* Label number of label created for -mrelocatable, to call to so we can
get the address of the GOT section */
rs6000_emit_prologue_components (sbitmap components)
{
rs6000_stack_t *info = rs6000_stack_info ();
- rtx ptr_reg = gen_rtx_REG (Pmode, frame_pointer_needed
- ? HARD_FRAME_POINTER_REGNUM
- : STACK_POINTER_REGNUM);
+ rtx ptr_reg = gen_rtx_REG (Pmode, frame_pointer_needed_indeed
+ ? HARD_FRAME_POINTER_REGNUM
+ : STACK_POINTER_REGNUM);
machine_mode reg_mode = Pmode;
int reg_size = TARGET_32BIT ? 4 : 8;
rs6000_emit_epilogue_components (sbitmap components)
{
rs6000_stack_t *info = rs6000_stack_info ();
- rtx ptr_reg = gen_rtx_REG (Pmode, frame_pointer_needed
- ? HARD_FRAME_POINTER_REGNUM
- : STACK_POINTER_REGNUM);
+ rtx ptr_reg = gen_rtx_REG (Pmode, frame_pointer_needed_indeed
+ ? HARD_FRAME_POINTER_REGNUM
+ : STACK_POINTER_REGNUM);
machine_mode reg_mode = Pmode;
int reg_size = TARGET_32BIT ? 4 : 8;
&& (lookup_attribute ("no_split_stack",
DECL_ATTRIBUTES (cfun->decl))
== NULL));
-
+
+ frame_pointer_needed_indeed
+ = frame_pointer_needed && df_regs_ever_live_p (HARD_FRAME_POINTER_REGNUM);
+
/* Offset to top of frame for frame_reg and sp respectively. */
HOST_WIDE_INT frame_off = 0;
HOST_WIDE_INT sp_off = 0;
}
/* Set frame pointer, if needed. */
- if (frame_pointer_needed)
+ if (frame_pointer_needed_indeed)
{
insn = emit_move_insn (gen_rtx_REG (Pmode, HARD_FRAME_POINTER_REGNUM),
sp_reg_rtx);
}
/* If we have a frame pointer, we can restore the old stack pointer
from it. */
- else if (frame_pointer_needed)
+ else if (frame_pointer_needed_indeed)
{
frame_reg_rtx = sp_reg_rtx;
if (DEFAULT_ABI == ABI_V4)