public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: Jeff Law <law@redhat.com>
Cc: Steven Bosscher <stevenb@suse.de>,
	gcc-patches <gcc-patches@gcc.gnu.org>,
	Diego Novillo <dnovillo@redhat.com>
Subject: Re: Fix a tcb crash and a potential bug on mainline
Date: Wed, 20 Oct 2004 13:17:00 -0000	[thread overview]
Message-ID: <1098278085.5695.3886.camel@pain> (raw)
In-Reply-To: <1098227633.2915.166.camel@localhost.localdomain>

On Tue, 2004-10-19 at 19:13, Jeffrey A Law wrote:
> On Tue, 2004-10-19 at 16:36, Steven Bosscher wrote:
> 
> > > Err, if we remove the last argument to a PHI node then by definition
> > > the block containing the PHI is unreachable as it has no incoming
> > > edges.
> > >
> > > There is no such thing as an "undefined" PHI node.
> > 
> > I didn't say we do.  I said we may have an undefined PHI result,
> > i.e. and SSA_NAME without a definition.
> OK.  And that is something that is, unfortunately, normal in our
> implementation.  If I look at the SSA_NAME manager that's by far
> its largest wart.
> 

If I understand the problem properly, the fundamental problem here is
that a block becomes unreachable by removing all the incoming edges. PHI
arguments for those edges are removed as the edge is removed. When the
last edge is removed, the PHI node has no more arguments, and thus gets
deleted.  None of the code in the dead block is removed until later when
delete_unreachable_blocks is called. Meanwhile, we end up pawing through
one or more stmts in the dead block which contains uses of the PHI
result.

I have a couple of questions.

1 - Why does cleanup_control_flow() ever look at a stmts inside an
unreachable block? Its seems rather, umm, unnecessary, for starters. Why
not just call delete_unreachable_blocks() as the *first* thing in
cfg_cleanup(). It doesn't look like its an expensive call... 

2 - The issue may also exist outside cleanup_control_flow, so why does
remove_phi_arg_num have to remove the PHI node when is removes the last
argument. Why not allow the PHI node to exist with no arguments. It'll
get removed and free'd if the block remains unreachable. Maybe someone
will add another edge back in at some point during the optimization,
then there are PHI nodes ready to take the arguments.  I presume right
now we make sure we add new edges before deleting old ones when
redirecting things (to avoid deleting the PHI).  This might cause the
PHI node to be resized larger without really needing it. (ie, if you are
replacing two edges with one different one, and you add the one before
delete the other two, you've resized the PHI node to 3.)
 

> 
>   2. When we release an SSA_NAME and PHI_NODE go and find all uses
>      of the SSA_NAME and release them too.  This is effectively an
>      iterative DCE process.

I am not very fond of this one :-)  Especially since they are going to
be dealt with en-mass when you delete the block anyway.

Andrew

  reply	other threads:[~2004-10-20 13:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-18 21:09 Steven Bosscher
2004-10-18 22:06 ` Andrew MacLeod
2004-10-18 22:18 ` Andrew Pinski
2004-10-19 20:58 ` Jeffrey A Law
2004-10-19 21:29   ` Steven Bosscher
2004-10-19 22:08     ` Jeffrey A Law
2004-10-19 22:27       ` Daniel Berlin
2004-10-19 22:35         ` Jeffrey A Law
2004-10-19 23:08           ` Daniel Berlin
2004-10-19 23:14             ` Daniel Berlin
2004-10-21  2:33               ` Jeffrey A Law
2004-10-19 22:36       ` Steven Bosscher
2004-10-19 22:41         ` Diego Novillo
2004-10-19 23:16         ` Jeffrey A Law
2004-10-20 13:17           ` Andrew MacLeod [this message]
2004-10-20 13:32             ` Steven Bosscher
2004-10-20 13:47               ` Andrew MacLeod
2004-10-20 14:30                 ` Steven Bosscher
2004-10-20 16:53                   ` Andrew MacLeod
2004-10-20 17:33                     ` Daniel Berlin
2004-10-22 19:15               ` Jeffrey A Law
2004-10-22 19:33                 ` Steven Bosscher
2004-10-22 19:37                   ` Jeffrey A Law
2004-10-22 19:40                     ` Steven Bosscher
2004-10-22 21:08                       ` Jeffrey A Law
2004-10-24 21:20                         ` Steven Bosscher
2004-10-27 16:27                           ` Jeffrey A Law
2004-10-22 19:10             ` Jeffrey A Law

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=1098278085.5695.3886.camel@pain \
    --to=amacleod@redhat.com \
    --cc=dnovillo@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=stevenb@suse.de \
    /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).