Bug 48953 - [4.7 Regression] ICE: verify_gimple failed: type mismatch in array reference with -flto and struct with vararray
Summary: [4.7 Regression] ICE: verify_gimple failed: type mismatch in array reference ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code, lto
Depends on:
Blocks:
 
Reported: 2011-05-10 17:36 UTC by Zdenek Sojka
Modified: 2011-05-31 12:24 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work: 4.6.1
Known to fail: 4.7.0
Last reconfirmed: 2011-05-11 04:01:47


Attachments
reduced testcase (118 bytes, text/plain)
2011-05-10 17:36 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2011-05-10 17:36:08 UTC
Created attachment 24219 [details]
reduced testcase

Compiler output:
$ gcc -O -flto -fno-tree-dce testcase.c 
In file included from :0:0:
testcase.c: In function 'main':
testcase.c:11:5: error: type mismatch in array reference
struct S

struct S

# .MEM_11 = VDEF <.MEM_10>
MEM[(struct S[2] *)s.1_7][0]{lb: 0 sz: 12}.value = 0;

testcase.c:11:5: 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.
lto-wrapper: /mnt/svn/gcc-trunk/binary-latest/bin/gcc returned 1 exit status
collect2: lto-wrapper returned 1 exit status

Tested revisions:
r173586 - crash
4.6 r173059 - OK (yes,rtl,df checking)
Comment 1 H.J. Lu 2011-05-11 04:01:47 UTC
It is caused by revision 172516:

http://gcc.gnu.org/ml/gcc-cvs/2011-04/msg00711.html
Comment 2 Richard Biener 2011-05-11 09:41:45 UTC
The rev. allowed inlining to happen.  We end up with two copies of type S
for some reason - inlining is supposed to copy variable-size types but
probably does not adjust reference tree types to those copies.  I'm not sure
why this doesn't trigger without LTO (we inline during early inlining).

I suppose the two types also exist w/o LTO but they are marked compatible
via TYPE_CANONICAL which isn't re-set by copy_node.  Thus, this is an
issue with re-constructing TYPE_CANONICAL.

Mine.
Comment 3 Richard Biener 2011-05-11 12:23:15 UTC
Author: rguenth
Date: Wed May 11 12:23:12 2011
New Revision: 173653

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

	PR middle-end/48953
	* tree-inline.c (remap_gimple_op_r): Also remap types of MEM_REFs.

	* gcc.dg/torture/pr48953.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr48953.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c
Comment 4 Richard Biener 2011-05-11 12:23:49 UTC
Fixed on trunk, queued for backporting.
Comment 5 Richard Biener 2011-05-31 12:23:58 UTC
Author: rguenth
Date: Tue May 31 12:23:55 2011
New Revision: 174475

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174475
Log:
2011-05-31  Richard Guenther  <rguenther@suse.de>

	Backport from mainline
	2011-05-11  Richard Guenther  <rguenther@suse.de>

	PR middle-end/48953
	* tree-inline.c (remap_gimple_op_r): Also remap types of MEM_REFs.

	* gcc.dg/torture/pr48953.c: New testcase.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/torture/pr48953.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-inline.c
Comment 6 Richard Biener 2011-05-31 12:24:14 UTC
Fixed.