diff mbox

[RFC] Replace some bitmaps with HARD_REG_SETs - second version

Message ID alpine.LNX.2.02.1107251601530.1374@localhost.localdomain
State New
Headers show

Commit Message

Dimitrios Apostolou July 25, 2011, 1:06 p.m. UTC
Bug found, in df_mark_reg I need to iterate until regno + n, not n. The 
error is at the following hunk:

Comments

Michael Matz July 25, 2011, 2:20 p.m. UTC | #1
Hi,

On Mon, 25 Jul 2011, Dimitrios Apostolou wrote:

> Bug found, in df_mark_reg I need to iterate until regno + n, not n. The error
> is at the following hunk:
> 
> --- gcc/df-scan.c       2011-02-02 20:08:06 +0000
> +++ gcc/df-scan.c       2011-07-24 17:16:46 +0000
> @@ -3713,35 +3717,40 @@ df_mark_reg (rtx reg, void *vset)
>    if (regno < FIRST_PSEUDO_REGISTER)
>      {
>        int n = hard_regno_nregs[regno][GET_MODE (reg)];
> -      bitmap_set_range (set, regno, n);
> +      int i;
> +      for (i=regno; i<n; i++)
> +       SET_HARD_REG_BIT (*set, i);
>      }

No.  n is a count, hence the upper bound is regno + n.


Ciao,
Michael.
Bernd Schmidt July 25, 2011, 3:01 p.m. UTC | #2
On 07/25/11 16:20, Michael Matz wrote:
> Hi,
> 
> On Mon, 25 Jul 2011, Dimitrios Apostolou wrote:
> 
>> Bug found, in df_mark_reg I need to iterate until regno + n, not n. The error
>> is at the following hunk:
>>
>> --- gcc/df-scan.c       2011-02-02 20:08:06 +0000
>> +++ gcc/df-scan.c       2011-07-24 17:16:46 +0000
>> @@ -3713,35 +3717,40 @@ df_mark_reg (rtx reg, void *vset)
>>    if (regno < FIRST_PSEUDO_REGISTER)
>>      {
>>        int n = hard_regno_nregs[regno][GET_MODE (reg)];
>> -      bitmap_set_range (set, regno, n);
>> +      int i;
>> +      for (i=regno; i<n; i++)
>> +       SET_HARD_REG_BIT (*set, i);
>>      }
> 
> No.  n is a count, hence the upper bound is regno + n.

Also, see add_to_hard_reg_set.


Bernd
Steven Bosscher July 25, 2011, 5:40 p.m. UTC | #3
On Mon, Jul 25, 2011 at 4:20 PM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Mon, 25 Jul 2011, Dimitrios Apostolou wrote:
>
>> Bug found, in df_mark_reg I need to iterate until regno + n, not n. The error
>> is at the following hunk:
>>
>> --- gcc/df-scan.c       2011-02-02 20:08:06 +0000
>> +++ gcc/df-scan.c       2011-07-24 17:16:46 +0000
>> @@ -3713,35 +3717,40 @@ df_mark_reg (rtx reg, void *vset)
>>    if (regno < FIRST_PSEUDO_REGISTER)
>>      {
>>        int n = hard_regno_nregs[regno][GET_MODE (reg)];
>> -      bitmap_set_range (set, regno, n);
>> +      int i;
>> +      for (i=regno; i<n; i++)
>> +       SET_HARD_REG_BIT (*set, i);
>>      }
>
> No.  n is a count, hence the upper bound is regno + n.

Indeed. Which is what Jimis said. Note the "error is in this hunk" ;-)

Ciao!
Steven
Dimitrios Apostolou July 25, 2011, 6:05 p.m. UTC | #4
That was a bug, indeed, but unfortunately it wasn't the one causing the 
crash I posted earlier... Even after fixing it I get the same backtrace 
from gdb.

So the petition "spot the bug" holds...


Thanks,
Dimitris
diff mbox

Patch

--- gcc/df-scan.c       2011-02-02 20:08:06 +0000
+++ gcc/df-scan.c       2011-07-24 17:16:46 +0000
@@ -3713,35 +3717,40 @@  df_mark_reg (rtx reg, void *vset)
    if (regno < FIRST_PSEUDO_REGISTER)
      {
        int n = hard_regno_nregs[regno][GET_MODE (reg)];
-      bitmap_set_range (set, regno, n);
+      int i;
+      for (i=regno; i<n; i++)
+       SET_HARD_REG_BIT (*set, i);
      }
    else


Many thanks to monoid from IRC for spotting it! I'll post an updated patch 
soon.

Thanks, 
Dimitris