https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65536

--- Comment #45 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #42)
> Hi,
> I read linemap_line_start and I think I noticed few issues with respect
> to overflows and lines being added randomly.

I honestly think this is too sensitive for stage3. I'm also not very much in
favour for optimizing out-of-order creating of line-maps. That is not the
typical case outside LTO and I would argue it should not be the typical case in
LTO either. Of course, fixing overflow problems is orthogonal and desirable and
should be submitted as a separate patch.

> 1) line_delta is computed as to_line SOURCE_LINE (map, set->highest_line)
>    I think the last inserted line is not very releavnt.  What we care about
> is
>    the base of the last location and to keep thing dense how much we are
>    stretching the value range from highest inserted element (inserting into
> middle
>    is cheap).

My guess is that the motivation here is that, if there is a large gap, it means
that we didn't get asked any source_location since a lot of lines ago. thus it
would save a lot of source_locations to simply start a new map now. Of course,
this does not work for out-of-order, but why should we pessimize typical usage
for something that should be fixed in LTO?

> 2) (line_delta > 10 && line_delta * ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map)
> > 1000)
>    ORDINARY_MAP_NUMBER_OF_COLUMN_BITS (map) is in range 7... 15, so it never
>    gets high enough to make this conditional trigger.  I changed it to:

I don't understand this. A line_delta of 67 (1000/15) will already trigger it.

> 4) the code deciding whether to do reuse seems worng:
>       if (line_delta < 0
>         || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map)
>         || SOURCE_COLUMN (map, highest) >= (1U << column_bits))
> 
>    line_delta really should be base_line_delta, we do not need to give up
>    when map's line is 1, SOURCE_LINE (map, set->highest_line) is 5
>    and we are requested to switch to line 3.

If you insert a line out of order without creating a new map, then
linemap_position_for_column will return the wrong value.

Reply via email to