Bug 21356 - [4.1 Regression] Dominance error after aggressive dead code elimination (cd_dce)
Summary: [4.1 Regression] Dominance error after aggressive dead code elimination (cd_dce)
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.1.0
Assignee: Diego Novillo
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2005-05-03 11:40 UTC by Gábor Lóki
Modified: 2005-07-09 17:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-05-03 16:00:08


Attachments
PPP (1.36 KB, text/plain)
2005-07-06 05:29 UTC, Jeffrey A. Law
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gábor Lóki 2005-05-03 11:40:31 UTC
I have internal compiler error for the following c code:
int a;
void* p;

void foo (void)
{
  switch (a)
  {
    a0: case 0:   p = &&a1;
    a1: case 1:   p = &&a2;
    a2: default:  p = &&a1;
  }
  goto *p;
}

Command line:
gcc -c -O2 1.c

Output:
1.c: In function 'foo':
1.c:5: error: dominator of 1 should be 2, not 0
1.c:5: internal compiler error: in verify_dominators, at dominance.c:875
...
Comment 1 Andrew Pinski 2005-05-03 16:00:07 UTC
Confirmed, a regression from 4.0.0.
Comment 2 Jeffrey A. Law 2005-07-06 05:29:38 UTC
Subject: Re:  [4.1 Regression] Dominance error
	after aggressive dead code elimination (cd_dce)


DCE in aggressive mode sometimes is able to remove control structures
and thus edge from the CFG.  Sometimes removal of edges from the CFG
changes the dominator tree, but we make no attempt to actually keep
the dominators up-to-date.

In this testcase failure to keep the dominators up-to-date leads to
a checking failure.  This is trivially addressed by arranging for the
dominators to be recomputed if we remove edges from the CFG.  An
enterprising individual might be able to incrementally update the
dominators, but for now this is safe and given that removal of 
control structures by DCE is rare, the compile-time cost is minimal.

Bootstrapped and regression tested on i686-pc-linux-gnu.

Jeff
Comment 3 Jeffrey A. Law 2005-07-06 05:29:40 UTC
Created attachment 9213 [details]
PPP
Comment 4 Andrew Pinski 2005-07-06 13:23:29 UTC
Fixed.
Comment 5 Daniel Berlin 2005-07-06 14:05:36 UTC
Subject: Re:  [4.1 Regression] Dominance error
	after aggressive dead code elimination (cd_dce)

On Tue, 2005-07-05 at 23:29 -0600, Jeffrey A Law wrote:
> DCE in aggressive mode sometimes is able to remove control structures
> and thus edge from the CFG.  Sometimes removal of edges from the CFG
> changes the dominator tree, but we make no attempt to actually keep
> the dominators up-to-date.
> 
> In this testcase failure to keep the dominators up-to-date leads to
> a checking failure.  This is trivially addressed by arranging for the
> dominators to be recomputed if we remove edges from the CFG.  An
> enterprising individual might be able to incrementally update the
> dominators,

Uh, we have code to incrementally update the dominators.
Just use iterate_fix_dominators 

Comment 6 Zdenek Dvorak 2005-07-07 06:57:27 UTC
Subject: Re:  [4.1 Regression] Dominance error after aggressive dead code elimination (cd_dce)

Hello,

> On Tue, 2005-07-05 at 23:29 -0600, Jeffrey A Law wrote:
> > DCE in aggressive mode sometimes is able to remove control structures
> > and thus edge from the CFG.  Sometimes removal of edges from the CFG
> > changes the dominator tree, but we make no attempt to actually keep
> > the dominators up-to-date.
> > 
> > In this testcase failure to keep the dominators up-to-date leads to
> > a checking failure.  This is trivially addressed by arranging for the
> > dominators to be recomputed if we remove edges from the CFG.  An
> > enterprising individual might be able to incrementally update the
> > dominators,
> 
> Uh, we have code to incrementally update the dominators.
> Just use iterate_fix_dominators 

note however that to use it you must precisely know the set of basic
blocks whose dominators may change (which may or may not be the case
with CDDCE, I haven't thought about it), and the set should rather be
small -- iterate_fix_dominators is O(n^3) in the size of the set.

All in all, if the changes to cfg are indeed rare (which they should be,
given that the problem remained unnoticed so far), just having the
dominators to be recomputed is much easier and safer.

Zdenek
Comment 7 Diego Novillo 2005-07-08 20:53:33 UTC
The patch for this PR causes bootstrap failures after enabling the new points-to
solver.  I will try to find another solution for this problem.
Comment 8 GCC Commits 2005-07-09 17:35:13 UTC
Subject: Bug 21356

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dnovillo@gcc.gnu.org	2005-07-09 17:35:05

Modified files:
	gcc            : ChangeLog passes.c 

Log message:
	PR 21356
	PR 22332
	* passes.c (execute_todo): Cleanup the CFG before updating
	SSA.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9394&r2=2.9395
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/passes.c.diff?cvsroot=gcc&r1=2.98&r2=2.99

Comment 9 Diego Novillo 2005-07-09 17:38:09 UTC
Fixed.  http://gcc.gnu.org/ml/gcc-patches/2005-07/msg00651.html.