]> git.ipfire.org Git - thirdparty/gcc.git/commit
tree-profile: Disable indirect call profiling for IFUNC resolvers
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 14 Apr 2024 19:57:39 +0000 (12:57 -0700)
committerH.J. Lu <(no_default)>
Mon, 15 Apr 2024 11:22:47 +0000 (04:22 -0700)
commitabe3a80aa2d6d53cc9b8c9f7c531e065451d5b6e
tree8c641953d950e5c65a6b373a2f99585bfdeb7218
parent9d5532499009d1b28c2ebd67ba7af288fad31702
tree-profile: Disable indirect call profiling for IFUNC resolvers

We can't profile indirect calls to IFUNC resolvers nor their callees as
it requires TLS which hasn't been set up yet when the dynamic linker is
resolving IFUNC symbols.

Add an IFUNC resolver caller marker to cgraph_node and set it if the
function is called by an IFUNC resolver.  Disable indirect call profiling
for IFUNC resolvers and their callees.

Tested with profiledbootstrap on Fedora 39/x86-64.

gcc/ChangeLog:

PR tree-optimization/114115
* cgraph.h (symtab_node): Add check_ifunc_callee_symtab_nodes.
(cgraph_node): Add called_by_ifunc_resolver.
* cgraphunit.cc (symbol_table::compile): Call
symtab_node::check_ifunc_callee_symtab_nodes.
* symtab.cc (check_ifunc_resolver): New.
(ifunc_ref_map): Likewise.
(is_caller_ifunc_resolver): Likewise.
(symtab_node::check_ifunc_callee_symtab_nodes): Likewise.
* tree-profile.cc (gimple_gen_ic_func_profiler): Disable indirect
call profiling for IFUNC resolvers and their callees.

gcc/testsuite/ChangeLog:

PR tree-optimization/114115
* gcc.dg/pr114115.c: New test.

(cherry picked from commit cab32bacaea268ec062b1fb4fc662d90c9d1cfce)
gcc/cgraph.h
gcc/cgraphunit.cc
gcc/symtab.cc
gcc/testsuite/gcc.dg/pr114115.c [new file with mode: 0644]
gcc/tree-profile.cc