https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65536
--- Comment #23 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #15)
> (In reply to Jakub Jelinek from comment #14)
> > By streaming the line_table directly you'd stream lots of location_t that
> > are not actually used for anything that is streamed into the LTO.
> > I don't understand why the tables would be huge, the string would of course
> > use normal LTO section string sharing, and if we stream right now every
> > location_t as the triplet, it would mean in case a single location_t is
> > never used by more than one tree we'd stream an integer extra to what we
> > stream now (just the triplets would be streamed in a different place), but
> > in the more common case where one location_t is used by many trees, we'd
> > stream less than what we stream now, due to the additional indirection.
>
[...]
> Of course, if you are really unlucky, each location_t used by LTO may belong
> to a different map, thus you cannot remove anything and then it would have
> been more efficient to use a file:line:column table. In this worst case, the
> overhead would be approximately sizeof(struct line_map) * number of rows in
> the file:line:column table.
In fact, looking at
struct GTY(()) line_map_ordinary {
const char *to_file;
linenum_type to_line;
/* An index into the set that gives the line mapping at whose end
the current one was included. File(s) at the bottom of the
include stack have this set to -1. */
int included_from;
/* SYSP is one for a system header, two for a C system header file
that therefore needs to be extern "C" protected in C++, and zero
otherwise. This field isn't really needed now that it's in
cpp_buffer. */
unsigned char sysp;
/* Number of the low-order source_location bits used for a column number. */
unsigned int column_bits : 8;
};
If we do not care about sysp and included_from, then even in the worst case, it
will be more efficient to stream out the line_table than the file:line:column
table.
And it has the benefit that it is already sorted and the location_t values
within trees/gimple can be streamed out directly without calling linemap_lookup
to get the file:line:column for each of them. And since a location_t takes 1/3
of space that file:line:column, that would reduce the streamed out data even
further.