Bug 61654 - [4.9/5 Regression] ICE in release_function_body, at cgraph.c:1699
Summary: [4.9/5 Regression] ICE in release_function_body, at cgraph.c:1699
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.9.0
: P2 normal
Target Milestone: 4.9.2
Assignee: Martin Jambor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-30 06:48 UTC by Manuel Lauss
Modified: 2014-09-12 16:53 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build:
Known to work: 4.8.3, 4.8.4
Known to fail: 4.9.0, 4.9.1, 5.0
Last reconfirmed: 2014-06-30 00:00:00


Attachments
preprocessed source (58.41 KB, text/plain)
2014-06-30 06:48 UTC, Manuel Lauss
Details
gcc410-pr61654.patch (545 bytes, patch)
2014-07-03 13:59 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Lauss 2014-06-30 06:48:27 UTC
Created attachment 33032 [details]
preprocessed source

current gcc-4_9-branch, ICE with "-O3". -O2 works; gcc-4.8.3 handles "-O3" fine
as well.

(source is scummvm-1.6.0/engines/tony/font.cpp)

i686-pc-linux-gnu-g++ -O3 -c font.i
In file included from ./engines/tony/input.h:32:0,
                 from engines/tony/font.cpp:32:
./common/events.h: In function '<built-in>':
./common/events.h:239:7: internal compiler error: in release_function_body, at cgraph.c:1699

Thanks!
Comment 1 Markus Trippelsdorf 2014-06-30 07:05:11 UTC
markus@x4 tmp % cat font.ii
class A
{
  virtual int m_fn1 (int, int = 0) = 0;
  int m_fn2 (const int &);
  int _nPrior;
};
class B : virtual A
{
  int _lDefault;
  int m_fn1 (int, int);
};
int A::m_fn2 (const int &) { return m_fn1 ('\0'); }

int B::m_fn1 (int, int) { return 0 ?: _lDefault; }


markus@x4 tmp % g++ -m32 -c -O3 font.ii
font.ii: In function ‘<built-in>’:
font.ii:14:50: internal compiler error: in release_function_body, at cgraph.c:1691
 int B::m_fn1 (int, int) { return 0 ?: _lDefault; }
                                                  ^
0x841577 release_function_body(tree_node*)
        ../../gcc/gcc/cgraph.c:1691
0x841626 cgraph_release_function_body(cgraph_node*)
        ../../gcc/gcc/cgraph.c:1727
0x841aa6 cgraph_remove_node(cgraph_node*)
        ../../gcc/gcc/cgraph.c:1812
0xa1c3eb symtab_remove_unreachable_nodes(bool, _IO_FILE*)
        ../../gcc/gcc/ipa.c:463
0xace957 execute_todo
        ../../gcc/gcc/passes.c:1843
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.
Comment 2 Markus Trippelsdorf 2014-06-30 07:19:21 UTC
git blame points to r209892.
Comment 3 Jakub Jelinek 2014-07-03 13:59:30 UTC
Created attachment 33061 [details]
gcc410-pr61654.patch

Untested fix.
Comment 4 Manuel Lauss 2014-07-04 07:04:04 UTC
The patch shifted the ICE to the following, same source file:

In file included from ./engines/tony/input.h:32:0,
                 from engines/tony/font.cpp:32:
