[2/7] lto: Remove random_seed from section name.

Message ID 1ab98391f1f12962c48d1dd4d7309fc219454c96.1700222403.git.mjires@suse.cz
State Accepted
Headers
Series lto: Incremental LTO. |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Michal Jires Nov. 17, 2023, 8:16 p.m. UTC
  Bootstrapped/regtested on x86_64-pc-linux-gnu

gcc/ChangeLog:

	* lto-streamer.cc (lto_get_section_name): Remove random_seed in WPA.
---
 gcc/lto-streamer.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Jan Hubicka Dec. 29, 2023, 9:17 p.m. UTC | #1
> Bootstrapped/regtested on x86_64-pc-linux-gnu
> 
> gcc/ChangeLog:
> 
> 	* lto-streamer.cc (lto_get_section_name): Remove random_seed in WPA.

This is also OK. (since it lacks explanation - the random suffixes are
added for ld -r to work.  This never happens between WPA and ltrans, so
they only consume extra space and confuse the ltrans cache).
> ---
>  gcc/lto-streamer.cc | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/lto-streamer.cc b/gcc/lto-streamer.cc
> index 4968fd13413..53275e32618 100644
> --- a/gcc/lto-streamer.cc
> +++ b/gcc/lto-streamer.cc
> @@ -132,11 +132,17 @@ 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. */
> +     and merging should be ok here.
> +
> +     WPA output is sent to LTRANS directly inside of lto-wrapper, so name
> +     uniqueness for external tools is not needed.
> +     Randomness would inhibit incremental LTO.  */
>    if (section_type == LTO_section_opts)
>      strcpy (post, "");
>    else if (f != NULL) 
>      sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, f->id);
> +  else if (flag_wpa)
> +    strcpy (post, ".0");
Con't post be just empty string?
>    else
>      sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false)); 
>    char *res = concat (section_name_prefix, sep, add, post, NULL);
> -- 
> 2.42.1
>
  

Patch

diff --git a/gcc/lto-streamer.cc b/gcc/lto-streamer.cc
index 4968fd13413..53275e32618 100644
--- a/gcc/lto-streamer.cc
+++ b/gcc/lto-streamer.cc
@@ -132,11 +132,17 @@  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. */
+     and merging should be ok here.
+
+     WPA output is sent to LTRANS directly inside of lto-wrapper, so name
+     uniqueness for external tools is not needed.
+     Randomness would inhibit incremental LTO.  */
   if (section_type == LTO_section_opts)
     strcpy (post, "");
   else if (f != NULL) 
     sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, f->id);
+  else if (flag_wpa)
+    strcpy (post, ".0");
   else
     sprintf (post, "." HOST_WIDE_INT_PRINT_HEX_PURE, get_random_seed (false)); 
   char *res = concat (section_name_prefix, sep, add, post, NULL);