trippels@gcc2-power8 linux-3.18.8 % cat libcxgbi.i extern void *memcpy(void *, const void *, unsigned long); struct in6_addr { struct { int u6_addr32[4]; }; }; struct foo { struct in6_addr daddr; struct in6_addr saddr; } a; extern void ip6_route_output(struct foo, int); int b; static void find_route_ipv6(struct in6_addr *p1) { if (p1) memcpy(0, p1, sizeof(struct in6_addr)); ip6_route_output(a, b); } void cxgbi_ep_connect() { find_route_ipv6(0); } trippels@gcc2-power8 linux-3.18.8 % gcc -O2 -c libcxgbi.i libcxgbi.i: In function ‘find_route_ipv6.constprop’: libcxgbi.i:18:1: internal compiler error: in as_a, at is-a.h:192 void cxgbi_ep_connect() { find_route_ipv6(0); } ^ 0x100f16e3 as_a<gcall*, gimple_statement_base> ../../gcc/gcc/is-a.h:192 0x1030ffb7 as_a<gcall*, gimple_statement_base> ../../gcc/gcc/is-a.h:192 0x1030ffb7 cgraph_update_edges_for_call_stmt_node ../../gcc/gcc/cgraph.c:1524 0x1031045f cgraph_update_edges_for_call_stmt(gimple_statement_base*, tree_node*, gimple_statement_base*) ../../gcc/gcc/cgraph.c:1588 0x108720a3 fold_marked_statements ../../gcc/gcc/tree-inline.c:4843 0x10884ebf tree_function_versioning(tree_node*, tree_node*, vec<ipa_replace_map*, va_gc, vl_embed>*, bool, bitmap_head*, bool, bitmap_head*, basic_block_def*) ../../gcc/gcc/tree-inline.c:5813 0x103229ef cgraph_materialize_clone ../../gcc/gcc/cgraphclones.c:1056 0x103229ef symbol_table::materialize_all_clones() ../../gcc/gcc/cgraphclones.c:1153 0x1031c3cb symbol_table::compile() ../../gcc/gcc/cgraphunit.c:2326 0x1031ee67 symbol_table::finalize_compilation_unit() ../../gcc/gcc/cgraphunit.c:2444 0x1015d1c7 c_write_global_declarations() ../../gcc/gcc/c/c-decl.c:10801 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.
Started with r221707.
Mine, will look into it tomorrow.
Hi, the ICE does not reproduce for me, but from backtrace it seems quite clear that the following fix should work: Index: cgraph.c =================================================================== --- cgraph.c (revision 221707) +++ cgraph.c (working copy) @@ -1516,7 +1516,7 @@ cgraph_update_edges_for_call_stmt_node ( if (e) { /* Keep calls marked as dead dead. */ - if (e->callee + if (new_call && e->callee && DECL_BUILT_IN_CLASS (e->callee->decl) == BUILT_IN_NORMAL && DECL_FUNCTION_CODE (e->callee->decl) == BUILT_IN_UNREACHABLE) { It is late here, so I will return to it only at morning. If the patch fixes the ICE and passes testing, please just go ahead and commit it. Honza
Author: hubicka Date: Fri Mar 27 10:33:17 2015 New Revision: 221726 URL: https://gcc.gnu.org/viewcvs?rev=221726&root=gcc&view=rev Log: PR middle-end/65595 * cgraph.c (cgraph_update_edges_for_call_stmt_node): Only do redirection if the call is not optimized out. * gcc.c-torture/compile/pr65595.c: New testcase. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr65595.c Modified: trunk/gcc/ChangeLog trunk/gcc/cgraph.c trunk/gcc/testsuite/ChangeLog
Fixed.
*** Bug 65603 has been marked as a duplicate of this bug. ***