c++: Prune ordinary locations
authorNathan Sidwell <nathan@acm.org>
Fri, 24 Jun 2022 12:57:42 +0000 (05:57 -0700)
committerNathan Sidwell <nathan@acm.org>
Tue, 5 Jul 2022 15:08:50 +0000 (08:08 -0700)
commit069f46c71e9432eda3d48a366e5c2a750cf8d612
tree3c3b3c58a1773b04d170446a6e991122d0701351
parent07dd0f7ba27d1fe9f0ce5b049ac5735dc5d361ad
c++: Prune ordinary locations

Like macro locations, we only need to emit ordinary location
information for locations emitted into the CMI. This adds a hash table
noting which ordinary lines are needed.  These are then sorted and
(sufficiently) adjacent lines are coalesced to a single map.  There is
a tradeoff here, allowing greater separation reduces the number of
line maps, but increases the number of locations.  It appears allowing
2 or 3 intervening lines is the sweet spot, and this patch chooses 2.

Compiling a hello-world #includeing <iostream> in it's GMF gives a
reduction in number of locations of 5 fold, but an increase in number
of maps about 4 fold.  Examining one of the xtreme-header tests we
halve the number of locations and increase the number of maps by 9
fold.

Module interfaces that emit no entities (or macros, if a header-unit),
will now have no location tables.

gcc/cp/
* module.cc
(struct ord_loc_info, ord_loc_traits): New.
(ord_loc_tabke, ord_loc_remap): New globals.
(struct location_map_info): Delete.
(struct module_state_config): Rename ordinary_loc_align to
loc_range_bits.
(module_for_ordinary_loc): Adjust.
(module_state::note_location): Note ordinary locations,
return bool.
(module_state::write_location): Adjust ordinary location
streaming.
(module_state::read_location): Likewise.
(module_state::write_init_maps): Allocate ord_loc_table.
(module_state::write_prepare_maps): Reimplement ordinary
map preparation.
(module_state::read_prepare_maps): Adjust.
(module_state::write_ordinary_maps): Reimplement.
(module_state::write_macro_maps): Adjust.
(module_state::read_ordinary_maps): Reimplement.
(module_state::write_macros): Adjust.
(module_state::write_config): Adjust.
(module_state::read_config): Adjust.
(module_state::write_begin): Adjust.
(module_state::read_initial): Adjust.
gcc/testsuite/
* g++.dg/modules/loc-prune-1.C: Adjust.
* g++.dg/modules/loc-prune-4.C: New.
* g++.dg/modules/pr98718_a.C: Adjust.
* g++.dg/modules/pr98718_b.C: Adjust.
* g++.dg/modules/pr99072.H: Adjust.
gcc/cp/module.cc
gcc/testsuite/g++.dg/modules/loc-prune-1.C
gcc/testsuite/g++.dg/modules/loc-prune-4.C [new file with mode: 0644]
gcc/testsuite/g++.dg/modules/pr98718_a.C
gcc/testsuite/g++.dg/modules/pr98718_b.C
gcc/testsuite/g++.dg/modules/pr99072.H