]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
lto: Remove random_seed from section name.
authorMichal Jires <mjires@suse.cz>
Tue, 9 Jan 2024 16:49:34 +0000 (17:49 +0100)
committerMichal Jires <mjires@suse.cz>
Thu, 6 Jun 2024 09:07:17 +0000 (11:07 +0200)
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.

gcc/lto-streamer.cc
gcc/lto/lto-common.cc

index 8032bbf7108fbb71e309fcc52ec7776b1c7a4c4c..40ca6b2da1b87553195ff16180e1df3010bf659b 100644 (file)
@@ -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);
index 2ce94cc32828ca0073e8501a581c113f6f2c4143..34aa63b179cd2afa5a13ba71a59db93b1bc336f8 100644 (file)
@@ -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;