This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: reg_n_info lossage patch


I've have cause to take a look the allocate_reg_info() code in
gcc/regclass.c and the 0041.html patch submitted by Richard Henderson"

I think the allocate_reg_info() routine has a few more bugs which are
due to fence post errors.

1. The test (after applying patch)

 if (min_index <= regno_allocated && min < max_index)

    should be

            if (min_index < regno_allocated && min <= max_index)

    The change to the 1st test is needed because "min_index" is an
    index whereas "regno_allocated" is the # of entries.

    The change to the 2nd test is needed because "min" is the index
    of the first new entry.

2. I can't see how the test "if (max > regno_allocated)" would ever be   
    other than as a result of a bug at which point I think an abort()   
would be
    more appropriate.

    Assuming I've missed something and max maybe be greater  than
    regno_allocated. Then the test and subsequent assigment are wrong
    and should be changed to.

 if (max >= regno_allocated)
    max = regno_allocated - 1;

     This is because "max" is an index whereas "regno_allocated" is the
     # of entries. Setting max to the # of entries whould logically cause
     array bounds to be exceeded.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]