diff mbox

ARM: exclude fixed_regs for stack-alignment save/restore

Message ID CAB=4xhr=LajhskDQ3YHqXeU7Ddhma7-hTJXTYVZ77xEregzoWQ@mail.gmail.com
State New
Headers show

Commit Message

Roland McGrath July 17, 2012, 8:42 p.m. UTC
Richard, here is the patch against the current trunk, as I promised
last week in Prague.  Please apply.


Thanks,
Roland


gcc/
2012-07-17  Roland McGrath  <mcgrathr@google.com>

	* config/arm/arm.c (arm_get_frame_offsets): Never use a fixed register
	as the extra register to save/restore for stack-alignment padding.

Comments

Roland McGrath July 20, 2012, 8:21 p.m. UTC | #1
ping?
Richard Earnshaw July 24, 2012, 11:54 a.m. UTC | #2
On 17/07/12 21:42, Roland McGrath wrote:
> Richard, here is the patch against the current trunk, as I promised
> last week in Prague.  Please apply.
> 

Done.

I've tweaked the comments slightly, but the functional modification is
unchanged.

R.

> 
> Thanks,
> Roland
> 
> 
> gcc/
> 2012-07-17  Roland McGrath  <mcgrathr@google.com>
> 
> 	* config/arm/arm.c (arm_get_frame_offsets): Never use a fixed register
> 	as the extra register to save/restore for stack-alignment padding.
> 
> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
> index e2f625c..189f71e 100644
> --- a/gcc/config/arm/arm.c
> +++ b/gcc/config/arm/arm.c
> @@ -16121,7 +16121,12 @@ arm_get_frame_offsets (void)
>  	  else
>  	    for (i = 4; i <= (TARGET_THUMB1 ? LAST_LO_REGNUM : 11); i++)
>  	      {
> -		if ((offsets->saved_regs_mask & (1 << i)) == 0)
> +		/* While the gratuitous register save/restore is ordinarily
> +		   harmless, if a register is marked as fixed or global it
> +		   may be entirely forbidden by the system ABI to touch it,
> +		   so we should avoid those registers.  */
> +		if (!fixed_regs[i]
> +		    && (offsets->saved_regs_mask & (1 << i)) == 0)
>  		  {
>  		    reg = i;
>  		    break;
>
Roland McGrath July 24, 2012, 4:21 p.m. UTC | #3
Thanks muchly!
diff mbox

Patch

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index e2f625c..189f71e 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -16121,7 +16121,12 @@  arm_get_frame_offsets (void)
 	  else
 	    for (i = 4; i <= (TARGET_THUMB1 ? LAST_LO_REGNUM : 11); i++)
 	      {
-		if ((offsets->saved_regs_mask & (1 << i)) == 0)
+		/* While the gratuitous register save/restore is ordinarily
+		   harmless, if a register is marked as fixed or global it
+		   may be entirely forbidden by the system ABI to touch it,
+		   so we should avoid those registers.  */
+		if (!fixed_regs[i]
+		    && (offsets->saved_regs_mask & (1 << i)) == 0)
 		  {
 		    reg = i;
 		    break;