Hi Honza,

> On 28 Jun 2025, at 1:04 pm, Jan Hubicka <hubi...@ucw.cz> wrote:
> 
> External email: Use caution opening links or attachments
> 
> 
> HI,
> I have tested your patch on exchange2 and noticed multiple problems:
>  1) with LTO the translation from dwarf names to symbol names is disabled
>     since we free lang data sooner.  I moved the offline pass upstream which
>     however also may make us miss clones intorduced betwen free lang data
>     and annotation.  This is not very important right now and may be furhter
>     fixed by splitting off auto-profile-read and offline passes.
>  2) I noticed that we miss a lot of AFDO inlines because some code compares
>     name indexes for equality in belief that it compares symbol names.  This
>     is not ture if we drop prefixes.  For this reason I integrated 
> get_original_name
>     into the renaming machinery which actually updates indexes so string table
>     conitnues to work as symbol table.
>     This lets me to drop
>        afdo_string_table->get_index (afdo_string_table->get_name (other->name 
> ()))
>     hops that were introduced at some places
> 
>     Now after renaming all afdo instances should go by DECL_ASSEMBLER_NAME
>     names.
>  3) Detection of realized offline instances had an ordering issue where we
>     omitted marking of those that were offlined later.  Since we can now
>     lookup assembler names, I simplified the logic into single-pass.
> 
> autoprofiledbootstrapped/regteted x86_64-linux, comitted.
> 
> gcc/ChangeLog:
> 
>        * auto-profile.cc (get_original_name): Only strip suffixes introduced
>        after auto-fdo annotation.
>        (string_table::get_index_by_decl):  Simplify.
>        (string_table::add_name): New member function.
>        (string_table::read): Micro-optimize allocation.
>        (function_instance::get_function_instance_by_decl): Dump reasons
>        for failure; try to compensate lost discriminators.
>        (function_instance::merge): Simplify sanity check; do not check
>        for realized flag; fix merging of targets.
>        (function_instance::offline_if_in_set): Simplify.
>        (function_instance::dump): Sanity check that names are consistent.
>        (autofdo_source_profile::offline_external_functions): Also handle
>        stripping suffixes.
>        (walk_block): Move up in source.
>        (autofdo_source_profile::offline_unrealized_inlines): Also compute
>        realized functions.
>        (autofdo_source_profile::get_function_instance_by_name_index): 
> Simplify.
>        (autofdo_source_profile::add_function_instance): Simplify.
>        (autofdo_source_profile::read): Do not strip suffxies; error on 
> duplicates.
>        (mark_realized_functions): Remove.
>        (auto_profile): Do not call mark_realized_functions.
>        * passes.def: Move auto_profile_offline before free_lang_data.
> 
> gcc/testsuite/ChangeLog:
> 
>        * gcc.dg/tree-prof/clone-test.c: New test.
> 

I am seeing an ICEs in offline pass.


during IPA pass: afdo_offline
gmsh/src/mesh/meshGEdge.cpp:979:1: internal compiler error: in 
set_call_location, at auto-profile.cc:433
  979 | }
      | ^
0x262582b internal_error(char const*, ...)
        ../../gcc/gcc/diagnostic-global-context.cc:517
0x864513 fancy_abort(char const*, int, char const*)
        ../../gcc/gcc/diagnostic.cc:1810
0x22da0e7 autofdo::function_instance::set_call_location(unsigned long)
        ../../gcc/gcc/auto-profile.cc:433
0x22da0e7 autofdo::function_instance::set_call_location(unsigned long)
        ../../gcc/gcc/auto-profile.cc:431
0x22da0e7 autofdo::function_instance::match(cgraph_node*, 
vec<autofdo::function_instance*, va_heap, vl_ptr>&, hash_map<int_hash<int, -1, 
-2>, int, simple_hashmap_traits<default_hash_traits<int_hash<int, -1, -2> >, 
int> >&)
        ../../gcc/gcc/auto-profile.cc:1498
0x22d8c8b autofdo::function_instance::match(cgraph_node*, 
vec<autofdo::function_instance*, va_heap, vl_ptr>&, hash_map<int_hash<int, -1, 
-2>, int, simple_hashmap_traits<default_hash_traits<int_hash<int, -1, -2> >, 
int> >&)
        ../../gcc/gcc/auto-profile.cc:1258
0x22d8c8b autofdo::function_instance::match(cgraph_node*, 
vec<autofdo::function_instance*, va_heap, vl_ptr>&, hash_map<int_hash<int, -1, 
-2>, int, simple_hashmap_traits<default_hash_traits<int_hash<int, -1, -2> >, 
int> >&)
        ../../gcc/gcc/auto-profile.cc:1638
0x22ddf6f autofdo::function_instance::match(cgraph_node*, 
vec<autofdo::function_instance*, va_heap, vl_ptr>&, hash_map<int_hash<int, -1, 
-2>, int, simple_hashmap_traits<default_hash_traits<int_hash<int, -1, -2> >, 
int> >&)
        ../../gcc/gcc/hash-table.h:994
0x22ddf6f autofdo::autofdo_source_profile::offline_external_functions()
        ../../gcc/gcc/auto-profile.cc:2032
0x22de0f3 execute
        ../../gcc/gcc/auto-profile.cc:4066

Here stmt is D.293641 = OBJ_TYPE_REF(_7;(const struct GEdge)from->57B) (from); 
and set_call_location has call_location_ != UNKNOWN_LOCATION 

Thanks,
Kugan

Reply via email to