diff mbox

S/390: Fix r6 vararg handling.

Message ID 56B48AEA.80308@linux.vnet.ibm.com
State New
Headers show

Commit Message

Andreas Krebbel Feb. 5, 2016, 11:43 a.m. UTC
On 02/04/2016 05:58 PM, Andreas Krebbel wrote:
> +static void
> +s390_register_info_set_ranges ()
> +{
> +  int i, j;
> +
> +  /* Find the first and the last save slot supposed to use the stack
> +     to set the restore range.
> +     Vararg regs might be marked as save to stack but only the
> +     call-saved regs really need restoring (i.e. r6).  This code
> +     assumes that the vararg regs have not yet been recorded in
> +     cfun_gpr_save_slot.  */
> +  for (i = 0; i < 16 && cfun_gpr_save_slot (i) != SAVE_SLOT_STACK; i++);
> +  for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
> +  cfun_frame_layout.first_restore_gpr = (i == 16) ? -1 : i;
> +  cfun_frame_layout.last_restore_gpr = (i == 16) ? -1 : j;
> +
> +  /* Now the range of GPRs which need saving.  */
> +  for (i = 0; i < 16 && cfun_gpr_save_slot (i) != SAVE_SLOT_STACK; i++);
> +  for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
> +  cfun_frame_layout.first_save_gpr = (i == 16) ? -1 : i;
> +  cfun_frame_layout.last_save_gpr = (i == 16) ? -1 : j;

Dominik just made me aware of this stupid copy and paste bug which made me ending up with the very
same loops twice :(
I've committed the attached patch to fix this:


Bye,

-Andreas-

Comments

Jakub Jelinek Feb. 5, 2016, 11:50 a.m. UTC | #1
On Fri, Feb 05, 2016 at 12:43:38PM +0100, Andreas Krebbel wrote:
> Dominik just made me aware of this stupid copy and paste bug which made me ending up with the very
> same loops twice :(
> I've committed the attached patch to fix this:
> 
> diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
> index 1667c11..2cf7096 100644
> --- a/gcc/config/s390/s390.c
> +++ b/gcc/config/s390/s390.c
> @@ -9326,10 +9326,6 @@ s390_register_info_set_ranges ()
>    for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
>    cfun_frame_layout.first_restore_gpr = (i == 16) ? -1 : i;
>    cfun_frame_layout.last_restore_gpr = (i == 16) ? -1 : j;
> -
> -  /* Now the range of GPRs which need saving.  */
> -  for (i = 0; i < 16 && cfun_gpr_save_slot (i) != SAVE_SLOT_STACK; i++);
> -  for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
>    cfun_frame_layout.first_save_gpr = (i == 16) ? -1 : i;
>    cfun_frame_layout.last_save_gpr = (i == 16) ? -1 : j;
>  }

Thus
  cfun_frame_layout.first_save_gpr = cfun_frame_layout.first_restore_gpr;
  cfun_frame_layout.last_save_gpr = cfun_frame_layout.last_restore_gpr;
?  Are those supposed to be equivalent just here, or everywhere?

	Jakub
Andreas Krebbel Feb. 5, 2016, 11:55 a.m. UTC | #2
On 02/05/2016 12:50 PM, Jakub Jelinek wrote:
> On Fri, Feb 05, 2016 at 12:43:38PM +0100, Andreas Krebbel wrote:
>> Dominik just made me aware of this stupid copy and paste bug which made me ending up with the very
>> same loops twice :(
>> I've committed the attached patch to fix this:
>>
>> diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
>> index 1667c11..2cf7096 100644
>> --- a/gcc/config/s390/s390.c
>> +++ b/gcc/config/s390/s390.c
>> @@ -9326,10 +9326,6 @@ s390_register_info_set_ranges ()
>>    for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
>>    cfun_frame_layout.first_restore_gpr = (i == 16) ? -1 : i;
>>    cfun_frame_layout.last_restore_gpr = (i == 16) ? -1 : j;
>> -
>> -  /* Now the range of GPRs which need saving.  */
>> -  for (i = 0; i < 16 && cfun_gpr_save_slot (i) != SAVE_SLOT_STACK; i++);
>> -  for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
>>    cfun_frame_layout.first_save_gpr = (i == 16) ? -1 : i;
>>    cfun_frame_layout.last_save_gpr = (i == 16) ? -1 : j;
>>  }
> 
> Thus
>   cfun_frame_layout.first_save_gpr = cfun_frame_layout.first_restore_gpr;
>   cfun_frame_layout.last_save_gpr = cfun_frame_layout.last_restore_gpr;
erm, right

> ?  Are those supposed to be equivalent just here, or everywhere?
They will differ if vararg is being used.

-Andreas-
diff mbox

Patch

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 1667c11..2cf7096 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -9326,10 +9326,6 @@  s390_register_info_set_ranges ()
   for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
   cfun_frame_layout.first_restore_gpr = (i == 16) ? -1 : i;
   cfun_frame_layout.last_restore_gpr = (i == 16) ? -1 : j;
-
-  /* Now the range of GPRs which need saving.  */
-  for (i = 0; i < 16 && cfun_gpr_save_slot (i) != SAVE_SLOT_STACK; i++);
-  for (j = 15; j > i && cfun_gpr_save_slot (j) != SAVE_SLOT_STACK; j--);
   cfun_frame_layout.first_save_gpr = (i == 16) ? -1 : i;
   cfun_frame_layout.last_save_gpr = (i == 16) ? -1 : j;
 }