public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: "Yitschak, Yehuda" <yehuday@amazon.com>
Cc: "gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: FDO for optimal linker map
Date: Thu, 26 May 2022 22:14:37 +0300 (MSK)	[thread overview]
Message-ID: <b474e993-b8f8-b58a-8f52-5befba80cdab@ispras.ru> (raw)
In-Reply-To: <76b462cb3dab454ca4382fa5eb7d9ae0@EX13D07EUA001.ant.amazon.com>

On Thu, 26 May 2022, Yitschak, Yehuda via Gcc-help wrote:

> Hello
> 
> I am learned about GCC FDO capabilities but AFAICT it doesn't effect the
> function layout which the linker generates
> My intention is to use the feedback data to create an optimal function layout
> to minimize I-cache misses.
> Meaning to group the most frequently accessed functions together and perhaps
> even order them  to utilize cache prefetch better.
> 
> Is there anyway to achieve that in GCC  ?

Yes. The compiler can select some order of functions, and place functions in
separate sections named .text.sorted.NNNN, and then the linker can emit the
sections in desired order (new Binutils linker handles .text.sorted.N
automatically, for older linkers you can pass --sort-section=name).

As you probably know, coming up with a good reordering is the hard part. There
is an experimental GCC patch that implements C3 reordering algorithm:
https://gcc.gnu.org/legacy-ml/gcc-patches/2019-09/msg01142.html

Alexander

      reply	other threads:[~2022-05-26 19:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-26  5:53 Yitschak, Yehuda
2022-05-26 19:14 ` Alexander Monakov [this message]

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=b474e993-b8f8-b58a-8f52-5befba80cdab@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=gcc-help@gcc.gnu.org \
    --cc=yehuday@amazon.com \
    /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).