Hi,
this change was discussed on Cauldron. Auto-profile needs to know linkage
names of functions, even those that has been inlined, to correctly map the
profile back to symbol table.

Currently dwarf2out does not output linkage names of non-public functions which
makes them appear by their dwarf name that is not even unique within single
unit.

Note that this patch does not solve the problem that internal linkage names may
clash across translation unit.  LLVM uses -funique-internal-linkage-names that
adds .uniq_<md5hash> suffixes to all internal symbols. This breaks ASM
statements and ohter things.  They are working on replacing it by using IDs
essentially ideantical to our profile ID (which is a hash of symbol name and
for insternal symbols also of translation unit). The profile IDs are not stored
in debug info but go into specal section.

I think we can get around by storing (linkage name,tranlsation unit name) pairs
into the auto-profile for which there is already patch that needs some extra 
work
I plan to work on next.

I wonder if we want to have -gdebug-for-auto-profile (probably on by default)
that controls parts of debug info used only for auto-fdo, such as this change.
THis could also control discriminators.  While it would be nice to have
auto-fdo to work with default debug info, I think this would be useful to keep
track what we do for autofdo only and how expensive it is.

Bootstrapped/regtested x86_64-linux, OK?
As a followup i will remove a twisted heuiristics i added to auto-fdo to handle
dwarf names next.

gcc/ChangeLog:

        * dwarf2out.cc (add_linkage_name): Store linkage names
        of private function symbols to help auto-fdo.

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 0bd8474bc37..95d9f219cf0 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -22235,7 +22235,10 @@ add_linkage_name (dw_die_ref die, tree decl)
 {
   if (debug_info_level > DINFO_LEVEL_NONE
       && VAR_OR_FUNCTION_DECL_P (decl)
-      && TREE_PUBLIC (decl)
+      && (TREE_PUBLIC (decl)
+         /* Linkage names of internal function symbols
+            are used by auto-fdo.  */
+         || TREE_CODE (decl) == FUNCTION_DECL)
       && !(VAR_P (decl) && DECL_REGISTER (decl))
       && die->die_tag != DW_TAG_member)
     add_linkage_name_raw (die, decl);

Reply via email to