https://gcc.gnu.org/g:7827ae8e6180a1637d63325c161ac2dd3e5f9c4c
commit r16-2641-g7827ae8e6180a1637d63325c161ac2dd3e5f9c4c Author: Jan Hubicka <j...@suse.cz> Date: Wed Jul 30 14:53:21 2025 +0200 auto-profile fixes 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. Diff: --- gcc/auto-profile.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index d1954b4fad69..53e7b51e8832 100644 --- a/gcc/auto-profile.cc +++ b/gcc/auto-profile.cc @@ -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 ());