diff options
author | Jan Hubicka <hubicka@ucw.cz> | 2015-03-27 07:58:59 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2015-03-27 06:58:59 +0000 |
commit | eaeec5ecfa45ef6af7642c6bf45c3d77dd4de6b9 (patch) | |
tree | cbd2e935efaa0cca2a297c9acffbbdf68e1c834d /gcc/lto-streamer.h | |
parent | 38147a2a4e7c553840b45ba7d099a5f93ac192a4 (diff) | |
download | gcc-eaeec5ecfa45ef6af7642c6bf45c3d77dd4de6b9.zip gcc-eaeec5ecfa45ef6af7642c6bf45c3d77dd4de6b9.tar.gz gcc-eaeec5ecfa45ef6af7642c6bf45c3d77dd4de6b9.tar.bz2 |
re PR lto/65536 (LTO line number information garbled)
PR lto/65536
* lto-streamer.h (class lto_location_cache): New.
(struct data_in): Add location_cache.
(lto_input_location): Update prototype.
(stream_input_location_now): New.
* streamer-hooks.h (struct streamer_hooks): Make input_location to take
pointer to location.
(stream_input_location): Update.
* ipa-devirt.c: Include streamer-hooks.h and lto-streamer.h
(warn_odr): Apply location cache before warning.
(lto_input_location): Update prototype.
* gimple-streamer-in.c (input_phi, input_gimple_stmt):
Use stream_input_location_now.
* lto/lto.c (unify_scc): Revert location cache when unification
suceeded.
(lto_read_decls): Accept location cache after sucess;
apply location cache before calling debug hooks.
* lto-streamer-in.c (lto_location_cache::current_cache): New static
variable.
(lto_location_cache::cmp_loc): New function.
(lto_location_cache::apply_location_cache): New function.
(lto_location_cache::accept_location_cache): New function.
(lto_location_cache::revert_location_cache): New function.
(lto_location_cache::input_location): New function.
(lto_input_location): Do location caching.
(stream_input_location_now): New function.
(input_eh_region, input_struct_function_base): Use
stream_input_location_now.
(lto_data_in_create): use new.
(lto_data_in_delete): Use delete.
* tree-streamer-in.c (unpack_ts_block_value_fields,
unpack_ts_omp_clause_value_fields, streamer_read_tree_bitfields,
lto_input_ts_exp_tree_pointers): Update for cached location api.
From-SVN: r221720
Diffstat (limited to 'gcc/lto-streamer.h')
-rw-r--r-- | gcc/lto-streamer.h | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h index c8862a2..bf17efe 100644 --- a/gcc/lto-streamer.h +++ b/gcc/lto-streamer.h @@ -307,6 +307,71 @@ typedef void (lto_free_section_data_f) (struct lto_file_decl_data *, const char *, size_t); +/* The location cache holds expanded locations for streamed in trees. + This is done to reduce memory usage of libcpp linemap that strongly preffers + locations to be inserted in the soruce order. */ + +class lto_location_cache +{ +public: + /* Apply all changes in location cache. Add locations into linemap and patch + trees. */ + bool apply_location_cache (); + /* Tree merging did not suceed; mark all changes in the cache as accepted. */ + void accept_location_cache (); + /* Tree merging did suceed; throw away recent changes. */ + void revert_location_cache (); + void input_location (location_t *loc, struct bitpack_d *bp, + struct data_in *data_in); + lto_location_cache () + : loc_cache (), accepted_length (0), current_file (NULL), current_line (0), + current_col (0), current_loc (UNKNOWN_LOCATION) + { + gcc_assert (!current_cache); + current_cache = this; + } + ~lto_location_cache () + { + apply_location_cache (); + gcc_assert (current_cache == this); + current_cache = NULL; + } + + /* There can be at most one instance of location cache (combining multiple + would bring it out of sync with libcpp linemap); point to current + one. */ + static lto_location_cache *current_cache; + +private: + static int cmp_loc (const void *pa, const void *pb); + + struct cached_location + { + const char *file; + location_t *loc; + int line, col; + }; + + /* The location cache. */ + + vec<cached_location> loc_cache; + + /* Accepted entries are ones used by trees that are known to be not unified + by tree merging. */ + + int accepted_length; + + /* Bookkeeping to remember state in between calls to lto_apply_location_cache + When streaming gimple, the location cache is not used and thus + lto_apply_location_cache happens per location basis. It is then + useful to avoid redundant calls of linemap API. */ + + const char *current_file; + int current_line; + int current_col; + location_t current_loc; +}; + /* Structure used as buffer for reading an LTO file. */ class lto_input_block { @@ -680,6 +745,9 @@ struct data_in /* Cache of pickled nodes. */ struct streamer_tree_cache_d *reader_cache; + + /* Cache of source code location. */ + lto_location_cache location_cache; }; @@ -788,7 +856,9 @@ extern struct data_in *lto_data_in_create (struct lto_file_decl_data *, vec<ld_plugin_symbol_resolution_t> ); extern void lto_data_in_delete (struct data_in *); extern void lto_input_data_block (struct lto_input_block *, void *, size_t); -location_t lto_input_location (struct bitpack_d *, struct data_in *); +void lto_input_location (location_t *, struct bitpack_d *, struct data_in *); +location_t stream_input_location_now (struct bitpack_d *bp, + struct data_in *data); tree lto_input_tree_ref (struct lto_input_block *, struct data_in *, struct function *, enum LTO_tags); void lto_tag_check_set (enum LTO_tags, int, ...); |