./common/events.h:239:7: internal compiler error: in ipa_propagate_frequency, at ipa-profile.c:411
 class DefaultEventMapper : public EventMapper {
       ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://bugs.gentoo.org/> for instructions.
Makefile.common:98: recipe for target 'engines/tony/font.o' failed
Comment 5 Jakub Jelinek 2014-07-04 08:39:16 UTC
Author: jakub
Date: Fri Jul  4 08:38:45 2014
New Revision: 212293

URL: https://gcc.gnu.org/viewcvs?rev=212293&root=gcc&view=rev
Log:
	PR middle-end/61654
	* cgraphunit.c (expand_thunk): Call free_dominance_info.

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

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr61654.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraphunit.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 Jakub Jelinek 2014-07-04 08:40:03 UTC
Author: jakub
Date: Fri Jul  4 08:39:31 2014
New Revision: 212294

URL: https://gcc.gnu.org/viewcvs?rev=212294&root=gcc&view=rev
Log:
	PR middle-end/61654
	* cgraphunit.c (expand_thunk): Call free_dominance_info.

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

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/opt/pr61654.C
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/cgraphunit.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 7 Jakub Jelinek 2014-07-04 09:16:47 UTC
Reduced testcase for the other ICE, ICEs only with -O3 -m32 and not with -O3 -m64 on x86_64-linux:
struct A
{
  virtual int a (int, int = 0);
  void b ();
  void c ();
  int d;
};

struct B : virtual A
{
  int a (int, int);
  int e;
};

int f;

void
A::b ()
{
  a (0);
}

void
A::c ()
{
  a (f);
}

int
B::a (int, int)
{
  return e;
}
Comment 8 Richard Biener 2014-07-07 11:05:57 UTC
The reduced testcase doesn't ICE on the branch, the full preprocessed source does.
Comment 9 Jakub Jelinek 2014-07-07 11:38:07 UTC
Richard mentioned that #c7 doesn't ICE on the 4.9 branch, only trunk.  This one ICEs on the 4.9 branch too (the only change is " = 0", i.e. making A::a pure virtual), again -O3 -m32 is needed:

struct A
{
  virtual int a (int, int = 0) = 0;
  void b ();
  void c ();
  int d;
};

struct B : virtual A
{
  int a (int, int);
  int e;
};

int f;

void
A::b ()
{
  a (0);
}

void
A::c ()
{
  a (f);
}

int
B::a (int, int)
{
  return e;
}
Comment 10 Jakub Jelinek 2014-07-16 13:27:24 UTC
GCC 4.9.1 has been released.
Comment 11 Martin Jambor 2014-07-24 15:16:53 UTC
ipa_propagate_frequency is seeing an artificial_thunk.  Mine.
Comment 12 Martin Jambor 2014-09-03 08:48:47 UTC
I have proposed a fix on the mailing list:

https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00207.html
Comment 13 Martin Jambor 2014-09-10 11:34:41 UTC
Author: jamborm
Date: Wed Sep 10 11:34:09 2014
New Revision: 215122

URL: https://gcc.gnu.org/viewcvs?rev=215122&root=gcc&view=rev
Log:
2014-09-10  Martin Jambor  <mjambor@suse.cz>

	PR ipa/61654
	* cgraphclones.c (duplicate_thunk_for_node): Copy arguments of the
	new decl properly.  Analyze the new thunk if it is expanded.

gcc/testsuite/
	* g++.dg/ipa/pr61654.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/ipa/pr61654.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraphclones.c
    trunk/gcc/testsuite/ChangeLog
Comment 14 Martin Jambor 2014-09-12 16:52:56 UTC
Author: jamborm
Date: Fri Sep 12 16:52:24 2014
New Revision: 215228

URL: https://gcc.gnu.org/viewcvs?rev=215228&root=gcc&view=rev
Log:
2014-09-12  Martin Jambor  <mjambor@suse.cz>

	PR ipa/61654
	* cgraph.h (cgraph_analyze_function): Declare.
	* cgraphunit.c: (analyze_function): Remove forward declaration,
	rename to cgraph_analyze_function, made external.
	* cgraphclones.c (duplicate_thunk_for_node): Copy arguments of the
        new decl properly.  Analyze the new thunk if it is expanded.

gcc/testsuite/
        * g++.dg/ipa/pr61654.C: New test.


Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/ipa/pr61654.C
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/cgraph.h
    branches/gcc-4_9-branch/gcc/cgraphclones.c
    branches/gcc-4_9-branch/gcc/cgraphunit.c
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
Comment 15 Martin Jambor 2014-09-12 16:53:49 UTC
Fixed.