Bug 11646 - [3.3/3.4 regression] ICE in commit_one_edge_insertion with -fnon-call-exceptions -fgcse -O
Summary: [3.3/3.4 regression] ICE in commit_one_edge_insertion with -fnon-call-excepti...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3.1
: P2 critical
Target Milestone: 3.3.2
Assignee: Eric Botcazou
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2003-07-23 18:09 UTC by nick
Modified: 2004-01-17 04:22 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2003-07-23 18:25:23


Attachments
3.3.1 prerelease preprocessed source triggering bug (39.01 KB, text/plain)
2003-07-23 18:10 UTC, nick
Details
Partially reduced testcase (1.46 KB, text/plain)
2003-09-14 12:48 UTC, Eric Botcazou
Details
Un-templatized testcase (476 bytes, text/plain)
2003-09-14 17:34 UTC, Eric Botcazou
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nick 2003-07-23 18:09:10 UTC
The following code ICE's the 3.3.1 prerelease with -fnon-call-exceptions
and -fgcse.  Disabling either of the two flags results in successful
compilation.  This compiles succeffully with the 3.2.3 release.

---------------
#include <vector>
using std::vector;

struct A {
  float l() const;
  A operator - (const A &) const;
  const A & operator = (float) const;
};

struct B {
  float d();
};

struct C {
    int i;
};

float
f(const A& a, B& b)
{
    vector<C> vc;
    int index = vc[0].i;
    A aa;
    float d = (aa - a).l();
    if (d > b.d()) aa = 0;
    return b.d();
}
------------------

> /dept/rnd/vendor/gcc-3.3.1-20030720/bin/g++ -fnon-call-exceptions -fgcse -O -c
fnce-gcse.C
fnce-gcse.C: In function `float f(const A&, B&)':
fnce-gcse.C:27: internal compiler error: in split_edge, at cfgrtl.c:1326
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

-nick
Comment 1 nick 2003-07-23 18:10:53 UTC
Created attachment 4467 [details]
3.3.1 prerelease preprocessed source triggering bug
Comment 2 Wolfgang Bangerth 2003-07-23 18:25:22 UTC
The error happens in commit_on_edge_insertion, which is why I thought for
a second that it might be the same bug as PR 11083, but that one is fixed
(I double-checked). On the other hand, that as well as this report both
ICE in commit_one_edge_insertion when using -fnon-call-exceptions.

Eric, you fixed 11083 -- would you mind to take a look at this one, too?
It's a regression on 3.3 and 3.4 against 3.2.

Here's a slightly smaller testcase (not really, since the include file
is still there):
---------------------------------
#include <vector>
using std::vector;

struct C {
    int i;
};

void f()
{
  vector<C> vc;
  int index = vc[0].i;
}
------------------------------
tmp/gg> ../build-gcc/gcc-install/bin/c++ -c x.cc -fgcse -fnon-call-exceptions -O
x.cc: In function `void f()':
x.cc:12: internal compiler error: in commit_one_edge_insertion, at cfgrtl.c:
   1546
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 3 Wolfgang Bangerth 2003-07-23 18:54:57 UTC
OK, this is as short as I can get it (but that should suffice):
-----------------------------
struct A {
    ~A() throw() { }
};

struct B {
    B(const A& __a) : p(0) { }
    int* p;
};

template<typename> struct V : B {
    V() : B(A()) { }
    ~V() {}
    int & foo();
};

