public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1063] c++: Separate late stage module writing Date: Mon, 13 Jun 2022 11:21:13 +0000 (GMT) [thread overview] Message-ID: <20220613112113.BC4B3382798C@sourceware.org> (raw) https://gcc.gnu.org/g:6303eee4b92e8509409503a3abebde8bd50f0f05 commit r13-1063-g6303eee4b92e8509409503a3abebde8bd50f0f05 Author: Nathan Sidwell <nathan@acm.org> Date: Thu Jun 9 08:48:25 2022 -0700 c++: Separate late stage module writing This moves some module writing into a newly added write_end function, which is called after writing initializers. gcc/cp/ * module.cc (module_state::write): Separate to ... (module_state::write_begin, module_state::write_end): ... these. (module_state::write_readme): Drop extensions parameter. (struct module_processing_cookie): Add more fields. (finish_module_processing): Adjust state writing call. (late_finish_module): Call write_end. Diff: --- gcc/cp/module.cc | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/gcc/cp/module.cc b/gcc/cp/module.cc index 51d774ae608..e7ce40ef464 100644 --- a/gcc/cp/module.cc +++ b/gcc/cp/module.cc @@ -3523,7 +3523,10 @@ class GTY((chain_next ("%h.parent"), for_user)) module_state { public: /* Read and write module. */ - void write (elf_out *to, cpp_reader *); + void write_begin (elf_out *to, cpp_reader *, + module_state_config &, unsigned &crc); + void write_end (elf_out *to, cpp_reader *, + module_state_config &, unsigned &crc); bool read_initial (cpp_reader *); bool read_preprocessor (bool); bool read_language (bool); @@ -3545,8 +3548,7 @@ class GTY((chain_next ("%h.parent"), for_user)) module_state { private: /* The README, for human consumption. */ - void write_readme (elf_out *to, cpp_reader *, - const char *dialect, unsigned extensions); + void write_readme (elf_out *to, cpp_reader *, const char *dialect); void write_env (elf_out *to); private: @@ -13954,8 +13956,7 @@ module_state::announce (const char *what) const readelf -pgnu.c++.README $(module).gcm */ void -module_state::write_readme (elf_out *to, cpp_reader *reader, - const char *dialect, unsigned extensions) +module_state::write_readme (elf_out *to, cpp_reader *reader, const char *dialect) { bytes_out readme (to); @@ -17560,7 +17561,8 @@ ool_cmp (const void *a_, const void *b_) */ void -module_state::write (elf_out *to, cpp_reader *reader) +module_state::write_begin (elf_out *to, cpp_reader *reader, + module_state_config &config, unsigned &crc) { /* Figure out remapped module numbers, which might elide partitions. */ @@ -17656,8 +17658,6 @@ module_state::write (elf_out *to, cpp_reader *reader) } ool->qsort (ool_cmp); - unsigned crc = 0; - module_state_config config; location_map_info map_info = write_prepare_maps (&config); unsigned counts[MSC_HWM]; @@ -17811,28 +17811,35 @@ module_state::write (elf_out *to, cpp_reader *reader) unsigned clusters = counts[MSC_sec_hwm] - counts[MSC_sec_lwm]; dump () && dump ("Wrote %u clusters, average %u bytes/cluster", clusters, (bytes + clusters / 2) / (clusters + !clusters)); + trees_out::instrument (); write_counts (to, counts, &crc); - /* And finish up. */ - write_config (to, config, crc); - spaces.release (); sccs.release (); vec_free (ool); - /* Human-readable info. */ - write_readme (to, reader, config.dialect_str, extensions); - // FIXME:QOI: Have a command line switch to control more detailed // information (which might leak data you do not want to leak). // Perhaps (some of) the write_readme contents should also be // so-controlled. if (false) write_env (to); +} + +// Finish module writing after we've emitted all dynamic initializers. + +void +module_state::write_end (elf_out *to, cpp_reader *reader, + module_state_config &config, unsigned &crc) +{ + /* And finish up. */ + write_config (to, config, crc); + + /* Human-readable info. */ + write_readme (to, reader, config.dialect_str); - trees_out::instrument (); dump () && dump ("Wrote %u sections", to->get_section_limit ()); } @@ -19855,15 +19862,18 @@ maybe_check_all_macros (cpp_reader *reader) } // State propagated from finish_module_processing to fini_modules + struct module_processing_cookie { elf_out out; + module_state_config config; char *cmi_name; char *tmp_name; + unsigned crc; bool began; module_processing_cookie (char *cmi, char *tmp, int fd, int e) - : out (fd, e), cmi_name (cmi), tmp_name (tmp), began (false) + : out (fd, e), cmi_name (cmi), tmp_name (tmp), crc (0), began (false) { } ~module_processing_cookie () @@ -19941,7 +19951,7 @@ finish_module_processing (cpp_reader *reader) auto loc = input_location; /* So crashes finger-point the module decl. */ input_location = state->loc; - state->write (&cookie->out, reader); + state->write_begin (&cookie->out, reader, cookie->config, cookie->crc); input_location = loc; } @@ -19977,6 +19987,9 @@ late_finish_module (cpp_reader *reader, module_processing_cookie *cookie) unsigned n = dump.push (state); state->announce ("finishing"); + if (cookie->began) + state->write_end (&cookie->out, reader, cookie->config, cookie->crc); + if (cookie->out.end () && cookie->cmi_name) { /* Some OS's do not replace NEWNAME if it already exists.
reply other threads:[~2022-06-13 11:21 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220613112113.BC4B3382798C@sourceware.org \ --to=nathan@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).