public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Martin Liška" <mliska@suse.cz>
To: "Arsen Arsenović" <arsen@aarsen.me>, gcc@gcc.gnu.org
Cc: Martin Jambor <mjambor@suse.cz>, Jan Hubicka <hubicka@ucw.cz>
Subject: Re: cgraph: does node->inlined_to imply node->clones is non-empty?
Date: Tue, 14 Mar 2023 13:42:29 +0100	[thread overview]
Message-ID: <cf459a6d-ba08-1815-3c23-49d3ee8bee97@suse.cz> (raw)
In-Reply-To: <86bkkwude3.fsf@aarsen.me>

Hi.

I'm CCing my more skilled colleagues who will know the right answer.

Cheers,
Martin

On 3/13/23 11:24, Arsen Arsenović via Gcc wrote:
> Hi,
> 
> I was debugging PR96059 and ran into a question which does not seem
> obvious from the code.
> 
> For the test case in the PR, in ipa.cc:remove_unreachable_nodes, GCC
> seems to try to remove an unreachable function that was already inlined
> into a different unreachable function.  When the original inline
> happens, ipa-inline-transform.cc:clone_inlined_nodes decides not to make
> a clone, since the function being cloned is a master clone but with no
> non-inline clones.
> 
> This decision later trips up the gcc_assert in:
> 
>   /* Inline clones might be kept around so their materializing allows further
>      cloning.  If the function the clone is inlined into is removed, we need
>      to turn it into normal cone.  */
>   FOR_EACH_FUNCTION (node)
>     {
>       if (node->inlined_to
> 	  && !node->callers)
> 	{
> 	  gcc_assert (node->clones);
> 	  node->inlined_to = NULL;
> 	  update_inlined_to_pointer (node, node);
> 	}
>       node->aux = NULL;
>     }
> 
> .. because it is expecting that an inlined function without callers
> (which is necessarily true here as this function is unreachable and so
> was ->remove ()'d earlier) has clones.
> 
> Either removing the assertion or making clone_inline_nodes clone when
> there are no existing clones 'fixes' (suppresses, but I haven't verified
> whether the results are correct) the problem.
> 
> Is this gcc_assert correct in that an inlined function without callers
> necessarily must have clones?
> 
> And as a side question, do all clone nodes have a ->clones pointing to
> the same list of all clones, or are they in a tree-ish arrangement,
> where clones of clones end up forming a tree, with the clone_of pointer
> being a pointer to the parent?  (in this instance, the node that trips
> the assert has a nullptr clone_of and clones value, which would AIUI
> imply that it is the original)
> 
> This train of thinking doesn't end up involving any devirtualization
> code, which the PR was originally reproduced with, but my current theory
> is that devirtualizing here just exposed an edge case that is decently
> well hidden, rather than it playing a crucial role.
> 
> Thanks in advance, have a lovely day.


  reply	other threads:[~2023-03-14 12:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 10:24 Arsen Arsenović
2023-03-14 12:42 ` Martin Liška [this message]
2023-03-15 17:12 ` Martin Jambor
2023-03-18 15:26   ` Arsen Arsenović
2023-03-24 12:40     ` Martin Jambor
2023-03-24 13:29       ` Jan Hubicka
2023-03-28  1:10       ` Arsen Arsenović

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=cf459a6d-ba08-1815-3c23-49d3ee8bee97@suse.cz \
    --to=mliska@suse.cz \
    --cc=arsen@aarsen.me \
    --cc=gcc@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --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).