Bug 65595 - [5 Regression] Linux kernel build failure: ICE: in as_a, at is-a.h:192
Summary: [5 Regression] Linux kernel build failure: ICE: in as_a, at is-a.h:192
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 5.0
: P1 normal
Target Milestone: 5.0
Assignee: Jan Hubicka
URL:
Keywords:
: 65603 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-03-27 08:10 UTC by Markus Trippelsdorf
Modified: 2015-03-27 14:07 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-03-27 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2015-03-27 08:10:59 UTC
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.
Comment 1 Markus Trippelsdorf 2015-03-27 08:25:35 UTC
Started with r221707.
Comment 2 Jan Hubicka 2015-03-27 09:09:23 UTC
Mine, will look into it tomorrow.
Comment 3 Jan Hubicka 2015-03-27 09:16:08 UTC
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
Comment 4 Jan Hubicka 2015-03-27 10:33:50 UTC
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
Comment 5 Jan Hubicka 2015-03-27 10:34:06 UTC
Fixed.
Comment 6 Markus Trippelsdorf 2015-03-27 14:07:41 UTC
*** Bug 65603 has been marked as a duplicate of this bug. ***