The following makes sure the BLOCK_SUPERCONTEXT of DECL_INITIAL (decl) is decl itself (I won't commit the assert in cfgexpand.c but bootstrap/test passed with it). It also marks yet another global initializer with DECL_IGNORED_P, in this case as it is emitted very late after early debug is finished.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2016-07-21 Richard Biener <rguent...@suse.de> * function-tests.c (build_trivial_generic_function): Set BLOCK_SUPERCONTEXT of DECL_INITIAL. * omp-low.c (create_omp_child_function): Likewise. (grid_expand_target_grid_body): Likewise. * cgraphunit.c (init_lowered_empty_function): Likewise. (cgraph_node::expand_thunk): Likewise. * tree-parloops.c (create_loop_fn): Likewise. * ipa.c (cgraph_build_static_cdtor_1): Likewise. cp/ * vtable-class-hierarchy.c (vtv_generate_init_routine): Set DECL_IGNORED_P. java/ * jcf-parse.c (java_emit_static_constructor): Set BLOCK_SUPERCONTEXT of DECL_INITIAL. Index: gcc/function-tests.c =================================================================== --- gcc/function-tests.c (revision 238584) +++ gcc/function-tests.c (working copy) @@ -249,6 +249,7 @@ build_trivial_generic_function () tsi_link_after (&stmt_iter, return_stmt, TSI_CONTINUE_LINKING); DECL_INITIAL (fndecl) = block; + BLOCK_SUPERCONTEXT (block) = fndecl; /* how to add to function? the following appears to be how to set the body of a fndecl: */ Index: gcc/java/jcf-parse.c =================================================================== --- gcc/java/jcf-parse.c (revision 238584) +++ gcc/java/jcf-parse.c (working copy) @@ -1719,6 +1719,7 @@ java_emit_static_constructor (void) DECL_UNINLINABLE (decl) = 1; DECL_INITIAL (decl) = make_node (BLOCK); + BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl; TREE_USED (DECL_INITIAL (decl)) = 1; DECL_STATIC_CONSTRUCTOR (decl) = 1; Index: gcc/omp-low.c =================================================================== --- gcc/omp-low.c (revision 238584) +++ gcc/omp-low.c (working copy) @@ -2472,6 +2472,7 @@ create_omp_child_function (omp_context * DECL_EXTERNAL (decl) = 0; DECL_CONTEXT (decl) = NULL_TREE; DECL_INITIAL (decl) = make_node (BLOCK); + BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl; if (cgraph_node::get (current_function_decl)->offloadable) cgraph_node::get_create (decl)->offloadable = 1; else @@ -13670,6 +13671,7 @@ grid_expand_target_grid_body (struct omp BLOCK_ABSTRACT_ORIGIN (fniniblock) = tgtblock; BLOCK_SOURCE_LOCATION (fniniblock) = BLOCK_SOURCE_LOCATION (tgtblock); BLOCK_SOURCE_END_LOCATION (fniniblock) = BLOCK_SOURCE_END_LOCATION (tgtblock); + BLOCK_SUPERCONTEXT (fniniblock) = kern_fndecl; DECL_INITIAL (kern_fndecl) = fniniblock; push_struct_function (kern_fndecl); cfun->function_end_locus = gimple_location (tgt_stmt); Index: gcc/cgraphunit.c =================================================================== --- gcc/cgraphunit.c (revision 238584) +++ gcc/cgraphunit.c (working copy) @@ -1438,6 +1438,7 @@ init_lowered_empty_function (tree decl, } DECL_INITIAL (decl) = make_node (BLOCK); + BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl; DECL_SAVED_TREE (decl) = error_mark_node; cfun->curr_properties |= (PROP_gimple_lcf | PROP_gimple_leh | PROP_gimple_any @@ -1627,6 +1628,7 @@ cgraph_node::expand_thunk (bool output_a fn_block = make_node (BLOCK); BLOCK_VARS (fn_block) = a; DECL_INITIAL (thunk_fndecl) = fn_block; + BLOCK_SUPERCONTEXT (fn_block) = thunk_fndecl; allocate_struct_function (thunk_fndecl, false); init_function_start (thunk_fndecl); cfun->is_thunk = 1; Index: gcc/cp/vtable-class-hierarchy.c =================================================================== --- gcc/cp/vtable-class-hierarchy.c (revision 238584) +++ gcc/cp/vtable-class-hierarchy.c (working copy) @@ -1182,6 +1182,9 @@ vtv_generate_init_routine (void) TREE_STATIC (vtv_fndecl) = 1; TREE_USED (vtv_fndecl) = 1; DECL_PRESERVE_P (vtv_fndecl) = 1; + /* We are running too late to generate any meaningful debug information + for this routine. */ + DECL_IGNORED_P (vtv_fndecl) = 1; if (flag_vtable_verify == VTV_PREINIT_PRIORITY && !TARGET_PECOFF) DECL_STATIC_CONSTRUCTOR (vtv_fndecl) = 0; Index: gcc/tree-parloops.c =================================================================== --- gcc/tree-parloops.c (revision 238584) +++ gcc/tree-parloops.c (working copy) @@ -1476,6 +1476,7 @@ create_loop_fn (location_t loc) DECL_EXTERNAL (decl) = 0; DECL_CONTEXT (decl) = NULL_TREE; DECL_INITIAL (decl) = make_node (BLOCK); + BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl; t = build_decl (loc, RESULT_DECL, NULL_TREE, void_type_node); DECL_ARTIFICIAL (t) = 1; Index: gcc/ipa.c =================================================================== --- gcc/ipa.c (revision 238584) +++ gcc/ipa.c (working copy) @@ -935,6 +935,7 @@ cgraph_build_static_cdtor_1 (char which, DECL_UNINLINABLE (decl) = 1; DECL_INITIAL (decl) = make_node (BLOCK); + BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl; TREE_USED (DECL_INITIAL (decl)) = 1; DECL_SOURCE_LOCATION (decl) = input_location; Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c (revision 238584) +++ gcc/cfgexpand.c (working copy) @@ -6165,6 +6165,8 @@ pass_expand::execute (function *fun) rtx_insn *var_seq, *var_ret_seq; unsigned i; + gcc_assert (BLOCK_SUPERCONTEXT (DECL_INITIAL (fun->decl)) == fun->decl); + timevar_push (TV_OUT_OF_SSA); rewrite_out_of_ssa (&SA); timevar_pop (TV_OUT_OF_SSA);