Bug 42386 - [4.5 Regression] ICE in ipcp_iterate_stage, at ipa-cp.c:766
Summary: [4.5 Regression] ICE in ipcp_iterate_stage, at ipa-cp.c:766
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: 4.5.0
Assignee: Jan Hubicka
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2009-12-15 23:12 UTC by Ryan Hill
Modified: 2009-12-17 20:56 UTC (History)
4 users (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-12-16 16:34:00


Attachments
Big5CodingSystem.ii (4.26 KB, text/plain)
2009-12-15 23:12 UTC, Ryan Hill
Details
gcc45-pr42386.patch (695 bytes, patch)
2009-12-16 17:20 UTC, Jakub Jelinek
Details | Diff
gcc45-pr42386.patch (630 bytes, patch)
2009-12-16 17:31 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Hill 2009-12-15 23:12:27 UTC
found compiling opensp:

$ g++ -O2 Big5CodingSystem.ii
Big5CodingSystem.cxx:65:1: internal compiler error: in ipcp_iterate_stage, at ipa-cp.c:766

$ gcc -v
Using built-in specs.
COLLECT_GCC=/usr/x86_64-unknown-linux-gnu/gcc-bin/4.5.0-pre9999/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0-pre9999/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.5.0_pre9999/work/gcc-4.5.0-9999/configure --prefix=/usr --bindir=/usr/x86_64-unknown-linux-gnu/gcc-bin/4.5.0-pre9999 --includedir=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.0-pre9999/include --datadir=/usr/share/gcc-data/x86_64-unknown-linux-gnu/4.5.0-pre9999 --mandir=/usr/share/gcc-data/x86_64-unknown-linux-gnu/4.5.0-pre9999/man --infodir=/usr/share/gcc-data/x86_64-unknown-linux-gnu/4.5.0-pre9999/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.5.0-pre9999/include/g++-v4 --host=x86_64-unknown-linux-gnu --build=x86_64-unknown-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-nls --with-system-zlib --disable-checking --disable-werror --enable-secureplt --enable-multilib --disable-libmudflap --disable-libssp --enable-libgomp --enable-cld --with-python-dir=/share/gcc-data/x86_64-unknown-linux-gnu/4.5.0-pre9999/python --disable-libgcj --enable-languages=c,c++ --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo SVN' --enable-lto --enable-checking
Thread model: posix
gcc version 4.5.0-pre9999 20091215 (experimental) rev. 155245 (Gentoo SVN)
Comment 1 Ryan Hill 2009-12-15 23:12:52 UTC
Created attachment 19314 [details]
Big5CodingSystem.ii
Comment 2 Richard Biener 2009-12-16 12:22:07 UTC
Confirmed.

# 1 "CodingSystem.h" 1
#pragma interface
# 1 "types.h" 1
# 15 "CodingSystem.h" 1
class Decoder { unsigned minBytesPerChar() const; };
class Encoder { class Handler {   }; };
class InputCodingSystem { virtual bool isIdentity() const; };
class OutputCodingSystem { public: virtual ~OutputCodingSystem(); 
virtual Encoder *makeEncoder() const = 0; };
class CodingSystem : public InputCodingSystem, public OutputCodingSystem 
{ public: ~CodingSystem() {} };
# 8 "Big5CodingSystem.h" 1
class Big5CodingSystem : public CodingSystem 
{   Decoder *makeDecoder() const;   Encoder *makeEncoder() const; };
Encoder *Big5CodingSystem::makeEncoder() const { }
Comment 3 H.J. Lu 2009-12-16 14:43:24 UTC
It is caused by revision 155143:

http://gcc.gnu.org/ml/gcc-cvs/2009-12/msg00287.html
Comment 4 Jakub Jelinek 2009-12-16 16:40:39 UTC
Both the base and deleting dtor in this case are !DECL_COMDAT, DECL_COMDAT_GROUP != NULL, DECL_EXTERNAL.  But they are emitted anyway, despite the DECL_EXTERNAL, as the base dtor is needed.
Comment 5 Jakub Jelinek 2009-12-16 17:04:49 UTC
Actually they aren't emitted, they are really just external.
And they are supposed to be external.

I guess we shouldn't "optimize" known external ctors or dtors.
The question then is whether for the DECL_DEFER_OUTPUT ones we sometimes don't keep node->same_comdat_group and/or node->same_body even when we decide at the end that they will be really external.
Comment 6 Jakub Jelinek 2009-12-16 17:20:29 UTC
Created attachment 19322 [details]
gcc45-pr42386.patch

Fix for this testcase.  If we already at maybe_clone_body time know that
the ctor or dtor will not be emitted in the current TU, we shouldn't create any same_body/same_comdat_group relations between the symbols.
The question is if for DECL_DEFER_OUTPUT we might decide later on that it is really DECL_EXTERNAL (i.e. not clear DECL_EXTERNAL on it).
Alternatively same_comdat_group could be only considered for !DECL_EXTERNAL decls.
Comment 7 H.J. Lu 2009-12-16 17:30:52 UTC
(In reply to comment #6)
> Created an attachment (id=19322) [edit]
> gcc45-pr42386.patch
> 
> Fix for this testcase.  If we already at maybe_clone_body time know that
> the ctor or dtor will not be emitted in the current TU, we shouldn't create any
> same_body/same_comdat_group relations between the symbols.
> The question is if for DECL_DEFER_OUTPUT we might decide later on that it is
> really DECL_EXTERNAL (i.e. not clear DECL_EXTERNAL on it).
> Alternatively same_comdat_group could be only considered for !DECL_EXTERNAL
> decls.
> 

Do we need those

# 1 "types.h" 1
# 15 "CodingSystem.h" 1

in testcase?
Comment 8 Jakub Jelinek 2009-12-16 17:31:17 UTC
Created attachment 19323 [details]
gcc45-pr42386.patch

Another alternative - don't mark nodes as reachable because of same_comdat_group links if they are DECL_EXTERNAL.  Fixes this too, and has the advantage that we don't have issues with DECL_DEFER_OUTPUT dtors we decided to keep DECL_EXTERNAL.
Comment 9 Jakub Jelinek 2009-12-16 17:33:46 UTC
Re: #c7, those 2 lines aren't needed, the other two # lines are needed as is #pragma interface.
Comment 10 Jason Merrill 2009-12-16 19:32:08 UTC
The second patch seems better.
Comment 11 Jakub Jelinek 2009-12-17 19:29:59 UTC
Subject: Bug 42386

Author: jakub
Date: Thu Dec 17 19:29:48 2009
New Revision: 155321

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155321
Log:
	PR c++/42386
	* ipa.c (function_and_variable_visibility): Clear same_comdat_group
	links of DECL_EXTERNAL nodes.

	* g++.dg/opt/dtor3.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/dtor3.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa.c
    trunk/gcc/testsuite/ChangeLog

Comment 12 Jakub Jelinek 2009-12-17 20:56:40 UTC
Fixed.
Comment 13 hjl@gcc.gnu.org 2009-12-22 18:18:15 UTC
Subject: Bug 42386

Author: hjl
Date: Tue Dec 22 18:17:53 2009
New Revision: 155403

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155403
Log:
Backport testcases from mainline.

2009-12-22  H.J. Lu  <hongjiu.lu@intel.com>

	Backport from mainline:
	2009-12-19  Dodji Seketeli  <dodji@redhat.com>

	PR c++/42225
	* g++.dg/template/typedef26.C: New test.

	2009-12-17  Jakub Jelinek  <jakub@redhat.com>

	PR c++/42386
	* g++.dg/opt/dtor3.C: New test.

	2009-12-15  Jason Merrill  <jason@redhat.com>

	PR c++/42358
	* g++.dg/cpp0x/variadic98.C: New.

	2009-12-13  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/42357
	* g++.dg/torture/pr42357.C: New testcase.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/cpp0x/variadic98.C
      - copied unchanged from r155402, trunk/gcc/testsuite/g++.dg/cpp0x/variadic98.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/dtor3.C
      - copied unchanged from r155402, trunk/gcc/testsuite/g++.dg/opt/dtor3.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef26.C
      - copied unchanged from r155402, trunk/gcc/testsuite/g++.dg/template/typedef26.C
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42357.C
      - copied unchanged from r155402, trunk/gcc/testsuite/g++.dg/torture/pr42357.C
Modified:
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog