===================================================================
@@ -354,20 +354,22 @@ frob_update_context (struct _Unwind_Cont
/* We are in a plt call stub or r2 adjusting long branch stub,
before r2 has been saved. Keep REG_UNSAVED. */
}
- else if (pc[0] == 0x4E800421
- && pc[1] == 0xE8410028)
- {
- /* We are at the bctrl instruction in a call via function
- pointer. gcc always emits the load of the new r2 just
- before the bctrl. */
- _Unwind_SetGRPtr (context, 2, context->cfa + 40);
- }
else
{
unsigned int *insn
= (unsigned int *) _Unwind_GetGR (context, R_LR);
if (insn && *insn == 0xE8410028)
_Unwind_SetGRPtr (context, 2, context->cfa + 40);
+ else if (pc[0] == 0x4E800421
+ && pc[1] == 0xE8410028)
+ {
+ /* We are at the bctrl instruction in a call via function
+ pointer. gcc always emits the load of the new R2 just
+ before the bctrl so this is the first and only place
+ we need to use the stored R2. */
+ _Unwind_Word sp = _Unwind_GetGR (context, 1);
+ _Unwind_SetGRPtr (context, 2, sp + 40);
+ }
}
}
#endif
===================================================================
@@ -172,8 +172,6 @@ extern void rs6000_emit_epilogue (int);
extern void rs6000_emit_eh_reg_restore (rtx, rtx);
extern const char * output_isel (rtx *);
extern void rs6000_call_indirect_aix (rtx, rtx, rtx);
-extern bool rs6000_save_toc_in_prologue_p (void);
-
extern void rs6000_aix_asm_output_dwarf_table_ref (char *);
/* Declare functions in rs6000-c.c */
===================================================================
@@ -1178,6 +1178,7 @@ static void rs6000_conditional_register_
static void rs6000_trampoline_init (rtx, tree, rtx);
static bool rs6000_cannot_force_const_mem (enum machine_mode, rtx);
static bool rs6000_legitimate_constant_p (enum machine_mode, rtx);
+static bool rs6000_save_toc_in_prologue_p (void);
/* Hash table stuff for keeping track of TOC entries. */
@@ -20536,8 +20562,11 @@ rs6000_emit_prologue (void)
/* If we need to, save the TOC register after doing the stack setup. */
if (rs6000_save_toc_in_prologue_p ())
- emit_frame_save (sp_reg_rtx, sp_reg_rtx, reg_mode, TOC_REGNUM,
- 5 * reg_size, info->total_size);
+ {
+ rtx addr = gen_rtx_PLUS (Pmode, sp_reg_rtx, GEN_INT (5 * reg_size));
+ rtx mem = gen_frame_mem (reg_mode, addr);
+ emit_move_insn (mem, gen_rtx_REG (reg_mode, TOC_REGNUM));
+ }
}
/* Write function prologue. */
@@ -27798,7 +27829,7 @@ rs6000_call_indirect_aix (rtx value, rtx
if (TARGET_SAVE_TOC_INDIRECT && !cfun->calls_alloca
&& !cfun->calls_setjmp && !cfun->has_nonlocal_label
&& !cfun->can_throw_non_call_exceptions
- && ((flags_from_decl_or_type (cfun->decl) & ECF_NOTHROW) == ECF_NOTHROW))
+ && (flags_from_decl_or_type (cfun->decl) & ECF_NOTHROW) == ECF_NOTHROW)
cfun->machine->save_toc_in_prologue = true;
else
@@ -27834,13 +27865,12 @@ rs6000_call_indirect_aix (rtx value, rtx
insn = call_func (func_addr, flag, func_toc_mem, stack_toc_mem);
emit_call_insn (insn);
- return;
}
/* Return whether we need to always update the saved TOC pointer when we update
the stack pointer. */
-bool
+static bool
rs6000_save_toc_in_prologue_p (void)
{
return (cfun && cfun->machine && cfun->machine->save_toc_in_prologue);