https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66487
Jan Hubicka <hubicka at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org --- Comment #12 from Jan Hubicka <hubicka at gcc dot gnu.org> --- The problem is that BLOCK_ABSTRACT_ORIGIN can iterate, while DECL_ABSTRACT_ORIGIN can not. Iterated inlining and/or function splitting may make us to miss the fact that vtbl store is vtbl store. Index: ipa-polymorphic-call.c =================================================================== --- ipa-polymorphic-call.c (revision 232227) +++ ipa-polymorphic-call.c (working copy) @@ -477,6 +477,19 @@ contains_type_p (tree outer_type, HOST_W consider_bases); } +/* Unlike ABSTRACT_ORIGIN, the BLOCK_ABSTRACT_ORIGIN can iterate. Look up + the real origin of BLOCK. */ + +static tree +block_origin (tree block) +{ + if (!BLOCK_ABSTRACT_ORIGIN (block)) + return NULL; + while (TREE_CODE (block) == BLOCK && BLOCK_ABSTRACT_ORIGIN (block)) + block = BLOCK_ABSTRACT_ORIGIN (block); + return DECL_P (block) ? DECL_ORIGIN (block) : block; +} + /* Return a FUNCTION_DECL if BLOCK represents a constructor or destructor. If CHECK_CLONES is true, also check for clones of ctor/dtors. */ @@ -484,7 +497,7 @@ contains_type_p (tree outer_type, HOST_W tree inlined_polymorphic_ctor_dtor_block_p (tree block, bool check_clones) { - tree fn = BLOCK_ABSTRACT_ORIGIN (block); + tree fn = block_origin (block); if (fn == NULL || TREE_CODE (fn) != FUNCTION_DECL) return NULL_TREE; @@ -1142,8 +1155,8 @@ noncall_stmt_may_be_vtbl_ptr_store (gimp block of CTOR/DTOR. */ for (tree block = gimple_block (stmt); block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block)) - if (BLOCK_ABSTRACT_ORIGIN (block) - && TREE_CODE (BLOCK_ABSTRACT_ORIGIN (block)) == FUNCTION_DECL) + if (block_origin (block) + && TREE_CODE (block_origin (block)) == FUNCTION_DECL) return inlined_polymorphic_ctor_dtor_block_p (block, false); return (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE && (DECL_CXX_CONSTRUCTOR_P (current_function_decl)