]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
auto-profile fixes
authorJan Hubicka <jh@suse.cz>
Wed, 30 Jul 2025 12:53:21 +0000 (14:53 +0200)
committerJan Hubicka <jh@suse.cz>
Wed, 30 Jul 2025 13:05:45 +0000 (15:05 +0200)
This patch silences warning about bad location in function_instance::match
warning about profile containing record for line numbers that are not matched
by the function body.  While this is a bogus profile (and we will end up losing
the profile data), create_gcov does not have enough information to output them
correctly in all contexts since in dwarf5 we output multiple locations per single
instructions (possibly comming from different inlines) while it can only represent
one inline stack.

The patch also fixes issue with profile scaling.   By making force_nonzero to
take into account cutoffs, I made the test for counter being non-zero before scaling
too agressive.

gcc/ChangeLog:

* auto-profile.cc (function_instance::match): Disable warning
about bogus locations since dwarf does not represent enough
info to output them correctly in all cases.
(add_scale): Use nonzero_p instead of orig.force_nonzero () == orig.
(afdo_adjust_guessed_profile): Add missing newline in dump
file.

gcc/auto-profile.cc

index d1954b4fad690f72572e4f869d66cc31a5720f94..53e7b51e88321849dea27047d773de99045be553 100644 (file)
@@ -1629,7 +1629,13 @@ function_instance::match (cgraph_node *node,
        if (iter->first != end_location
            && iter->first != start_location
            && (iter->first & 65535) != zero_location
-           && iter->first)
+           && iter->first
+           /* FIXME: dwarf5 does not represent inline stack of debug
+              statements and consequently create_gcov is sometimes
+              mixing up statements from other functions.  Do not warn
+              user about this until this problem is solved.
+              We still write info into dump file.  */
+           && 0)
          {
            if (!warned)
              warned = warning_at (DECL_SOURCE_LOCATION (node->decl),
@@ -3425,7 +3431,7 @@ add_scale (vec <scale> *scales, profile_count annotated, profile_count orig)
       annotated.dump (dump_file);
       fprintf (dump_file, "\n");
     }
-  if (orig.force_nonzero () == orig)
+  if (orig.nonzero_p ())
     {
       sreal scale
        = annotated.guessed_local ()
@@ -3672,7 +3678,7 @@ afdo_adjust_guessed_profile (bb_set *annotated_bb)
         {
           if (dump_file)
             fprintf (dump_file,
-                     "  Can not determine count from the boundary; giving up");
+                     "  Can not determine count from the boundary; giving up\n");
           continue;
         }
        gcc_checking_assert (scales.length ());