GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 22037 - [4.1 Regression] internal compiler error: verify_ssa failed
Summary: [4.1 Regression] internal compiler error: verify_ssa failed
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: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: ice-on-valid-code, monitored, patch
Depends on:
Blocks:
 
Reported: 2005-06-12 15:13 UTC by Mathieu Malaterre
Modified: 2005-08-04 18:17 UTC (History)
7 users (show)

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


Attachments
g++ -save-temps (106.76 KB, application/octet-stream)
2005-06-12 15:16 UTC, Mathieu Malaterre
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mathieu Malaterre 2005-06-12 15:13:19 UTC
I cannot compile VTK using gcc 4.1.0 (at least the one shipped in gcc-snapshot).

Step to reproduce (on debian testing system):

1. sudo apt-get install gcc-snapshot (as of today)
2. Get VTK source (CVS)
3. Compile line is:

/usr/lib/gcc-snapshot/bin/g++ -o vtkRungeKutta45.o -DvtkCommon_EXPORTS -Wall -W
-Wshadow -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual 
-Wno-deprecated -O3 -fPIC  -I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/Utilities
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/VolumeRendering
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/Rendering
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Parallel
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Hybrid
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/VolumeRendering
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Rendering
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Rendering/Testing/Cxx
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/IO
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Imaging
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Graphics
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/GenericFiltering
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Filtering
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Common
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Utilities
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Common/Testing/Cxx
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/Utilities/DICOMParser
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Utilities/DICOMParser
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/Utilities/vtkfreetype/include
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Utilities/vtkfreetype/include
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/Utilities/vtkfreetype
-I/home/mathieu/Dashboards/MyTests/ParaView/VTK/Utilities/ftgl/src
-I/home/mathieu/Dashboards/MyTests/VTK-gcc-snapshot/Utilities/ftgl
-I/usr/X11R6/include -I/usr/include/tcl8.4   -DVTK_IN_VTK  -c
/home/mathieu/Dashboards/MyTests/ParaView/VTK/Common/vtkRungeKutta45.cxx



Error is:

/home/mathieu/Dashboards/MyTests/ParaView/VTK/Common/vtkRungeKutta45.cxx: In
member function 'int vtkRungeKutta45::ComputeAStep(double*, double*, double*,
double, double&, double&)':
/home/mathieu/Dashboards/MyTests/ParaView/VTK/Common/vtkRungeKutta45.cxx:205:
error: Definition in block 76 follows the use
for SSA_NAME: A_428 in statement:
#   A_441 = V_MAY_DEF <A_428>;
#   B_442 = V_MAY_DEF <B_429>;
#   C_443 = V_MAY_DEF <C_430>;
#   DC_444 = V_MAY_DEF <DC_431>;
*error_48 = D.36281_47;
/home/mathieu/Dashboards/MyTests/ParaView/VTK/Common/vtkRungeKutta45.cxx:205:
internal compiler error: verify_ssa failed.
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Mathieu Malaterre 2005-06-12 15:14:34 UTC
Adding version:

$ /usr/lib/gcc-snapshot/bin/g++ --version                                      
               g++ (GCC) 4.1.0 20050607 (experimental) Copyright (C) 2005 Free
Software Foundation, Inc. This is free software; see the source for copying
conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Comment 2 Mathieu Malaterre 2005-06-12 15:16:26 UTC
Created attachment 9077 [details]
g++ -save-temps

Adding .ii using the compilation line with -save-temps
Comment 3 Andrew Pinski 2005-06-12 15:27:20 UTC
Copyprop4 is causing the ICE, I wonder if this is related to the bug which I reported to gcc@ when 
removing forwprop pass.
Comment 4 Andrew Pinski 2005-06-12 16:00:05 UTC
Confirmed, reduced testcase:
extern double sqrt (double __x) throw ();
int numDerivs1;
int ComputeAStep( double& error)
{
  int i, numDerivs;
  numDerivs = numDerivs1;
  for(i=0; i<numDerivs; i++)
    ;
  double err=0;
  for(i=0; i<numDerivs; i++)
      err += 1;
  error = sqrt(err);
  for(i=0; i<numDerivs; i++) 
    ;
  return 0;
}

Comment 5 Wolfgang Bangerth 2005-06-28 23:06:12 UTC
Cutting another line or two: 
------------------- 
extern double sqrt (double) throw (); 
 
void foo(double& d, int n) 
{ 
  double e=0; 
  for(int i=0; i<n; i++); 
  for(int i=0; i<n; i++) e=1; 
  d = sqrt(e); 
 
  for(int i=0; i<n; i++); 
} 
----------------------------- 
g/x> /home/bangerth/bin/gcc-4.1-pre/bin/c++ -c x.cc -O3 -fPIC 
x.cc: In function &#8216;void foo(double&, int)&#8217;: 
x.cc:3: error: Definition in block 6 follows the use 
for SSA_NAME: TMT.4_17 in statement: 
#   TMT.4_18 = V_MAY_DEF <TMT.4_17>; 
*d_10 = D.1741_9; 
x.cc:3: internal compiler error: verify_ssa failed. 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W. 
Comment 6 Diego Novillo 2005-06-29 20:19:24 UTC
We are folding sqrt(0) into 0 and not updating virtual operands properly.  Still
looking.
Comment 7 Andrew Pinski 2005-07-01 16:27:03 UTC
Actually I think this is worse than any can think.  The problem is that we have a VUSE on the sqrt which 
is wrong, we should have a V_MAY_DEF.

