Bug 41775 - [4.5 Regression] IPA-SRA: ice in rewrite_stmt, at tree-into-ssa.c:1302
Summary: [4.5 Regression] IPA-SRA: ice in rewrite_stmt, at tree-into-ssa.c:1302
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P1 normal
Target Milestone: 4.5.0
Assignee: Martin Jambor
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-10-21 04:13 UTC by John Regehr
Modified: 2009-10-29 12:50 UTC (History)
4 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 4.4.2
Known to fail:
Last reconfirmed: 2009-10-21 15:05:11


Attachments
failure inducing input (1.86 KB, text/x-c++src)
2009-10-21 04:13 UTC, John Regehr
Details
Proposed fix (2.91 KB, patch)
2009-10-26 21:53 UTC, Martin Jambor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description John Regehr 2009-10-21 04:13:02 UTC
This ice prevents the gcc svn head from building the LLVM svn head.

regehr@john-home:~/volatile/tmp208$ current-g++ -c -O3 small.cpp
small.cpp: In member function ‘(anonymous namespace)::StrongPHIElimination::runOnMachineFunction(llvm::MachineFunction&)’:
small.cpp:281:1: internal compiler error: in rewrite_stmt, at tree-into-ssa.c:1302
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

regehr@john-home:~/volatile/tmp208$ current-g++ -v

Using built-in specs.
COLLECT_GCC=current-g++
COLLECT_LTO_WRAPPER=/home/regehr/z/tmp/gcc-r153044-install/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../configure --enable-lto --prefix=/home/regehr/z/tmp/gcc-r153044-install --program-prefix=r153044- --enable-languages=c,c++
Thread model: posix
gcc version 4.5.0 20091020 (experimental) (GCC)
Comment 1 John Regehr 2009-10-21 04:13:37 UTC
Created attachment 18848 [details]
failure inducing input
Comment 2 Richard Biener 2009-10-21 12:31:39 UTC
Confirmed.

Looks like invalid tree-sharing.  On

(gdb) call debug_gimple_stmt (stmt)
# .MEM = VDEF <.MEM>
llvm::LiveInterval::removeRange (PI_10, D.2378_13->start, D.2378_13->end, 1);

we have replaced the first use but on replacing the 2nd one
the INDIRECT_REF was shared.

Both built from

#1  0x0888e476 in build_ref_for_offset_1 (res=0xbffff068, type=0xb7d72a8c, 
    offset=0, exp_type=0xb7d728fc)
    at /home/richard/src/trunk/gcc/tree-sra.c:1255
1255			  expr = build3 (COMPONENT_REF, TREE_TYPE (fld), *res, fld,

without unsharing *res.

Thus, this is IPA-SRA.
Comment 3 Martin Jambor 2009-10-26 21:53:36 UTC
Created attachment 18903 [details]
Proposed fix

Indeed, the users of build_ref_for_offset in ipa-prop.c and ipa-cp.c
do not unshare the base expressions they should.  I have looked at all
other users and found that they either pass declarations or do their
own unsharing and so decided to move the unsharing to
build_ref_for_offset itself.  The attached patch fixes the ICE when
compiling the testcase, I am currently bootstrapping it.
Comment 4 Martin Jambor 2009-10-27 18:04:26 UTC
I have just sent the patch to the mailing list:

http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01625.html

I had to change the testcase a bit so that it compiles on x86_64.
Comment 5 Uroš Bizjak 2009-10-27 19:35:28 UTC
(In reply to comment #4)
> I have just sent the patch to the mailing list:
> 
> http://gcc.gnu.org/ml/gcc-patches/2009-10/msg01625.html
> 
> I had to change the testcase a bit so that it compiles on x86_64.

You should also add:

 // { dg-require-visibility "" }
Comment 6 Martin Jambor 2009-10-29 12:41:39 UTC
Subject: Bug 41775

Author: jamborm
Date: Thu Oct 29 12:40:48 2009
New Revision: 153699

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153699
Log:
2009-10-29  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/41775
	* tree-sra.c (build_ref_for_offset): Unshare *expr if not NULL.
	(generate_subtree_copies): Do not unshare agg.
	(load_assign_lhs_subreplacements): Do not unshare rhs.
	(sra_modify_assign): Do not unshare exprs.
	(propagate_subacesses_accross_link): Renamed to
	propagate_subaccesses_across_link.

	* testsuite/g++.dg/torture/pr41775.C: New testcase.



Added:
    trunk/gcc/testsuite/g++.dg/torture/pr41775.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c

Comment 7 Martin Jambor 2009-10-29 12:50:58 UTC
I did.  This is now fixed.
Comment 8 hjl@gcc.gnu.org 2009-10-30 16:05:31 UTC
Subject: Bug 41775

Author: hjl
Date: Fri Oct 30 16:04:41 2009
New Revision: 153759

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153759
Log:
2009-10-30  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2009-10-30  Dodji Seketeli  <dodji@redhat.com>

	PR c++/41863
	* g++.dg/template/sizeof12.C: New test.

	2009-10-29  Martin Jambor  <mjambor@suse.cz>

	PR tree-optimization/41775
	* g++.dg/torture/pr41775.C: New testcase.

	2009-10-28  Jakub Jelinek  <jakub@redhat.com>

	PR debug/41801
	* g++.dg/ext/sync-3.C: New test.

	2009-10-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/41020
	* g++.dg/lookup/extern-c-redecl5.C: Fix up regexp.

	2009-10-26  Jakub Jelinek  <jakub@redhat.com>

	PR bootstrap/41345
	* gcc.dg/pr41345.c: New test.

	2009-10-26  Dodji Seketeli  <dodji@redhat.com>

	PR c++/41785
	* g++.dg/cpp0x/variadic96.C: New test.

	2009-10-26  Dodji Seketeli  <dodji@redhat.com>

	PR c++/41020
	* g++.dg/lookup/extern-c-redecl2.C: New test.
	* g++.dg/lookup/extern-c-redecl3.C: Likewise.
	* g++.dg/lookup/extern-c-redecl4.C: Likewise.
	* g++.dg/lookup/extern-c-redecl5.C: Likewise.

	2009-10-23  Joseph Myers  <joseph@codesourcery.com>

	PR c/40033
	* gcc.dg/noncompile/pr40033-1.c: New test.

	2009-10-23  Joseph Myers  <joseph@codesourcery.com>

	PR c/41673
	* gcc.dg/Wstrict-aliasing-bogus-vla-1.c: New test.

	2009-10-21  Sebastian Pop  <sebastian.pop@amd.com>

	PR tree-optimization/41497
	* gcc.dg/tree-ssa/pr41497.c: New.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/variadic96.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/cpp0x/variadic96.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/ext/sync-3.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/ext/sync-3.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl2.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl3.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl4.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/lookup/extern-c-redecl5.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/sizeof12.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/template/sizeof12.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr41775.C
      - copied unchanged from r153757, trunk/gcc/testsuite/g++.dg/torture/pr41775.C
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c
      - copied unchanged from r153758, trunk/gcc/testsuite/gcc.dg/Wstrict-aliasing-bogus-vla-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/noncompile/pr40033-1.c
      - copied unchanged from r153758, trunk/gcc/testsuite/gcc.dg/noncompile/pr40033-1.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr41345.c
      - copied unchanged from r153757, trunk/gcc/testsuite/gcc.dg/pr41345.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c
      - copied unchanged from r153758, trunk/gcc/testsuite/gcc.dg/tree-ssa/pr41497.c
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog