Bug 12215 - [3.3 regression] ICE in make_label_edge with -fnon-call-exceptions -fno-gcse -O2
[3.3 regression] ICE in make_label_edge with -fnon-call-exceptions -fno-gcse -O2
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: rtl-optimization
3.3.1
: P2 critical
: 3.3.2
Assigned To: Eric Botcazou
: ice-on-valid-code
: 12214 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-09-08 20:12 UTC by nick
Modified: 2003-10-06 09:26 UTC (History)
2 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-09-11 01:43:47


Attachments
bzip2 compressed preprocessed test case for pr 12215 (44.07 KB, application/octet-stream)
2003-09-08 20:14 UTC, nick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description nick 2003-09-08 20:12:20 UTC
The following code triggers an ICE in the 3.3.1 release:

/dept/rnd/vendor/gcc-3.3.1-notpatched/bin/g++ -E gcc331_ie.C > gcc331_ie.ii
/dept/rnd/vendor/gcc-3.3.1-notpatched/bin/g++ -fnon-call-exceptions -fno-gcse
-O2  gcc331_ie.ii -o gcc331_ie
gcc331_ie.C: In function `int main(int, const char**)':
gcc331_ie.C:39: internal compiler error: in make_label_edge, at cfgbuild.c:238
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

---------
#include <string>

void getArg( int &i, int argc, const char **argv, float &arg0 )
{
    if ( i < argc )
    {
        arg0 = atof( argv[i++] );
    }
}

int main (int argc, const char **argv)
{
    float               val = 0.0;
    int                 i = 1;

    //
    // Parse the arguments
    //
    try {
        while ( i < argc )
        {
            std::string arg( argv[i++]);

            if ( arg == "-" )
            {
                int e=0;
                throw( e );
            }
            else if ( arg == "-op" )
            {
                getArg( i, argc, argv, val );
            }
        }
    } catch (...) {

    }

    return 0;
}
-----

It compiles with 3.2.3.  It also compiles if gcse is enabled, but
bug 11646 is keeping us from doing that with the rest of the code :/

-nick
Comment 1 nick 2003-09-08 20:14:22 UTC
Created attachment 4719 [details]
bzip2 compressed preprocessed test case for pr 12215
Comment 2 nick 2003-09-08 20:18:30 UTC
*** Bug 12214 has been marked as a duplicate of this bug. ***
Comment 3 Wolfgang Bangerth 2003-09-11 01:43:47 UTC
Confirmed. A regression on 3.3 branch only.
W.
Comment 4 Wolfgang Bangerth 2003-09-11 02:05:25 UTC
This one was fairly painless compared to some of the optimization PRs:
---------------------------
struct B {
    ~B() throw() {}
};

struct X {
    X(const char*, const B&);
    ~X() {}
};

bool m();
void f(int &i, float &arg0);

void g (const char **argv) {
  float val;
  int i = 1;

  try {
    while ( i < 1 )
      {
        X arg(argv[i], B());
        if (m())
          throw(0);

        f(i, val);
      }
  } catch (...) {}
}
------------------------------------

It only fails with 3.3, but that doesn't mean that the bug is
not also present in latent form on mainline, of course:

g/x> /home/bangerth/bin/gcc-3.3.2-pre/bin/c++ -fnon-call-exceptions -fno-gcse
-O2 -c y.cc
y.cc: In function `void g(const char**)':
y.cc:27: internal compiler error: in make_label_edge, at cfgbuild.c:238
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

W.
Comment 5 Eric Botcazou 2003-09-11 17:07:22 UTC
Related to PR opt/11083. Investigating.
Comment 7 Mark Mitchell 2003-10-05 18:27:39 UTC
Subject: Re:  [3.3 regression] ICE in
	make_label_edge with -fnon-call-exceptions -fno-gcse -O2

On Fri, 2003-10-03 at 23:17, ebotcazou at gcc dot gnu dot org wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12215

Let's call the possibly-trapping insn I.  Let's call the next nonnote
insn after I N.

This patch changes the compiler to emit the new instruction (X) right
before N, rather than right after I.  Now, N and I are in different
basic blocks.  So, X will be executed any time control enters the block
containing N, even if not falling through from I.  Won't that be wrong?

Thanks,

Comment 8 Eric Botcazou 2003-10-06 07:20:23 UTC
No, because I think we are guaranteed that the control flow can't enter block(N)
without falling through from block(I) by cse_set_around_loop, because we are
guaranteed there is no label between them:

	      /* Look for an insn in front of LOOP_START that sets
		 something in the desired mode to SET_SRC (x) before we hit
		 a label or CALL_INSN.  */

	      for (p = prev_nonnote_insn (loop_start);
		   p && GET_CODE (p) != CALL_INSN
		   && GET_CODE (p) != CODE_LABEL;
		   p = prev_nonnote_insn  (p))

[sorry, I should have mentioned it in my first message].
Comment 9 Mark Mitchell 2003-10-06 07:45:59 UTC
Subject: Re:  [3.3 regression] ICE in
	make_label_edge with -fnon-call-exceptions -fno-gcse -O2

On Mon, 2003-10-06 at 00:20, ebotcazou at gcc dot gnu dot org wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12215

OK, it sounds like you've thought this through carefully, and your
explanation makes sense.

Your patch is OK, then.

Thanks,

Comment 10 CVS Commits 2003-10-06 09:18:09 UTC
Subject: Bug 12215

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	ebotcazou@gcc.gnu.org	2003-10-06 09:18:01

Modified files:
	gcc            : ChangeLog cse.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/opt: cfg2.C 

Log message:
	PR optimization/12215
	* cse.c (cse_set_around_loop): Emit the move at the beginning
	of the next basic block for trapping sets.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1297&r2=2.1298
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cse.c.diff?cvsroot=gcc&r1=1.271&r2=1.272
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3097&r2=1.3098
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/opt/cfg2.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 12 Eric Botcazou 2003-10-06 09:26:55 UTC
Original patch applied.