public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: PING: [PATCH v2] tree-profile: Don't instrument an IFUNC resolver nor its callees
Date: Tue, 2 Apr 2024 08:57:42 -0700	[thread overview]
Message-ID: <CAMe9rOpukwZui401ou-_t9kGLfsccujdsFJM9BDVJH2KOjUJ1A@mail.gmail.com> (raw)
In-Reply-To: <ZgwbKb58WVu5lwtl@kam.mff.cuni.cz>

On Tue, Apr 2, 2024 at 7:50 AM Jan Hubicka <hubicka@ucw.cz> wrote:
>
> > On Tue, Mar 5, 2024 at 1:45 PM H.J. Lu <hjl.tools@gmail.com> wrote:
> > >
> > > We can't instrument an IFUNC resolver nor its callees as it may require
> > > 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.  Update tree_profiling to skip
> > > functions called by IFUNC resolver.
> > >
> > > 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 (tree_profiling): Do not instrument an IFUNC
> > >         resolver nor its callees.
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > >         PR tree-optimization/114115
> > >         * gcc.dg/pr114115.c: New test.
> >
> > PING.
>
> I am bit worried about commonly used functions getting "infected" by
> being called once from ifunc resolver.  I think we only use thread local
> storage for indirect call profiling, so we may just disable indirect
> call profiling for these functions.

Will change it.

> Also the patch will be noop with -flto -flto-partition=max, so probably
> we need to compute this flag at WPA time and stream to partitions.
>

Why is it a nop with -flto -flto-partition=max? I got

(gdb) bt
#0  symtab_node::check_ifunc_callee_symtab_nodes ()
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/symtab.cc:1440
#1  0x0000000000e487d3 in symbol_table::compile (this=0x7fffea006000)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/cgraphunit.cc:2320
#2  0x0000000000d23ecf in lto_main ()
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/lto/lto.cc:687
#3  0x00000000015254d2 in compile_file ()
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/toplev.cc:449
#4  0x00000000015284a4 in do_compile ()
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/toplev.cc:2154
#5  0x0000000001528864 in toplev::main (this=0x7fffffffd84a, argc=16,
    argv=0x42261f0) at /export/gnu/import/git/gitlab/x86-gcc/gcc/toplev.cc:2310
#6  0x00000000030a3fe2 in main (argc=16, argv=0x7fffffffd958)
    at /export/gnu/import/git/gitlab/x86-gcc/gcc/main.cc:39

Do you have a testcase to show that it is a nop?

-- 
H.J.

  reply	other threads:[~2024-04-02 15:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 21:45 H.J. Lu
2024-04-02 14:41 ` PING: " H.J. Lu
2024-04-02 14:50   ` Jan Hubicka
2024-04-02 15:57     ` H.J. Lu [this message]
2024-04-02 17:03       ` Jan Hubicka
2024-04-03 12:41         ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMe9rOpukwZui401ou-_t9kGLfsccujdsFJM9BDVJH2KOjUJ1A@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).