public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Alexandre Oliva <oliva@adacore.com>, Jan Hubicka <hubicka@ucw.cz>
Cc: Nathan Sidwell <nathan@acm.org>,
	gcc-patches@gcc.gnu.org, jason@redhat.com,
	 joseph@codesourcery.com, hainque@adacore.com,
	ebotcazou@adacore.com
Subject: Re: [PATCH v3] Introduce attribute reverse_alias
Date: Tue, 18 Jul 2023 13:37:51 +0200	[thread overview]
Message-ID: <CAFiYyc0TwLXgSUvFYp1BWkN-MvTTcwqHCj7YSybQrzaUn3=LYA@mail.gmail.com> (raw)
In-Reply-To: <orh6q13ks2.fsf@lxoliva.fsfla.org>

On Tue, Jul 18, 2023 at 6:29 AM Alexandre Oliva via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hello, Nathan,
>
> On Jul 15, 2023, Nathan Sidwell <nathan@acm.org> wrote:
>
> > Not commenting on the semantics, but the name seems unfortunate (hello
> > bikeshed).
>
> Yeah, it's a bit challenging to express the concept, when the notion of
> "alias" is kind of symmetric between decl and target, but the
> previously-implemented extension attaches it to decl rather than to
> target.  I tried "extra alias" before, but that didn't fly either.
>
> Maybe I should give up and just recommend the use of asm ("name")
> instead of allowing alternative names (AKA aliases, in the dictionary
> sense; oh, the irony) to be introduced for a decl?  Maybe that would be
> simpler and enough to sidestep the problem of varying mangled names when
> trying to import into Ada (or defining C++ aliases for) C++ symbols that
> use standard types in signatures that are not fundamental types, such as
> size_t.  That they mangle differently depending on what size_t is
> typedef'ed to makes for some undesirable inconvenience, which this
> attribute attempts to alleviate.
>
> > The documentation starts with 'attribute causes @var{name}
> > to be emitted as an alias to the definition'.  So not emitting a
> > 'reverse alias', whatever that might be.
>
> It's reverse in that it doesn't alias another declaration, as in the
> preexisting meaning of the alias attribute, it adds an alias for the
> present declaration.
>
> > It doesn;t seem to mention how reverse alias differs from 'alias'.
> > Why would 'alias' not DTRT?
>
> contrast:
>
> int foo();
> int __attribute__ ((alias ("foo"))) bar();
>
> static_assert (&foo == &bar); // ok
>
> with:
>
> int __attribute__ ((reverse_alias ("bar"))) foo();
>
> static_assert (&foo == &bar); // error, bar is not a C++ symbol
>
> int __attribute__ ((alias ("bar"))) baz(); // ok
>
> static_assert (&foo == &baz); // ok
>
> asm (".quad bar"); // ok, even in other TUs
> asm (".quad foo"); // not necessarily ok, foo's symbol may be mangled
> asm (".quad baz"); // not necessarily ok, baz's symbol may be mangled
>
> > Is is emitting a an additiona symbol -- ie, something like 'altname'.
>
> Yup.  Is there precedent for this attribute name elsewhere?  I think it
> could work.

I think the __symver__ attribute does something similar already so
maybe use __attribute__((__sym__("foo")))?

Richard.

> > Is that symbol known in the current TU, or other TUs?
>
> Only in the assembly/linker name space, not in any C++ namespace.
>
> --
> Alexandre Oliva, happy hacker                https://FSFLA.org/blogs/lxo/
>    Free Software Activist                       GNU Toolchain Engineer
> Disinformation flourishes because many people care deeply about injustice
> but very few check the facts.  Ask me about <https://stallmansupport.org>

  reply	other threads:[~2023-07-18 11:38 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-29 20:56 [RFC, WIP] introduce attribute exalias Alexandre Oliva
2020-08-07 17:38 ` [PATCH] " Alexandre Oliva
2020-08-14 15:39   ` Alexandre Oliva
2020-08-14 16:24     ` Nathan Sidwell
2020-08-14 19:24       ` Alexandre Oliva
2020-08-14 22:12         ` Nathan Sidwell
2020-08-15  2:43           ` Alexandre Oliva
2020-08-15  9:22             ` Iain Sandoe
2020-08-15 16:39               ` Alexandre Oliva
2020-08-15 18:17                 ` Iain Sandoe
2020-08-25  8:34                   ` Alexandre Oliva
2020-08-25 11:23                     ` Iain Sandoe
2020-08-15 17:26               ` Alexandre Oliva
2020-08-15 21:11             ` Nathan Sidwell
2020-08-25  7:50               ` Alexandre Oliva
2023-07-15  1:08   ` [PATCH v3] Introduce attribute reverse_alias Alexandre Oliva
2023-07-15 21:55     ` Nathan Sidwell
2023-07-18  4:29       ` Alexandre Oliva
2023-07-18 11:37         ` Richard Biener [this message]
2023-07-19 23:11           ` [PATCH v4] Introduce attribute sym Alexandre Oliva
2023-07-20 13:09             ` Richard Biener
2023-07-21  9:23               ` Alexandre Oliva
2023-07-22  3:12             ` Fangrui Song
2023-08-16  4:27               ` Alexandre Oliva
     [not found]             ` <orpm2tgrsd.fsf_-_@lxoliva.fsfla.org>
     [not found]               ` <CAH6eHdQ3vT3MjohuE-izto+K=BMRykY3T-UyWa5-=OTDPM-JsQ@mail.gmail.com>
     [not found]                 ` <ory1h9t6nr.fsf@lxoliva.fsfla.org>
2023-09-20  5:59                   ` [PATCH v5] Introduce attribute sym_alias (was: Last call for bikeshedding on attribute sym/exalias/reverse_alias) Alexandre Oliva
2023-11-20 12:54                     ` [PATCH v5] Introduce attribute sym_alias Alexandre Oliva
2023-11-22 12:14                       ` Richard Biener
2023-11-22 19:16                         ` Joseph Myers
2023-11-22 13:13                     ` [PATCH v5] Introduce attribute sym_alias (was: Last call for bikeshedding on attribute sym/exalias/reverse_alias) Jan Hubicka
2023-11-30 12:53                       ` [PATCH v6] Introduce attribute sym_alias Alexandre Oliva
2023-11-30 15:24                         ` Jan Hubicka
2023-12-01 11:25                           ` [PATCH v7] " Alexandre Oliva
2023-12-06  2:10                             ` [PATCH v8] " Alexandre Oliva
2023-12-06 10:06                             ` [PATCH v7] " Jan Hubicka
2023-12-07 20:52                               ` Alexandre Oliva

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='CAFiYyc0TwLXgSUvFYp1BWkN-MvTTcwqHCj7YSybQrzaUn3=LYA@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hainque@adacore.com \
    --cc=hubicka@ucw.cz \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=nathan@acm.org \
    --cc=oliva@adacore.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).