------- Additional Comments From law at redhat dot com 2005-03-30 18:57 ------- Subject: Re: [PR tree-optimization/20460] add phi args to dests of dce-redirected edges
On Wed, 2005-03-30 at 02:56 -0300, Alexandre Oliva wrote: > When remove_dead_stmt() redirects a control stmt, the edge redirection > reserves space for the phi arg for the new incoming edge in all phi > nodes, but, instead of filling them in with information obtained from > the edge redirection, we simply discard this information. This leaves > NULL in the phi args, which may cause crashes later on. > > This patch fixes the problem by filling in the phi args using the > PENDING_STMT list created during edge redirection. This appears to be > the intended use for this information, and it is used similarly in > e.g. loop unrolling. > > Bootstrapping mainline and 4.0 branch on amd64-linux-gnu, and mainline > on i686-pc-linux-gnu. Ok to install if bootstrap and regtesting pass? > > The patch below is for the 4.0 branch, but it applies cleanly and > correctly in mainline as well, since it's just a few lines off. /* Redirect the first edge out of BB to reach POST_DOM_BB. */ redirect_edge_and_branch (EDGE_SUCC (bb, 0), post_dom_bb); - PENDING_STMT (EDGE_SUCC (bb, 0)) = NULL; + flush_pending_stmts (EDGE_SUCC (bb, 0)); I'm having trouble seeing how this can be correct. AFAICT this assumes that EDGE_SUCC (bb, 0)->dest before the redirection has similar PHI as post_dom_bb and that the PHIs appear in the same order in both blocks. I'm not sure you can make that assumption. This code is triggered rarely, I would expect it to be even rarer still for POST_DOM_BB to have PHI nodes. You could probably just ignore dead control statements where the post dominator has PHI nodes and I doubt it would ever be noticed. Jeff -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20460