public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeffrey A Law <law@redhat.com>
To: Steven Bosscher <stevenb@suse.de>
Cc: gcc-patches@gcc.gnu.org, dnovillo@redhat.com, amacleod@redhat.com
Subject: Re: Fix a tcb crash and a potential bug on mainline
Date: Tue, 19 Oct 2004 20:58:00 -0000	[thread overview]
Message-ID: <1098218905.2915.123.camel@localhost.localdomain> (raw)
In-Reply-To: <200410182303.52997.stevenb@suse.de>

On Mon, 2004-10-18 at 15:03, Steven Bosscher wrote:

> Later on cleanup_control_flow() tries to do its thing on basic block 4.
> It tries to fold "(c_13 != 0B)", but c_13 is on the free list, so it
> does not have a TREE_TYPE, so fold crashes.
Hmm.  I wonder if this is the same bug Andrew Pinski was trying to
fix by not clearing TREE_TYPE.  Your description matches a lot of
the tidbits Andrew mentioned.


> 
> I think the root cause of this bug is that c_13 is put on the free list,
> and I think its SSA_NAME_DEF_STMT should be set to the empty statement,
> because remove_phi_arg_num() cannot know if there are any immediate
> uses of it still left. 
???  Putting c_13 on the free list is the right thing to do.  I'm not
sure why you think setting SSA_NAME_DEF_STMT to NULL is particularly
interesting though.  Whether or not the name has any uses left in the
IL isn't something we use to determine whether or not to set
SSA_NAME_DEF_STMT to any particular value IIRC. 


>  I don't know if making that change could have
> some unforseen effects, so I decided to re-hide the the bug by just not
> looking at unreachable blocks in cleanup_control_flow().
I'm not sure this is sufficient to hide the bug well enough though.


>   I've tried to
> convince myself that this can not happen in other situations, but I'm
> not sure.
Well, any code that deletes edges from the CFG, then later looks at
statements without first calling delete_unreachable_blocks is
suspect.  But I'm not sure if we've even solved this problem
within the context of cleanup_tree_cfg.

Let's say we have a PHI in block A.  Assume the result is used in 
block B.  Assume block A will become unreachable.

While block B must also be unreachable (block B is dominated by
block A), we won't necessarily have removed all its incoming edges.

Thus when we process block B we can still end up touching a statement
which references a released SSA_NAME.  Ugh...

>   This may be something Andrew may want to look into as part
> of his immediate uses work??
It's something we've pondered and talked about a little.  Basically
with the immediate use work we would know where all the uses are
and we could probably arrange to delete those uses.

The trick is whether or not we can do that without introducing the
kinds of problems we had with delete_insn in the past which tried
to do similar stuff.

> 
> This fix is completely untested at the moment, but it's quite obvious
> and it fixes the ICE I was seeing.  Still, I am a bit surprised that we
> have not been in trouble over this bug before - perhaps we should still
> fix the remove_phi_arg_num() issue instead of papering it over this way?
I'm not sure what you mean by fix remove_phi_arg_num except to compute
the immediate uses of the result and delete those statements, which
in turn can cause other statements to get deleted.  Basically it turns
into immediate use based DCE.  Roughly the same thing we'd end up
doing if we tried to do integrated dead code removal using
immediate uses.

Alternately we could split up cleanup_control_expr_graph into two
phases.  The first identifies all the COND_EXPRs and SWITCH_EXPRs
which need updating, but does not do any edge removal.   Once we
have done our full IL scan, we go back to the nodes where we know
which outgoing edge will be taken and proceed to remove the 
COND_EXPR/SWITCH_EXPR and the untaken edges.

jeff

  parent reply	other threads:[~2004-10-19 20:48 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 [this message]
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
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=1098218905.2915.123.camel@localhost.localdomain \
    --to=law@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=dnovillo@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --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).