public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Jan Hubicka <hubicka@kam.mff.cuni.cz>
Cc: Martin Jambor <mjambor@suse.cz>,
	Artem Klimov <jakmobius@gmail.com>,
	 gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] ipa-visibility: Optimize TLS access [PR99619]
Date: Thu, 5 May 2022 17:41:07 +0300 (MSK)	[thread overview]
Message-ID: <eeba792-42f-5028-ac59-a42e9bb21e65@ispras.ru> (raw)
In-Reply-To: <YnO7ZhFfmfIS6P8D@kam.mff.cuni.cz>

On Thu, 5 May 2022, Jan Hubicka wrote:

> > It follows from how local-dynamic model is defined: we call __tls_get_addr
> > with an argument that identifies the current DSO (not the individual
> > thread-local variable), and then compute the address of the variable with
> > a simple addition, so when there are two or more TLS variables, we can
> > call __tls_get_addr just once (but at -O0 we will end up with redundant
> > calls).
> 
> Thanks for explanation.
> So this is something that really depends on optimization flags of the
> function referring the variable rather than on optimization flags of the
> variable itself and only makes difference if there is -O0 function that
> contains more than one reference to a TLS var?

Well, for an -O0 function it doesn't matter how many different TLS variables
it is referencing. The interesting case is an -O2 function referencing one
local-dynamic TLS variable.

> I guess then a correct answer would be to search for such references.

Presumably at RTL generation time, i.e. let the middle end discover the
most specific TLS access model, and then selectively downgrade local-dynamic
to global-dynamic when lowering an -O0 function.

> What happens when there are multiple object files with a hidden TLS var
> where some gts LOCAL_DYNAMIC and others GLOBAL_DYNAMIC? (Which may
> happen when linking together object files compiled with different
> versions of compiler if we go ahead with this patch on hidden symbols).

They have different relocations, so there's an increase in number of GOT
entries, but otherwise I don't think there's any problem.

Alexander

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

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-17 18:51 Artem Klimov
2022-05-02  8:51 ` Alexander Monakov
2022-05-02 16:04 ` Martin Jambor
2022-05-02 16:43   ` Alexander Monakov
2022-05-09 16:06     ` Alexander Monakov
2022-05-09 16:47       ` Jan Hubicka
2022-05-09 17:15         ` Alexander Monakov
2022-05-16 15:50         ` Alexander Monakov
2022-05-23 10:56           ` Alexander Monakov
2022-05-25  9:04             ` Jan Hubicka
2022-07-07 15:53               ` [PATCH v2] " Alexander Monakov
2022-07-20 13:04                 ` Alexander Monakov
2022-08-05 14:03                   ` Alexander Monakov
2022-08-23 15:27                     ` Alexander Monakov
2022-08-26 11:32                 ` Martin Jambor
2022-08-26 13:35                   ` Alexander Monakov
2022-08-30 11:44                     ` Martin Jambor
2022-08-30 13:19                       ` Alexander Monakov
2022-08-30 14:03                         ` Alexander Monakov
2022-09-05 10:39                           ` Martin Jambor
2022-05-02 19:28   ` [PATCH] " Martin Liška
2022-05-05 10:50   ` Jan Hubicka
2022-05-05 11:50     ` Alexander Monakov
2022-05-05 11:56       ` Jan Hubicka
2022-05-05 14:41         ` 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=eeba792-42f-5028-ac59-a42e9bb21e65@ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@kam.mff.cuni.cz \
    --cc=jakmobius@gmail.com \
    --cc=mjambor@suse.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).