On Aug 1, 2013, at 8:09 AM, Jan Hubicka <hubi...@ucw.cz> wrote: > Now when we have abstract origins tracked, this patch makes DECL_ARGUMENTS and > DECL_RESULT to be removed from FUNCTION_DECLs that are never passed to symbol > table. This reduces LTO streaming effort (by about 1/3rd of PARM_DECls)
So, I was tracking down an lto failure in the C++ test suite, g++.dg/ipa/pr46984.C, and it appears to be caused by 4df870fdeec85907db3dcabf1992cf8b63e1d562 aka svn+ssh://gcc.gnu.org/svn/gcc/trunk@201468. I was trying to find the gcc-patches email for this work, but could not. :-( Anyway, the above is the closest work to that, that I can find. The problem is that DECL_ARGUMENTS of the thunk (aka _ZThn528_N1D3fooEv) is used during thunk code-generation, and thunk code-generation happens during the output of D::foo. My port is a targetm.asm_out.can_output_mi_thunk false port. RESULT_DECL is synthesized on the fly like this: /* Build the return declaration for the function. */ restype = TREE_TYPE (TREE_TYPE (thunk_fndecl)); if (DECL_RESULT (thunk_fndecl) == NULL_TREE) { resdecl = build_decl (input_location, RESULT_DECL, 0, restype); DECL_ARTIFICIAL (resdecl) = 1; DECL_IGNORED_P (resdecl) = 1; DECL_RESULT (thunk_fndecl) = resdecl; } else resdecl = DECL_RESULT (thunk_fndecl); in expand_thunk, but DECL_ARGUMENTS is not. Either it needs to be, or it has to be saved and restored in some fashion. input_function is never called for the thunk. If it had been, then it would have worked I think. I think this translates into output_function not being called on the thunk. Anyway, the core dump looks like: In member function 'non-virtual thunk to D::foo()': lto1: internal compiler error: Segmentation fault 0x995d3f crash_signal ../../gcc/gcc/toplev.c:335 0x6a5828 contains_struct_check ../../gcc/gcc/tree.h:3804 0x6a5828 fold_build_pointer_plus_hwi_loc ../../gcc/gcc/tree.h:5871 0x6a5828 thunk_adjust ../../gcc/gcc/cgraphunit.c:1240 0x6a6ffd expand_thunk(cgraph_node*) ../../gcc/gcc/cgraphunit.c:1440 0x6a799d assemble_thunks_and_aliases ../../gcc/gcc/cgraphunit.c:1549 0x6a7a32 assemble_thunks_and_aliases ../../gcc/gcc/cgraphunit.c:1565 0x6a7bce expand_function ../../gcc/gcc/cgraphunit.c:1675 0x6a983c expand_all_functions ../../gcc/gcc/cgraphunit.c:1717 0x6a983c compile() ../../gcc/gcc/cgraphunit.c:2054 0x62ccd7 lto_main() ../../gcc/gcc/lto/lto.c:3843 It appears that > > Bootstrapped/regtested ppc64-linux, will commit it after further testing on > x86_64-linux. > > Honza > > * cgraph.h (release_function_body): Declare. > * tree.c (free_lang_data_in_decl): Free, parameters and return values > of unused delcarations. > Index: cgraph.h > =================================================================== > --- cgraph.h (revision 201408) > +++ cgraph.h (working copy) > @@ -606,6 +606,7 @@ void debug_cgraph_node (struct cgraph_no > void cgraph_remove_edge (struct cgraph_edge *); > void cgraph_remove_node (struct cgraph_node *); > void cgraph_release_function_body (struct cgraph_node *); > +void release_function_body (tree); > void cgraph_node_remove_callees (struct cgraph_node *node); > struct cgraph_edge *cgraph_create_edge (struct cgraph_node *, > struct cgraph_node *, > Index: tree.c > =================================================================== > --- tree.c (revision 201367) > +++ tree.c (working copy) > @@ -4886,6 +4886,20 @@ free_lang_data_in_decl (tree decl) > > if (TREE_CODE (decl) == FUNCTION_DECL) > { > + struct cgraph_node *node; > + if (!(node = cgraph_get_node (decl)) > + || (!node->symbol.definition && !node->clones)) > + { > + if (node) > + cgraph_release_function_body (node); > + else > + { > + release_function_body (decl); > + DECL_ARGUMENTS (decl) = NULL; > + DECL_RESULT (decl) = NULL; > + DECL_INITIAL (decl) = error_mark_node; > + } > + } > if (gimple_has_body_p (decl)) > { > tree t;