diff options
author | Michal Jires <mjires@suse.cz> | 2024-01-09 17:49:34 +0100 |
---|---|---|
committer | Michal Jires <mjires@suse.cz> | 2024-06-06 11:07:17 +0200 |
commit | 346f33e27809ae012696c4731c8ebcec2414dbfb (patch) | |
tree | f5b8e1a84070842b1ccd366291c6aa419468831b | |
parent | ca43678c3d8aff1b8774e0b05c9a4a42fd271b13 (diff) | |
download | gcc-346f33e27809ae012696c4731c8ebcec2414dbfb.zip gcc-346f33e27809ae012696c4731c8ebcec2414dbfb.tar.gz gcc-346f33e27809ae012696c4731c8ebcec2414dbfb.tar.bz2 |
lto: Remove random_seed from section name.
This patch removes suffixes from section names during LTO linking.
These suffixes were originally added for ld -r to work (PR lto/44992).
They were added to all LTO object files, but are only useful before WPA.
After that they waste space, and if kept random, make LTO caching impossible.
Bootstrapped/regtested on x86_64-pc-linux-gnu
gcc/ChangeLog:
* lto-streamer.cc (lto_get_section_name): Remove suffixes after WPA.
gcc/lto/ChangeLog:
* lto-common.cc (lto_section_with_id): Dont load suffix during LTRANS.
-rw-r--r-- | gcc/lto-streamer.cc | 11 | ||||
-rw-r--r-- | gcc/lto/lto-common.cc | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/gcc/lto-streamer.cc b/gcc/lto-streamer.cc index 8032bbf..40ca6b2 100644 --- a/gcc/lto-streamer.cc +++ b/gcc/lto-streamer.cc @@ -132,11 +132,18 @@ lto_get_section_name (int section_type, const char *name, doesn't confuse the reader with merged sections. For options don't add a ID, the option reader cannot deal with them - and merging should be ok here. */ - if (section_type == LTO_section_opts) + and merging should be ok here. + + LTRANS files (output of wpa, input and output of ltrans) are handled + directly inside of linker/lto-wrapper, so name uniqueness for external + tools is not needed. + Randomness would inhibit incremental LTO. */ + if (section_type == LTO_section_opts || flag_ltrans) strcpy (post, ""); else if (f != NULL) sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, f->id); + else if (flag_wpa) + strcpy (post, ""); else sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false)); char *res = concat (section_name_prefix, sep, add, post, NULL); diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc index 2ce94cc..34aa63b 100644 --- a/gcc/lto/lto-common.cc +++ b/gcc/lto/lto-common.cc @@ -2176,6 +2176,13 @@ lto_section_with_id (const char *name, unsigned HOST_WIDE_INT *id) if (strncmp (name, section_name_prefix, strlen (section_name_prefix))) return 0; + + if (flag_ltrans) + { + *id = 0; + return 1; + } + s = strrchr (name, '.'); if (!s) return 0; |