Bug 29610 - [4.1 Regression] ICE when compiling c++ code with -O2 -funswitch-loops
Summary: [4.1 Regression] ICE when compiling c++ code with -O2 -funswitch-loops
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: 4.1.2
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-10-27 01:22 UTC by John Schmidt
Modified: 2006-11-11 12:52 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.3.0
Known to fail: 4.1.2
Last reconfirmed: 2006-11-01 13:21:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Schmidt 2006-10-27 01:22:20 UTC
Get an ICE when compiling c++ code with optimization turned on.

gcc -v:

Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --with-tune=i686 --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.1.2 20061020 (prerelease) (Debian 4.1.1-17)


Compile command:


g++ -Wall -march=pentium4 -msse -msse2 -O3    -I/usr/local/Thirdparty/1.25.3/Linux/gcc-4.1.2-32bit///include -I/usr/local/Thirdparty/1.25.3/Linux/gcc-4.1.2-32bit//src/tcl/generic -I/usr/local/Thirdparty/1.25.3/Linux/gcc-4.1.2-32bit//src/tk/generic -I/usr/local/Thirdparty/1.25.3/Linux/gcc-4.1.2-32bit//src/tk/unix -I/usr/local/Thirdparty/1.25.3/Linux/gcc-4.1.2-32bit//include/libxml2 -I../src/include -I../src -I. -I./include -I../src/Packages -I/usr/X11R6/include -I/usr/include/petsc -I/usr/include/mpi -I/usr/include/freetype2  -c ../src/Dataflow/Modules/Render/Painter.cc -o Dataflow/Modules/Render/Painter.o
../src/Dataflow/Modules/Render/Painter.cc: In member function 'virtual void SCIRun::Painter::tcl_command(SCIRun::GuiArgs&, void*)':
../src/Dataflow/Modules/Render/Painter.cc:2345: internal compiler error: in dominated_by_p, at dominance.c:827
Comment 1 John Schmidt 2006-10-27 01:36:18 UTC
Preprocessed source:


http://www.sci.utah.edu/~jas/cchBu06i.out
Comment 2 Andrew Pinski 2006-10-27 01:43:33 UTC
Reducing ...
Comment 3 Andrew Pinski 2006-10-27 17:46:37 UTC
Confirmed, reduced testcase:
struct __normal_iterator 
{
  typedef int*const *_Iterator;
  int*const * _M_current;
  __normal_iterator(const _Iterator& __i) : _M_current(__i){}
  const _Iterator& base() const {}
};
struct string { ~string(){} };
struct vector 
{
  int** _M_finish;
  __normal_iterator end() const   { return __normal_iterator (_M_finish); }
  int size() const   { return end().base() - end().base(); }
};
class Painter
{
  int redraw_window(void);
  typedef int (Painter::* SliceWindowFunc)(void);
  int for_each(vector&, SliceWindowFunc);
  void tcl_command(void);
};
inline int Painter::for_each(vector &layout, SliceWindowFunc func)
{
    for (unsigned int window = 0; window < layout.size();++window)
        (this->*func)();
}
int t;
int Painter::redraw_window(void) {t = 1;}
string t2(int);
vector *g(const string&);
void Painter::tcl_command(void)
{
     for_each(*g(t2(2)), &Painter::redraw_window);
}
Comment 4 Richard Biener 2006-11-01 13:21:42 UTC
sccp destroys dominators, unswitching only enables the sccp opportunity.  The
destroying happens in cleanup_tree_cfg calling cleanup_control_flow calling
tree_purge_dead_eh_edges which we don't record the true return value here even
if it frees dominators, so dominators are not re-computed later in cleanup_tree_cfg_loop.

We enter the function with the following BB:

;; basic block 5, loop depth 1, count 0
;; prev block 4, next block 6
;; pred:       4 [95.0%]  (true,exec)
;; succ:       6 [100.0%]  (fallthru,exec) 10 (ab,eh,loop_exit,exec)
<L16>:;
#   D.1861_45 = V_MAY_DEF <D.1861_50>;
#   TMT.44_3 = V_MAY_DEF <TMT.44_22>;
#   TMT.45_4 = V_MAY_DEF <TMT.45_53>;
#   TMT.46_5 = V_MAY_DEF <TMT.46_123>;
#   TMT.47_6 = V_MAY_DEF <TMT.47_124>;
#   TMT.49_7 = V_MAY_DEF <TMT.49_125>;
redraw_window (this_20);
Comment 5 Richard Biener 2006-11-01 13:25:07 UTC
This problem is latent on the mainline as well.
Comment 6 patchapp@dberlin.org 2006-11-05 20:35:30 UTC
Subject: Bug number PR29610

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00015.html
Comment 7 Richard Biener 2006-11-07 17:29:47 UTC
Subject: Bug 29610

Author: rguenth
Date: Tue Nov  7 17:29:34 2006
New Revision: 118555

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118555
Log:
2006-11-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/29610
	* tree-cfgcleanup.c (cleanup_control_flow): Honor return value
	of tree_purge_dead_eh_edges as it may free dominators.

	* g++.dg/other/pr29610.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/other/pr29610.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-cfgcleanup.c

Comment 8 Richard Biener 2006-11-07 17:32:15 UTC
Subject: Bug 29610

Author: rguenth
Date: Tue Nov  7 17:32:03 2006
New Revision: 118556

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118556
Log:
2006-11-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/29610
	* tree-cfgcleanup.c (cleanup_control_flow): Honor return value
	of tree_purge_dead_eh_edges as it may free dominators.

	* g++.dg/other/pr29610.C: New testcase.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/g++.dg/other/pr29610.C
      - copied unchanged from r118555, trunk/gcc/testsuite/g++.dg/other/pr29610.C
Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/tree-cfgcleanup.c

Comment 9 Richard Biener 2006-11-07 17:33:49 UTC
Subject: Bug 29610

Author: rguenth
Date: Tue Nov  7 17:33:38 2006
New Revision: 118557

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118557
Log:
2006-11-07  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/29610
	* tree-cfgcleanup.c (cleanup_control_flow): Honor return value
	of tree_purge_dead_eh_edges as it may free dominators.

	* g++.dg/other/pr29610.C: New testcase.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/g++.dg/other/pr29610.C
      - copied unchanged from r118555, trunk/gcc/testsuite/g++.dg/other/pr29610.C
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/tree-cfgcleanup.c

Comment 10 Richard Biener 2006-11-11 12:52:47 UTC
Fixed.