From: Markus Trippelsdorf Date: Tue, 4 Feb 2014 17:25:38 +0000 (+0000) Subject: re PR ipa/60058 (internal compiler error: Segmentation fault) X-Git-Tag: releases/gcc-4.9.0~1097 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8472fa801bfcc8cfcbd8848b0c86c3527a984fe9;p=thirdparty%2Fgcc.git re PR ipa/60058 (internal compiler error: Segmentation fault) PR ipa/60058 * ipa-cp.c (ipa_get_indirect_edge_target_1): Check that target is non-null. * g++.dg/torture/pr60058.C: New testcase. From-SVN: r207478 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index baa87764d688..68ec96251eec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-02-04 Markus Trippelsdorf + + PR ipa/60058 + * ipa-cp.c (ipa_get_indirect_edge_target_1): Check that target + is non-null. + 2014-02-04 Jan Hubicka * gimple-fold.c (can_refer_decl_in_current_unit_p): Default visibility is safe. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 68afeb0d89e4..a2682bbe18d4 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1573,20 +1573,23 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, { target = gimple_get_virt_method_for_vtable (ie->indirect_info->otr_token, vtable, offset); - if ((TREE_CODE (TREE_TYPE (target)) == FUNCTION_TYPE - && DECL_FUNCTION_CODE (target) == BUILT_IN_UNREACHABLE) - || !possible_polymorphic_call_target_p - (ie, cgraph_get_node (target))) + if (target) { - if (dump_file) - fprintf (dump_file, - "Type inconsident devirtualization: %s/%i->%s\n", - ie->caller->name (), ie->caller->order, - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (target))); - target = builtin_decl_implicit (BUILT_IN_UNREACHABLE); - cgraph_get_create_node (target); + if ((TREE_CODE (TREE_TYPE (target)) == FUNCTION_TYPE + && DECL_FUNCTION_CODE (target) == BUILT_IN_UNREACHABLE) + || !possible_polymorphic_call_target_p + (ie, cgraph_get_node (target))) + { + if (dump_file) + fprintf (dump_file, + "Type inconsident devirtualization: %s/%i->%s\n", + ie->caller->name (), ie->caller->order, + IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (target))); + target = builtin_decl_implicit (BUILT_IN_UNREACHABLE); + cgraph_get_create_node (target); + } + return target; } - return target; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e2d5ebcbc014..028b911c271e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-02-04 Markus Trippelsdorf + + PR ipa/60058 + * g++.dg/torture/pr60058.C: New testcase. + 2014-02-04 Max Ostapenko * g++.dg/tsan/default_options.C: Invert check. diff --git a/gcc/testsuite/g++.dg/torture/pr60058.C b/gcc/testsuite/g++.dg/torture/pr60058.C new file mode 100644 index 000000000000..1144137cb918 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/pr60058.C @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-require-visibility "" } */ + +typedef enum {} UErrorCode; +class A { +public: + virtual A &m_fn1(A &, const A &, UErrorCode &) const; + void m_fn2(); + A(); + A(int); +}; +class __attribute__((visibility("hidden"))) B : public A { +public: + B(A &p1) : norm2(p1), set(0) {} + A &m_fn1(A &, const A &, UErrorCode &) const; + A &norm2; + const int &set; +}; + +UErrorCode a; +A c; +void fn1(A *p1) { + A b; + p1->m_fn1(b, 0, a).m_fn2(); +} + +void fn2() { + B d(c); + fn1(&d); +}