The check you added seems correct to me. Do we need to keep the  
afdo_string_table->get_index (IDENTIFIER_POINTER (
            DECL_ASSEMBLER_NAME (edge->callee->decl))) != s->name ()
check? Should your check replace it rather than be an additional check?

-----Original Message-----
From: liuhongt <hongtao....@intel.com> 
Sent: Sunday, April 27, 2025 8:18 PM
To: gcc-patches@gcc.gnu.org
Cc: Eugene Rozenfeld <eugene.rozenf...@microsoft.com>; hongtao.liu 
<hongtao....@intel.com>
Subject: [EXTERNAL] [PATCH] Fix name mismatch for fortran.

From: "hongtao.liu" <hongtao....@intel.com>

Function name in afdo_string_table is step3d_t_tile.
but DECL_ASSEMBLER_NAME (edge->callee->decl))) gets 
__step3d_t_mod_MOD_step3d_t_tile, Looks like the prefix is not in the debug 
string table, so let's also check directly for 
afdo_string_table->get_index_by_decl (edge->callee->decl).

Tested with autofdo enabled, the issue is fixed by the patch.
Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}.
Ok for trunk?

gcc/ChangeLog:

        PR gcov-profile/118508
        * auto-profile.cc
        (autofdo_source_profile::get_callsite_total_count): Fix name
        mismatch for fortran.
---
 gcc/auto-profile.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index 
aa4d1634f01..2d2d4a428f2 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -837,8 +837,10 @@ autofdo_source_profile::get_callsite_total_count (
 
   function_instance *s = get_function_instance_by_inline_stack (stack);
   if (s == NULL
-      || afdo_string_table->get_index (IDENTIFIER_POINTER (
-             DECL_ASSEMBLER_NAME (edge->callee->decl))) != s->name ())
+      || (afdo_string_table->get_index (IDENTIFIER_POINTER (
+           DECL_ASSEMBLER_NAME (edge->callee->decl))) != s->name ()
+         && afdo_string_table->get_index_by_decl (edge->callee->decl)
+         != s->name()))
     return 0;
 
   return s->total_count ();
--
2.34.1

Reply via email to