Bug 54669 - [4.8 regression] verify_flow_info failure after loop unrolling with -fnon-call-exceptions
Summary: [4.8 regression] verify_flow_info failure after loop unrolling with -fnon-cal...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Eric Botcazou
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2012-09-22 10:41 UTC by Zdenek Sojka
Modified: 2012-09-23 20:39 UTC (History)
1 user (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work: 4.7.2
Known to fail: 4.8.0
Last reconfirmed: 2012-09-22 00:00:00


Attachments
reduced testcase (117 bytes, text/x-csrc)
2012-09-22 10:41 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2012-09-22 10:41:22 UTC
Created attachment 28247 [details]
reduced testcase

Compiler output:
$ gcc -O2 -fexceptions -fnon-call-exceptions testcase.c         
testcase.c: In function 'foo':
testcase.c:4:1: error: BB 5 last statement has incorrectly set lp
 foo (void)
 ^
testcase.c:4:1: internal compiler error: verify_flow_info failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


Backtrace:
(gdb) bt
#0  0x000000000111f2e0 in internal_error(char const*, ...) ()
#1  0x000000000069d48e in verify_flow_info() () at /mnt/svn/gcc-trunk/gcc/cfghooks.c:260
#2  0x0000000000a06825 in cleanup_tree_cfg() () at /mnt/svn/gcc-trunk/gcc/tree-cfgcleanup.c:693
#3  0x00000000010ea8d9 in tree_unroll_loops_completely(bool, bool) () at /mnt/svn/gcc-trunk/gcc/tree-ssa-loop-ivcanon.c:648
#4  0x0000000000ad64f2 in tree_complete_unroll_inner() ()
#5  0x00000000008fb90d in execute_one_pass(opt_pass*) () at /mnt/svn/gcc-trunk/gcc/passes.c:2199
#6  0x00000000008fbcc5 in execute_pass_list(opt_pass*) () at /mnt/svn/gcc-trunk/gcc/passes.c:2254
#7  0x00000000008fbcd7 in execute_pass_list(opt_pass*) () at /mnt/svn/gcc-trunk/gcc/passes.c:2255
#8  0x00000000006c0098 in expand_function(cgraph_node*) () at /mnt/svn/gcc-trunk/gcc/cgraphunit.c:1601
#9  0x00000000006c1f42 in compile() () at /mnt/svn/gcc-trunk/gcc/cgraphunit.c:1705
#10 0x00000000006c2535 in finalize_compilation_unit() () at /mnt/svn/gcc-trunk/gcc/cgraphunit.c:2080
#11 0x000000000059f930 in c_write_global_declarations() () at /mnt/svn/gcc-trunk/gcc/c/c-decl.c:10116
#12 0x00000000009e0a85 in compile_file() () at /mnt/svn/gcc-trunk/gcc/toplev.c:560
#13 0x00000000009e265a in toplev_main(int, char**) () at /mnt/svn/gcc-trunk/gcc/toplev.c:1863
#14 0x00007ffff69594bd in __libc_start_main () from /lib64/libc.so.6
#15 0x0000000000586611 in _start ()


Version:
$ gcc -v
Using built-in specs.
COLLECT_GCC=/mnt/svn/gcc-trunk/binary-latest/bin/gcc
COLLECT_LTO_WRAPPER=/mnt/svn/gcc-trunk/binary-191586-lto-fortran-checking-yes-rtl-df/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /mnt/svn/gcc-trunk//configure --enable-checking=yes,rtl,df --enable-languages=c,c++,lto,fortran --prefix=/mnt/svn/gcc-trunk/binary-191586-lto-fortran-checking-yes-rtl-df/ --without-cloog --without-ppl
Thread model: posix
gcc version 4.8.0 20120920 (experimental) (GCC) 


Tested revisions:
r191586 - crash
4.7 r188682 - OK
Comment 1 Marek Polacek 2012-09-22 13:30:11 UTC
Started with http://gcc.gnu.org/viewcvs?view=revision&revision=191387
Comment 2 Marek Polacek 2012-09-22 14:22:46 UTC
With very slightly modified testcase:
int a[10];

void
foo (void)
{
  int x;
  int i;
  for (i = 0; i < 1;)
    {
      int b[3];
      for (i = 0; i < 4; i++)
	b[i] = a[i];
      if (&x)
	a[0] = b[0];
    }
}

we get:

x.c: In function ‘foo’:
x.c:4:1: error: statement marked for throw, but doesn’t
 foo (void)
 ^
# VUSE <.MEM_15>
_16 = a[0];

x.c:4:1: error: statement marked for throw, but doesn’t
# .MEM_17 = VDEF <.MEM_15>
b[0] = _16;

x.c:4:1: error: statement marked for throw, but doesn’t
# VUSE <.MEM_17>
_21 = a[1];

x.c:4:1: error: statement marked for throw, but doesn’t
# .MEM_22 = VDEF <.MEM_17>
b[1] = _21;

x.c:4:1: error: statement marked for throw, but doesn’t
# VUSE <.MEM_22>
_26 = a[2];

x.c:4:1: error: statement marked for throw, but doesn’t
# .MEM_27 = VDEF <.MEM_22>
b[2] = _26;

x.c:4:1: error: statement marked for throw, but doesn’t
# VUSE <.MEM_27>
_31 = a[3];

x.c:4:1: internal compiler error: verify_gimple failed
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 3 Eric Botcazou 2012-09-22 19:50:11 UTC
I guess it's the transformation of array accesses with variable index into array accesses with fixed index in conjunction with -fnon-call-exceptions.
Comment 4 Eric Botcazou 2012-09-22 19:51:45 UTC
Fixing.
Comment 5 Marek Polacek 2012-09-22 20:03:59 UTC
It happens in cunrolli pass.  It might be propagate_constants_for_unrolling.  It seems we eventually end up removing BB 9 and 11, which might be wrong.
Comment 6 Eric Botcazou 2012-09-22 20:34:50 UTC
> It happens in cunrolli pass.  It might be propagate_constants_for_unrolling. 
> It seems we eventually end up removing BB 9 and 11, which might be wrong.

We just need to update the EH info after the transformation.
Comment 7 Eric Botcazou 2012-09-23 20:37:40 UTC
Author: ebotcazou
Date: Sun Sep 23 20:37:37 2012
New Revision: 191654

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=191654
Log:
	PR tree-optimization/54669
	* tree-ssa-loop-ivcanon.c (propagate_into_all_uses): Invoke
	maybe_clean_or_replace_eh_stmt on the modified use statements.

Added:
    trunk/gcc/testsuite/gcc.dg/pr54669.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-loop-ivcanon.c
Comment 8 Eric Botcazou 2012-09-23 20:39:43 UTC
Thanks for reporting the problem.