public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jan Hubicka <jh@suse.cz>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch] OpenMP: Handle cpp_implicit_alias in declare-target discovery (PR96390)
Date: Tue, 22 Sep 2020 17:39:40 +0200	[thread overview]
Message-ID: <e5c8f5ce-a300-cf50-a108-630659e15315@codesourcery.com> (raw)
In-Reply-To: <20200922142433.GZ2176@tucnak>

On 9/22/20 4:24 PM, Jakub Jelinek wrote:
> On Tue, Sep 22, 2020 at 04:11:19PM +0200, Tobias Burnus wrote:
>> +      while (node->alias_target)
>> +        {
>> +          node = node->ultimate_alias_target ();
> At least in theory, ultimate_alias_target can look through multiple aliases.

Granted. But we need to handle two things:
* target alias (such as for __attribute__(alias(...))
   for this one, I can walk 'node = node->alias_target'
   here, I need to mark all nodes on the way.
* C++ aliases
   for this one, I used node = node->ultimate_alias_target ()
   here, I only need to mark the last one as only
   that function decl is streamed out

> While it might not do that most of the time because this is executed quite
> early, I think we have no guarantees it will never do it.
> So I'd prefer what you had in the earlier patch, i.e. do the
> ultimate_alias_target call + loop to find the ultimate node, and then
> in another loop go from the original node (inclusive) up to the ultimate one
> (exclusive) and do what you do in this loop now.
> Does that make sense?

I am lost. What do I gain by running the loops twice? Initially
the idea was to return NULL_TREE but as you example showed we need
to mark all unmarked ones until to final node.

Thus, we have to mark all – even if the final one is already
'omp declare target'.

But in that case, why can't we do it in a single loop?



If we assume that there is no c++ aliasing, we could do:

           while (node->alias_target)
             {
               // see assumption above: // node = node->ultimate_alias_target ();
               if (!omp_declare_target_fn_p (node->decl)
                   && !lookup_attribute ("omp declare target host",
                                         DECL_ATTRIBUTES (node->decl)))
                 {
                   node->offloadable = 1;
                   DECL_ATTRIBUTES (node->decl)
                     = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (node->decl));
                 }
               node = symtab_node::get (node->alias_target);
             }
           // all node->alias_target resolved
           node = node->ultimate_alias_target ();

That would avoid the in-between calling of ultimate_alias_target() but still
calls it if there is no alias_target or for the final alias target.

Is this (really) better?

BTW: When the assumption about the ordering completely changes,
the current __attribute__(alias(…)) testcase will fail; this might
not catch all issues but at least if it completely changes.

Tobias

-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

  reply	other threads:[~2020-09-22 15:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-03 15:37 Tobias Burnus
2020-08-17  7:17 ` *PING* – " Tobias Burnus
2020-08-25 16:58   ` *PING**2 " Tobias Burnus
2020-08-31 15:53 ` Jakub Jelinek
2020-09-14 13:25   ` Tobias Burnus
2020-09-16 10:36     ` Jakub Jelinek
2020-09-16 23:15       ` Tobias Burnus
2020-09-22  7:11         ` Tobias Burnus
2020-09-22  7:36           ` Jakub Jelinek
2020-09-22 14:11             ` Tobias Burnus
2020-09-22 14:24               ` Jakub Jelinek
2020-09-22 15:39                 ` Tobias Burnus [this message]
2020-09-23 13:52                   ` Tobias Burnus
2020-09-23 14:06                     ` Jakub Jelinek
2020-09-23 15:45                       ` Tobias Burnus
2020-09-25 11:23                         ` Jakub Jelinek

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=e5c8f5ce-a300-cf50-a108-630659e15315@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jh@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).