Commit d0b2f831 by Richard Earnshaw Committed by Richard Earnshaw

re PR rtl-optimization/57708 (function clobbers callee saved register on ARM)

	PR rtl-optimization/57708
	* recog.c (peep2_find_free_register): Validate all regs in a
	multi-reg mode.

From-SVN: r201501
parent 4b7dff77
2013-08-05 Richard Earnshaw <rearnsha@arm.com>
PR rtl-optimization/57708
* recog.c (peep2_find_free_register): Validate all regs in a
multi-reg mode.
2013-08-05 Jan Hubicka <jh@suse.cz> 2013-08-05 Jan Hubicka <jh@suse.cz>
PR lto/57602 PR lto/57602
......
...@@ -3124,32 +3124,53 @@ peep2_find_free_register (int from, int to, const char *class_str, ...@@ -3124,32 +3124,53 @@ peep2_find_free_register (int from, int to, const char *class_str,
regno = raw_regno; regno = raw_regno;
#endif #endif
/* Don't allocate fixed registers. */ /* Can it support the mode we need? */
if (fixed_regs[regno])
continue;
/* Don't allocate global registers. */
if (global_regs[regno])
continue;
/* Make sure the register is of the right class. */
if (! TEST_HARD_REG_BIT (reg_class_contents[cl], regno))
continue;
/* And can support the mode we need. */
if (! HARD_REGNO_MODE_OK (regno, mode)) if (! HARD_REGNO_MODE_OK (regno, mode))
continue; continue;
/* And that we don't create an extra save/restore. */
if (! call_used_regs[regno] && ! df_regs_ever_live_p (regno))
continue;
if (! targetm.hard_regno_scratch_ok (regno))
continue;
/* And we don't clobber traceback for noreturn functions. */
if ((regno == FRAME_POINTER_REGNUM || regno == HARD_FRAME_POINTER_REGNUM)
&& (! reload_completed || frame_pointer_needed))
continue;
success = 1; success = 1;
for (j = hard_regno_nregs[regno][mode] - 1; j >= 0; j--) for (j = 0; success && j < hard_regno_nregs[regno][mode]; j++)
{ {
/* Don't allocate fixed registers. */
if (fixed_regs[regno + j])
{
success = 0;
break;
}
/* Don't allocate global registers. */
if (global_regs[regno + j])
{
success = 0;
break;
}
/* Make sure the register is of the right class. */
if (! TEST_HARD_REG_BIT (reg_class_contents[cl], regno + j))
{
success = 0;
break;
}
/* And that we don't create an extra save/restore. */
if (! call_used_regs[regno + j] && ! df_regs_ever_live_p (regno + j))
{
success = 0;
break;
}
if (! targetm.hard_regno_scratch_ok (regno + j))
{
success = 0;
break;
}
/* And we don't clobber traceback for noreturn functions. */
if ((regno + j == FRAME_POINTER_REGNUM
|| regno + j == HARD_FRAME_POINTER_REGNUM)
&& (! reload_completed || frame_pointer_needed))
{
success = 0;
break;
}
if (TEST_HARD_REG_BIT (*reg_set, regno + j) if (TEST_HARD_REG_BIT (*reg_set, regno + j)
|| TEST_HARD_REG_BIT (live, regno + j)) || TEST_HARD_REG_BIT (live, regno + j))
{ {
...@@ -3157,6 +3178,7 @@ peep2_find_free_register (int from, int to, const char *class_str, ...@@ -3157,6 +3178,7 @@ peep2_find_free_register (int from, int to, const char *class_str,
break; break;
} }
} }
if (success) if (success)
{ {
add_to_hard_reg_set (reg_set, mode, regno); add_to_hard_reg_set (reg_set, mode, regno);
......
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