https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121074

--- Comment #5 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
This is patch to close the auto-profiles.
It is kind of useless but I do not think we need to open gcov file so early. I
am looking into opening it later. sorry is however also an option

diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
index 34f863a7731..1d07a4fc04b 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -3214,6 +3214,7 @@ read_profile (void)
   if (gcov_read_unsigned () != GCOV_DATA_MAGIC)
     {
       error ("AutoFDO profile magic number does not match");
+      gcov_close ();
       return;
     }

@@ -3223,6 +3224,7 @@ read_profile (void)
     {
       error ("AutoFDO profile version %u does not match %u",
             version, AUTO_PROFILE_VERSION);
+      gcov_close ();
       return;
     }

@@ -3234,6 +3236,7 @@ read_profile (void)
   if (!afdo_summary_info->read ())
     {
       error ("cannot read summary information from %s", auto_profile_file);
+      gcov_close ();
       return;
     }

@@ -3242,6 +3245,7 @@ read_profile (void)
   if (!afdo_string_table->read ())
     {
       error ("cannot read string table from %s", auto_profile_file);
+      gcov_close ();
       return;
     }

@@ -3253,6 +3257,7 @@ read_profile (void)
       error ("cannot read function profile from %s", auto_profile_file);
       delete afdo_source_profile;
       afdo_source_profile = NULL;
+      gcov_close ();
       return;
     }

@@ -3261,8 +3266,10 @@ read_profile (void)
   if (gcov_is_error ())
     {
       error ("cannot read module profile from %s", auto_profile_file);
+      gcov_close ();
       return;
     }
+  gcov_close ();
 }

 /* From AutoFDO profiles, find values inside STMT for that we want to measure

Reply via email to