Created attachment 32438 [details] Reduced C++ testfile.ii, compile with -O3 Follow-up to PR59176 ICE with -O3 in verify_cgraph_node. (-O2 is fine.) (In reply to David Binderman from PR59176 comment #15) > Created attachment 32434 [details] > gzipped C++ source code (In reply to Martin Jambor from PR59176 comment #17) > Although the ICE message is the same, this is most certainly a > different bug as it happens at a different time during the compilation > process. I will look it at it some more tomorrow.
Confirmed, mine.
Created attachment 32459 [details] Possible fix The problem is that IPA-CP skips thunks when it redirects edges to the new clones it produces. I am currently testing this patch which duplicates thunks when redirecting edges. It is quite possible it will have issues. In any event, Honza, do you have any comments?
Reduced testcase: struct A {}; struct E { ~E (); }; struct B { virtual unsigned foo () const; }; struct C { virtual void foo (); }; struct D : public A { D (A *); }; struct I : public D { A i; I (int) : D (0) {} }; struct F : E { virtual unsigned foo (bool) const; }; template <class T> struct G : public T {}; struct J : C, public F {}; struct K : public J { unsigned foo (bool) const { return 0; } }; struct H : B { H (A); unsigned foo () const { return bar ().foo (0); } const F &bar () const { return h; } G<K> h; }; template <class T> void baz () { I f (0); T d (f); } void test () { baz<H> (); } Regressed with r205019.
That is still too big, here is a smaller one: struct B { virtual unsigned f () const; }; struct C { virtual void f (); }; struct F { virtual unsigned f (bool) const; ~F (); }; struct J : C, F {}; struct G : J { unsigned f (bool) const { return 0; } }; struct H : B { H (int); unsigned f () const { return ((const F &) h).f (0); } G h; }; H h (0);
(In reply to Jakub Jelinek from comment #4) > That is still too big, here is a smaller one: > struct B { virtual unsigned f () const; }; > struct C { virtual void f (); }; > struct F { virtual unsigned f (bool) const; ~F (); }; > struct J : C, F {}; > struct G : J { unsigned f (bool) const { return 0; } }; > struct H : B > { > H (int); > unsigned f () const { return ((const F &) h).f (0); } > G h; > }; > H h (0); Though, on this reduced testcase the ICE started with r176424, i.e. making it a 4.7/4.8/4.9 Regression on that testcase.
I added the newest testcase to the patch a proposed it on the mailing list: http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01640.html
(In reply to Martin Jambor from comment #6) > I added the newest testcase to the patch a proposed it on the mailing list: > > http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01640.html I still see the old testcase only there ;).
Created attachment 32513 [details] Miscompiled run time testcase (In reply to Jakub Jelinek from comment #7) > > I still see the old testcase only there ;). Yeah, I forgot to refresh the patch, but I do have it in my copy. I'm also adding this one.
This one has them all, in addition to fixing a real problem: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00016.html
Created attachment 32523 [details] Proposed patch for the 4.8 branch Independent of the trunk fix, I'm going to propose this simple patch which disables propagation through thunks for the 4.8 branch. It passes bootstrap and testsuite on x86_64-linux.
Created attachment 32524 [details] Proposed patch for the 4.7 branch Independent of the trunk fix, I'm going to propose this simple patch which disables propagation through thunks for the 4.7 branch. It passes bootstrap and testsuite on x86_64-linux.
Author: jamborm Date: Fri Apr 4 14:11:06 2014 New Revision: 209097 URL: http://gcc.gnu.org/viewcvs?rev=209097&root=gcc&view=rev Log: 2014-04-04 Martin Jambor <mjambor@suse.cz> PR ipa/60640 * cgraph.h (cgraph_clone_node): New parameter added to declaration. Adjust all callers. * cgraph.c (clone_of_p): Also return true if thunks match. (verify_edge_corresponds_to_fndecl): Removed extraneous call to cgraph_function_or_thunk_node and an obsolete comment. * cgraphclones.c (build_function_type_skip_args): Moved upwards in the file. (build_function_decl_skip_args): Likewise. (set_new_clone_decl_and_node_flags): New function. (duplicate_thunk_for_node): Likewise. (redirect_edge_duplicating_thunks): Likewise. (cgraph_clone_node): New parameter args_to_skip, pass it to redirect_edge_duplicating_thunks which is called instead of cgraph_redirect_edge_callee. (cgraph_create_virtual_clone): Pass args_to_skip to cgraph_clone_node, moved setting of a lot of flags to set_new_clone_decl_and_node_flags. testsuite/ * g++.dg/ipa/pr60640-1.C: New test. * g++.dg/ipa/pr60640-2.C: Likewise. * g++.dg/ipa/pr60640-3.C: Likewise. * g++.dg/ipa/pr60640-4.C: Likewise. Added: trunk/gcc/testsuite/g++.dg/ipa/pr60640-1.C trunk/gcc/testsuite/g++.dg/ipa/pr60640-2.C trunk/gcc/testsuite/g++.dg/ipa/pr60640-3.C trunk/gcc/testsuite/g++.dg/ipa/pr60640-4.C Modified: trunk/gcc/ChangeLog trunk/gcc/cgraph.c trunk/gcc/cgraph.h trunk/gcc/cgraphclones.c trunk/gcc/ipa-inline-transform.c trunk/gcc/ipa-inline.c trunk/gcc/lto-cgraph.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk with http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00208.html I have posted the patch for the 4.8 branch: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00213.html and also for the 4.7 branch: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00215.html
Author: jamborm Date: Mon Apr 7 09:36:10 2014 New Revision: 209180 URL: http://gcc.gnu.org/viewcvs?rev=209180&root=gcc&view=rev Log: 2014-04-07 Martin Jambor <mjambor@suse.cz> PR ipa/60640 * ipa-cp.c (propagate_constants_accross_call): Do not propagate accross thunks. testsuite/ * g++.dg/ipa/pr60640-1.C: New test. * g++.dg/ipa/pr60640-2.C: Likewise. * g++.dg/ipa/pr60640-3.C: Likewise. Added: branches/gcc-4_8-branch/gcc/testsuite/g++.dg/ipa/pr60640-1.C branches/gcc-4_8-branch/gcc/testsuite/g++.dg/ipa/pr60640-2.C branches/gcc-4_8-branch/gcc/testsuite/g++.dg/ipa/pr60640-3.C Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/ipa-cp.c branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
Author: jamborm Date: Mon Apr 7 09:54:55 2014 New Revision: 209181 URL: http://gcc.gnu.org/viewcvs?rev=209181&root=gcc&view=rev Log: 2014-04-07 Martin Jambor <mjambor@suse.cz> PR ipa/60640 * ipa-cp.c (propagate_constants_accross_call): Do not propagate accross thunks. testsuite/ * g++.dg/ipa/pr60640-1.C: New test. * g++.dg/ipa/pr60640-2.C: Likewise. * g++.dg/ipa/pr60640-3.C: Likewise. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/ipa/pr60640-1.C branches/gcc-4_7-branch/gcc/testsuite/g++.dg/ipa/pr60640-2.C branches/gcc-4_7-branch/gcc/testsuite/g++.dg/ipa/pr60640-3.C Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/ipa-cp.c branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Fixed everywhere.