Bug 62079 - [4.9 Regression] ICE: in calc_dfs_tree, at dominance.c:401 with -fnon-call-exceptions
Summary: [4.9 Regression] ICE: in calc_dfs_tree, at dominance.c:401 with -fnon-call-ex...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 4.9.2
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2014-08-10 10:13 UTC by Zdenek Sojka
Modified: 2014-09-09 11:43 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work: 4.7.4, 4.8.4, 5.0
Known to fail: 4.9.1
Last reconfirmed: 2014-08-11 00:00:00


Attachments
partially reduced testcase (568 bytes, text/x-csrc)
2014-08-10 10:13 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2014-08-10 10:13:44 UTC
Created attachment 33280 [details]
partially reduced testcase

Compiler output:
$ gcc -std=c++0x -O2 -fnon-call-exceptions testcase.C
testcase.C: In function 'int main()':
testcase.C:75:1: internal compiler error: in calc_dfs_tree, at dominance.c:401
 }
 ^
0x98b7ab calc_dfs_tree
        /mnt/svn/gcc-trunk/gcc/dominance.c:401
0x98c7c1 calculate_dominance_info(cdi_direction)
        /mnt/svn/gcc-trunk/gcc/dominance.c:662
0x9220a7 flow_loops_find(loops*)
        /mnt/svn/gcc-trunk/gcc/cfgloop.c:414
0xb903c7 loop_optimizer_init(unsigned int)
        /mnt/svn/gcc-trunk/gcc/loop-init.c:92
0x157db93 if_convert
        /mnt/svn/gcc-trunk/gcc/ifcvt.c:4427
0x157fe8d execute
        /mnt/svn/gcc-trunk/gcc/ifcvt.c:4650
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Tested revisions:
r213777 - ICE
4_9 r212703 - ICE
4_8 r212702 - OK
4_7 r211571 - OK
Comment 1 Richard Biener 2014-08-11 08:49:02 UTC
Mine.
Comment 2 Richard Biener 2014-08-13 13:17:34 UTC
Ok, so this is if-after-reload which calls loop_optimizer_init on a CFG
with an unreachable block.  Thus we miss a cfg-cleanup somewhere.

Note that regular ifcvt runs a cleanup_cfg (CLEANUP_EXPENSIVE), but
not if-after-combine or if-after-reload.

It's peephole2 that ends up with this bogus CFG.

Passes leaving dangling unreachable blocks should fix that up.
Comment 3 Richard Biener 2014-08-13 14:04:28 UTC
Funny that peep2s peep2_do_cleanup_cfg variable is write-only.  Bernd introduced that, a simple

Index: recog.c
===================================================================
--- recog.c     (revision 213909)
+++ recog.c     (working copy)
@@ -3553,6 +3553,8 @@ peephole2_optimize (void)
   BITMAP_FREE (live);
   if (peep2_do_rebuild_jump_labels)
     rebuild_jump_labels (get_insns ());
+  if (peep2_do_cleanup_cfg)
+    cleanup_cfg (CLEANUP_CFG_CHANGED);
 }
 #endif /* HAVE_peephole2 */
 
fixes the testcase.
Comment 4 Richard Biener 2014-08-14 08:57:14 UTC
Fixed on trunk sofar.
Comment 5 Richard Biener 2014-08-14 08:57:22 UTC
Author: rguenth
Date: Thu Aug 14 08:56:49 2014
New Revision: 213950

URL: https://gcc.gnu.org/viewcvs?rev=213950&root=gcc&view=rev
Log:
2014-08-14  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/62079
	* recog.c (peephole2_optimize): If peep2_do_cleanup_cfg
	run cleanup_cfg.

	* g++.dg/pr62079.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/pr62079.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/recog.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Richard Biener 2014-09-09 11:43:06 UTC
Author: rguenth
Date: Tue Sep  9 11:42:34 2014
New Revision: 215059

URL: https://gcc.gnu.org/viewcvs?rev=215059&root=gcc&view=rev
Log:
2014-09-09  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2014-08-05  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/61672
	* emit-rtl.h (mem_attrs_eq_p): Declare.
	* emit-rtl.c (mem_attrs_eq_p): Export.  Handle NULL mem-attrs.
	* cse.c (exp_equiv_p): Use mem_attrs_eq_p.
	* cfgcleanup.c (merge_memattrs): Likewise.
	Include emit-rtl.h.

	2014-08-11  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/62075
	* tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Properly
	handle uses in patterns.

	* gcc.dg/vect/pr62075.c: New testcase.

	2014-08-14  Richard Biener  <rguenther@suse.de>

	PR rtl-optimization/62079
	* recog.c (peephole2_optimize): If peep2_do_cleanup_cfg
	run cleanup_cfg.

	* g++.dg/pr62079.C: New testcase.


	2014-08-26  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/62175
	* tree-ssa-loop-niter.c (expand_simple_operations): Do not
	expand possibly trapping operations.

	* g++.dg/torture/pr62175.C: New testcase.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/pr62079.C
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/torture/pr62175.C
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr62075.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/cfgcleanup.c
    branches/gcc-4_9-branch/gcc/cse.c
    branches/gcc-4_9-branch/gcc/emit-rtl.c
    branches/gcc-4_9-branch/gcc/recog.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-ssa-loop-niter.c
    branches/gcc-4_9-branch/gcc/tree-vect-slp.c
Comment 7 Richard Biener 2014-09-09 11:43:22 UTC
Fixed.