void f() {
  int index = V<int>().foo();
}
------------------------------
mp/gg> ../build-gcc/gcc-install/bin/c++ -c z.cc -fgcse -fnon-call-exceptions -O
z.cc: In function `void f()':
z.cc:18: internal compiler error: in commit_one_edge_insertion, at cfgrtl.c:
   1546
Please submit a full bug report,

W.
Comment 4 janis187 2003-07-25 23:30:53 UTC
The regression in PR 11646 was introduced or exposed with this patch:

--- gcc/gcc/ChangeLog ---

Sat Jul 12 03:06:01 CEST 2003  Jan Hubicka  <jh@suse.cz>
                               Gerald Pfeifer  <pfeifer@dbai.tuwien.ac.at>

        * cgraph.c (cgraph_max_uid): New global variable.
        (cgraph_node): Set uid field.
        (create_edge): Keep inline flags consistent.
        (dump_cgraph): Dump more info.

        [lots more]
                                                                               
The regression hunt took place on i686-pc-linux-gnu using the small test
case from comment #3 compiled with "-O -fgcse -fnon-call-exceptions". 
Comment 5 Andrew Pinski 2003-08-09 13:17:31 UTC
The patch which Janias quoted almost did not cause this ICE as 3.3.1 ICE also and that 
patch went only into the mainline.
Also the patch might have cause the rtl to be generated differently which caused the 
problem but who knows.
Comment 6 Eric Botcazou 2003-09-04 20:48:20 UTC
Wolfgang, note that your reduced testcases are not valid on the 3.3 branch.
Comment 7 Wolfgang Bangerth 2003-09-04 20:58:22 UTC
Subject: Re:  [3.3/3.4 regression] ICE in commit_one_edge_insertion with -fnon-call-exceptions -fgcse -O

> Wolfgang, note that your reduced testcases are not
> valid on the 3.3 branch.

What do you mean by that? I can compile them.

However, I can't reproduce the failure mode any more on neither 3.3 branch nor 
on mainline. Has this been silently fixed? If so, we should ask Janis to 
search for the patch to see whether it is fixed or just papered over.

W.

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/

Comment 8 Eric Botcazou 2003-09-04 21:12:58 UTC
They are not valid testcases for the bug on the 3.3 branch, that is they don't
trigger the ICE while the original code still does as of today.
Comment 9 Wolfgang Bangerth 2003-09-04 21:39:28 UTC
Subject: Re:  [3.3/3.4 regression] ICE in commit_one_edge_insertion with -fnon-call-exceptions -fgcse -O

> They are not valid testcases for the bug on the
> 3.3 branch, that is they don't trigger the ICE while the original code
> still does as of today.

Ouch. So someone will have to do the work again. Unfortunately, I won't have 
the time to do this in the forseeable future. Let's CC: the bugmasters 
list...

W.

-------------------------------------------------------------------------
Wolfgang Bangerth              email:            bangerth@ices.utexas.edu
                               www: http://www.ices.utexas.edu/~bangerth/

Comment 10 Eric Botcazou 2003-09-12 11:20:23 UTC
Intermediate step to...
Comment 11 Eric Botcazou 2003-09-12 11:20:58 UTC
...this one.
Comment 12 Eric Botcazou 2003-09-14 12:48:02 UTC
Created attachment 4756 [details]
Partially reduced testcase
Comment 13 Eric Botcazou 2003-09-14 17:34:29 UTC
Created attachment 4759 [details]
Un-templatized testcase
Comment 14 Eric Botcazou 2003-09-15 07:07:23 UTC
Fixing.
Comment 15 GCC Commits 2003-09-17 07:11:05 UTC
Subject: Bug 11646

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2003-09-17 07:11:02

Modified files:
	gcc            : ChangeLog cfgrtl.c toplev.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: cfg3.C 

Log message:
	PR optimization/11646
	* cfgrtl.c (purge_dead_edges) [JUMP_INSN]: Rematerialize the
	EDGE_ABNORMAL flag for EH edges.
	* toplev.c (rest_of_handle_cse): Delete unreachable blocks
	if dead edges were purged.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1074&r2=2.1075
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&r1=1.97&r2=1.98
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&r1=1.825&r2=1.826
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3059&r2=1.3060
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/cfg3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 16 GCC Commits 2003-09-17 07:17:20 UTC
Subject: Bug 11646

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	ebotcazou@gcc.gnu.org	2003-09-17 07:17:18

Modified files:
	gcc            : ChangeLog cfgrtl.c toplev.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: cfg3.C 

Log message:
	PR optimization/11646
	* cfgrtl.c (purge_dead_edges) [JUMP_INSN]: Rematerialize the
	EDGE_ABNORMAL flag for EH edges.
	* toplev.c (rest_of_compilation): Delete unreachable blocks
	if dead edges were purged after the first CSE pass.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.739&r2=1.16114.2.740
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.61.2.11&r2=1.61.2.12
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/toplev.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.690.2.21&r2=1.690.2.22
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.280&r2=1.2261.2.281
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/cfg3.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 17 Eric Botcazou 2003-09-17 07:20:54 UTC
See http://gcc.gnu.org/ml/gcc-patches/2003-09/msg01007.html