public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ulf Magnusson <ulfalizer@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: How does inline definitions affect inlining heuristics for C++?
Date: Mon, 29 Oct 2012 12:14:00 -0000	[thread overview]
Message-ID: <CAFkk2KRr0YyTYWicM3YmCB9i8as94XSVoL5z8WSr5m9JcKe1Gg@mail.gmail.com> (raw)

Hi,

When not using whole program or link-time optimization, the body of a
function must be available to the compiler for it to be able to inline
calls the function when compiling a TU. Hence, you might want to put a
function that is used in multiple TUs in a header file to give the
compiler the opportunity to inline it. However, this forces you to
make the function inline, as multiple definitions of non-inline
functions is not allowed. It seems inline might be used for two
different purposes here:

(1) To make the function body available to the compiler to give it the
opportunity to inline.
(2) To give the compiler a hint to inline the function.

But what if you trust the compiler to make the right decision for the
function and don't want to influence the inlining heuristics? I.e.,
what if you only want (1) and not (2)?

Which brings me to my questions:

 - How does making a function inline influence GCC's inlining
heuristics for C++?
 - If it does influence the inlining heuristics in some significant
way, then is there some way to get (1) without (2) being forced upon
you?

(Oh, and please point out if I lied anywhere. :)

Cheers,
Ulf

             reply	other threads:[~2012-10-28 13:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-29 12:14 Ulf Magnusson [this message]
2012-10-30  6:30 ` Ángel González

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=CAFkk2KRr0YyTYWicM3YmCB9i8as94XSVoL5z8WSr5m9JcKe1Gg@mail.gmail.com \
    --to=ulfalizer@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /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).