With an optimized (non bootstrapped) compiler, we get the correct results and on powerpc-darwin.
Comment 8 Andrew Pinski 2005-07-01 16:30:16 UTC
(In reply to comment #7)
in reply to this.  On powerpc-darwin we get the right answer but on i686-pc-linux-gnu, we don't, I 
have no idea why.
Comment 9 Andrew Pinski 2005-07-01 16:36:14 UTC
(In reply to comment #8)
> (In reply to comment #7)
> in reply to this.  On powerpc-darwin we get the right answer but on i686-pc-linux-gnu, we don't, I 
> have no idea why.

Ignore all this talk, the reason why I cannot reproduce it on ppc-darwin is because -fno-math-errno is 
default there.
Comment 10 Andrew Pinski 2005-07-01 17:08:24 UTC
The bug is really in cleanup_tree_cfg which is doing the merge of the two BBs.
This patch fixes the problem but I have not yet bootstrapped it yet:
Index: tree-cfg.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.207
diff -u -p -r2.207 tree-cfg.c
--- tree-cfg.c	28 Jun 2005 19:33:20 -0000	2.207
+++ tree-cfg.c	1 Jul 2005 17:07:35 -0000
@@ -1254,6 +1254,10 @@ replace_uses_by (tree name, tree val)
       tree rhs;
 
       fold_stmt_inplace (stmt);
+      mark_new_vars_to_rename (stmt);
+      
+      if (maybe_clean_or_replace_eh_stmt (stmt, stmt))
+	tree_purge_dead_eh_edges (bb_for_stmt (stmt));
 
       rhs = get_rhs (stmt);
       if (TREE_CODE (rhs) == ADDR_EXPR)
Index: tree-cfgcleanup.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/tree-cfgcleanup.c,v
retrieving revision 2.2
diff -u -p -r2.2 tree-cfgcleanup.c
--- tree-cfgcleanup.c	25 Jun 2005 02:01:15 -0000	2.2
+++ tree-cfgcleanup.c	1 Jul 2005 17:07:36 -0000
@@ -520,7 +520,11 @@ cleanup_tree_cfg (void)
 
   /* Merging the blocks creates no new opportunities for the other
      optimizations, so do it here.  */
-  retval |= merge_seq_blocks ();
+  if (merge_seq_blocks ())
+    {
+      retval = true;
+      update_ssa (TODO_update_ssa_only_virtuals);
+    }
 
   compact_blocks ();
 
Comment 11 Andrew Pinski 2005-07-02 14:30:54 UTC
(In reply to comment #10)
> The bug is really in cleanup_tree_cfg which is doing the merge of the two BBs.
> This patch fixes the problem but I have not yet bootstrapped it yet:
This patch does not bootstrap.  I think it is better to disable the optimization in tree cfg and let leter 
tree passes fix it up.

I am looking into fix it still.
Comment 12 Andrew Pinski 2005-07-02 18:32:02 UTC
Here is a patch fixes the problem:
Index: tree-cfg.c
===============================================================
====
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.207
diff -u -p -r2.207 tree-cfg.c
--- tree-cfg.c	28 Jun 2005 19:33:20 -0000	2.207
+++ tree-cfg.c	2 Jul 2005 18:29:46 -0000
@@ -1298,10 +1298,12 @@ tree_merge_blocks (basic_block a, basic_
       tree copy;
       
       if (!may_propagate_copy (def, use)
-	  /* Propagating pointers might cause the set of vops for statements
-	     to be changed, and thus require ssa form update.  */
+	  /* Propagating pointers and constants might cause the
+	     set of vops for statements to be changed, and thus
+	     require ssa form update.  */
 	  || (is_gimple_reg (def)
-	      && POINTER_TYPE_P (TREE_TYPE (def))))
+	      && (POINTER_TYPE_P (TREE_TYPE (def))
+		  || TREE_CONSTANT (use))))
 	{
 	  gcc_assert (is_gimple_reg (def));
 


Hopefully it is not too permissive, we do allow the later passes fix up the permissiveness.
Comment 13 Andrew Pinski 2005-07-04 10:38:50 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-07/msg00155.html>.
Comment 14 CVS Commits 2005-08-04 18:16:48 UTC
Subject: Bug 22037

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	dnovillo@gcc.gnu.org	2005-08-04 18:16:41

Modified files:
	gcc            : ChangeLog passes.c tree-cfg.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/tree-ssa: pr22037.C 

Log message:
	PR 22037
	* tree-cfg.c (replace_uses_by): Call mark_new_vars_to_rename.
	(tree_merge_blocks): Propagate anything allowed by
	may_propagate_copy.
	Clarify documentation.
	* passes.c (execute_todo): If cleanup_tree_cfg invalidated the
	SSA form, schedule an update if necessary.
	
	testsuite/ChangeLog
	
	PR 22037
	* g++.dg/tree-ssa/pr22037.C:

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.9654&r2=2.9655
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/passes.c.diff?cvsroot=gcc&r1=2.108&r2=2.109
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-cfg.c.diff?cvsroot=gcc&r1=2.213&r2=2.214
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5877&r2=1.5878
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/tree-ssa/pr22037.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 15 Diego Novillo 2005-08-04 18:17:41 UTC
Fixed.  http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00283.html.