From d7438551ff5ffa0afeca2aa3efd13035b26bee34 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Fri, 5 Jun 2015 18:44:53 +0000 Subject: Merge debug-early branch into mainline. * dwarf2out.c: Remove deferred_locations*. (dwarf2_debug_hooks): Add early_finish hook. Remove global_decl hook. Add early_global_decl and late_global_decl hook. New global early_dwarf. New structure set_early_dwarf. (output_die): Indicate whether a DIE was generated early when generating assembly with -dA. (struct limbo_die_struct): Document created_for field. Remove file_table_last_lookup. (remove_AT): Return TRUE if successful. (remove_child_TAG): Clear die_parent. (reparent_child): New function abstracted from... (splice_child_die): ...here. (new_die): ICE if a DIE ends up in limbo too late. (check_die): New. (defer_location): Remove. (add_subscript_info): Reuse DW_TAG_subrange_type if available. (fill_variable_array_bounds): New. (decl_start_label): Call fill_variable_array_bounds. (gen_formal_parameter_die): Rewrite to reuse previously generated DIEs. (gen_subprogram_die): Same. (gen_variable_die): Same. (gen_const_die): Same. (gen_label_die): Same. (gen_lexical_block_die): Same. (decl_will_get_specification_p): New. (local_function_static): New. (gen_struct_or_union_type_die): Fill in variable-length fields. (gen_typedef_die): Fill in variable-length typedefs. (gen_tagged_type_die): Gracefully return on error_mark_node. Handle re-entrancy. (gen_type_die_with_usage): Handle variable-length types. Remove duplicate code for ARRAY_TYPE case. (process_scope_var): Only process imported modules during early dwarf. (dwarf2out_early_global_decl): New. (dwarf2out_late_global_decl): Rename from dwarf2out_global_decl. (dwarf2out_type_decl): Set early_dwarf while calling dwarf2out_decl. (dwarf2out_decl): Verify that we did not recreate a previously generated DIE. Do not return on DECL_EXTERNALs in VAR_DECLs. Abstract some code to local_function_static. (lookup_filename): Remove use of file_table_last_lookup. Gracefully exit on missing file_name. (dwarf2out_finish): Verify limbo list. Remove deferred_locations_list use. Move deferred_asm_name and limbo flushing to... (dwarf2out_early_finish): ...here. New. (dwarf2out_c_finalize): Remove set of deferred_location_list, deferred_asm_name, and file_table_last_lookup. * cgraph.h (referred_to_p): Add default argument. * cgraphunit.c (referred_to_p): Add and handle include_self argument. (analyze_functions): Add first_time argument. Call check_global_declaration for all symbols. Call late_global_decl for nodes for moribund nodes. (finalize_compilation_unit): Add new argument to analyze_functions. Call early_global_decl for functions. Call early_finish debug hook. * dbxout.c (dbxout_early_global_decl): New. (dbxout_late_global_decl): New. Adapted from dbxout_global_decl. (dbx_debug_hooks): Add new hooks. (xcoff_debug_hooks): Same. * debug.c (do_nothing_debug_hooks): Add early_finish field. Add early and late debug hooks. Remove global_decl hook. * debug.h (struct gcc_debug_hooks): Add early_finish, early_global_decl, and late_global_decl fields. Remove global_decl field. Document gcc_debug_hooks. * gengtype.c (output_typename): Remove. * godump.c (go_early_global_decl): New. (go_late_global_decl): New. (go_global_decl): Remove. (dump_go_spec_init): Remove global_decl. Add {early,late}_global_decl. * langhooks-def.h (LANG_HOOKS_WRITE_GLOBALS): Remove. (LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): New. * langhooks.c (lhd_warn_unused_global_decl): Adjust comment. (write_global_declarations): Remove. (global_decl_processing): New. * langhooks.h (struct lang_hooks_for_decls): Remove final_write_globals field. Add post_compilation_parsing_cleanups field. * passes.c (rest_of_decl_compilation): Call early_global_decl. * sdbout.c: Add early and late_global_decl hooks. Remove sdbout_global_decl hook. Add early_finish field for sdb_debug_hooks. (sdbout_global_decl): Remove. (sdbout_early_global_decl): New. (sdbout_late_global_decl): New. * timevar.def (TV_PHASE_LATE_PARSING_CLEANUPS): New. * toplev.c (check_global_declaration): Rename from check_global_declaration_1. Adapt to use symtab infrastructure. (check_global_declarations): Remove. (emit_debug_global_declarations): Remove. (compile_file): Remove call to final_write_globals langhook. Run the actual compilation process. Perform any post compilation parser cleanups. Generate late debug info. * toplev.h (check_global_declaration): New. (check_global_declaration_1): Remove. (check_global_declarations): Remove. (write_global_declarations): Remove. (emit_debug_global_declarations): Remove. (global_decl_processing): New. * tree-core.h (struct tree_block): Add DIE field. * tree.h (BLOCK_DIE): New. * vmsdbgout.c (vmsdbgout_global_decl): Remove function and its use throughout. (vmsdbgout_early_global_decl): New. (vmsdbgout_late_global_decl): New. Add early_finish debug hook field to vmsdbg_debug_hooks. Remove vmsdbgout_decl to vmsdbgout_function_decl. Add early and late_global_decl debug hooks. From-SVN: r224161 --- gcc/cp/ChangeLog | 33 +++++++++++++++++++ gcc/cp/cp-objcp-common.c | 2 +- gcc/cp/cp-objcp-common.h | 4 +-- gcc/cp/cp-tree.h | 2 +- gcc/cp/decl.c | 15 ++------- gcc/cp/decl2.c | 82 +++++++++++++++++++++++------------------------- gcc/cp/name-lookup.c | 2 +- 7 files changed, 80 insertions(+), 60 deletions(-) (limited to 'gcc/cp') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e845b9f..bb59bcc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,36 @@ +2015-06-05 Aldy Hernandez + + * cp-objcp-common.c: Adjust comment for + cxx_warn_unused_global_decl. + * cp-objcp-common.h (LANG_HOOKS_WRITE_GLOBALS): Remove + (LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): New. + * cp-tree.h (note_mangling_alias): Protoize. + (cp_write_global_declarations): Remove. + (cxx_post_compilation_parsing_cleanups): Protoize. + * decl.c (wrapup_globals_for_namespace): Remove use of DATA + argument. + * decl2.c (mangling_aliases): New global. + (build_java_method_aliases): New. Adapted from + collect_candidates_for_java_method_aliases. + (collect_candidates_for_java_method_aliases): Remove. + (build_java_method_aliases): Remove. + (generate_mangling_aliases): New. + (note_mangling_alias): New. Moved from mangle_decl. + (locus_at_end_of_parsing): New global. + (c_parse_final_cleanups): Rename from + cp_write_global_declarations. + Use locus_at_end_of_parsing. + Call generate_mangling_aliases. + Rename call to collect_candidates_for_java_method_aliases into + build_java_method_aliases. + Remove call to finalize_compilation_unit. + Move vtable handling into cxx_post_compilation_parsing_cleanups. + Do not call check_global_declarations or + emit_debug_global_declarations. + (cxx_post_compilation_parsing_cleanups): New. + * mangle.c (mangle_decl): Move code to note_mangling_alias. + * name-lookup.c (do_namespace_alias): Call early_global_decl. + 2015-06-05 Nathan Sidwell PR c++/52595 diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 8f40ce4..4c193a1 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -57,7 +57,7 @@ cxx_get_alias_set (tree t) return c_common_get_alias_set (t); } -/* Called from check_global_declarations. */ +/* Called from check_global_declaration. */ bool cxx_warn_unused_global_decl (const_tree decl) diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index 8a36e7f..c8572a7 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -84,8 +84,8 @@ extern void cp_common_init_ts (void); #define LANG_HOOKS_PRINT_ERROR_FUNCTION cxx_print_error_function #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL cxx_warn_unused_global_decl -#undef LANG_HOOKS_WRITE_GLOBALS -#define LANG_HOOKS_WRITE_GLOBALS cp_write_global_declarations +#undef LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS +#define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS cxx_post_compilation_parsing_cleanups #undef LANG_HOOKS_BUILTIN_FUNCTION #define LANG_HOOKS_BUILTIN_FUNCTION cxx_builtin_function #undef LANG_HOOKS_BUILTIN_FUNCTION_EXT_SCOPE diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 26b6cb6..fb1702c 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5469,7 +5469,7 @@ extern tree cp_reconstruct_complex_type (tree, tree); extern bool attributes_naming_typedef_ok (tree); extern void cplus_decl_attributes (tree *, tree, int); extern void finish_anon_union (tree); -extern void cp_write_global_declarations (void); +extern void cxx_post_compilation_parsing_cleanups (void); extern tree coerce_new_type (tree); extern tree coerce_delete_type (tree); extern void comdat_linkage (tree); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e63098f..2bddce2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -888,30 +888,19 @@ walk_namespaces (walk_namespaces_fn f, void* data) return walk_namespaces_r (global_namespace, f, data); } -/* Call wrapup_globals_declarations for the globals in NAMESPACE. If - DATA is non-NULL, this is the last time we will call - wrapup_global_declarations for this NAMESPACE. */ +/* Call wrapup_globals_declarations for the globals in NAMESPACE. */ int -wrapup_globals_for_namespace (tree name_space, void* data) +wrapup_globals_for_namespace (tree name_space, void* data ATTRIBUTE_UNUSED) { cp_binding_level *level = NAMESPACE_LEVEL (name_space); vec *statics = level->static_decls; tree *vec = statics->address (); int len = statics->length (); - int last_time = (data != 0); - - if (last_time) - { - check_global_declarations (vec, len); - emit_debug_global_declarations (vec, len); - return 0; - } /* Write out any globals that need to be output. */ return wrapup_global_declarations (vec, len); } - /* In C++, you don't have to write `struct S' to refer to `S'; you can just use `S'. We accomplish this by creating a TYPE_DECL as diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a6a628d..c1b568b 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4389,6 +4389,8 @@ dump_tu (void) } } +static location_t locus_at_end_of_parsing; + /* Check the deallocation functions for CODE to see if we want to warn that only one was defined. */ @@ -4436,17 +4438,16 @@ maybe_warn_sized_delete () first, since that way we only need to reverse the decls once. */ void -cp_write_global_declarations (void) +c_parse_final_cleanups (void) { tree vars; bool reconsider; size_t i; - location_t locus; unsigned ssdf_count = 0; int retries = 0; tree decl; - locus = input_location; + locus_at_end_of_parsing = input_location; at_eof = 1; /* Bad parse errors. Just forget about it. */ @@ -4463,6 +4464,9 @@ cp_write_global_declarations (void) return; } + timevar_stop (TV_PHASE_PARSING); + timevar_start (TV_PHASE_DEFERRED); + symtab->process_same_body_aliases (); /* Handle -fdump-ada-spec[-slim] */ @@ -4478,8 +4482,6 @@ cp_write_global_declarations (void) /* FIXME - huh? was input_line -= 1;*/ - timevar_start (TV_PHASE_DEFERRED); - /* We now have to write out all the stuff we put off writing out. These include: @@ -4575,7 +4577,7 @@ cp_write_global_declarations (void) /* Set the line and file, so that it is obviously not from the source file. */ - input_location = locus; + input_location = locus_at_end_of_parsing; ssdf_body = start_static_storage_duration_function (ssdf_count); /* Make sure the back end knows about all the variables. */ @@ -4601,7 +4603,7 @@ cp_write_global_declarations (void) /* Finish up the static storage duration function for this round. */ - input_location = locus; + input_location = locus_at_end_of_parsing; finish_static_storage_duration_function (ssdf_body); /* All those initializations and finalizations might cause @@ -4609,7 +4611,7 @@ cp_write_global_declarations (void) instantiations, etc. */ reconsider = true; ssdf_count++; - /* ??? was: locus.line++; */ + /* ??? was: locus_at_end_of_parsing.line++; */ } /* Now do the same for thread_local variables. */ @@ -4752,7 +4754,7 @@ cp_write_global_declarations (void) (template_for_substitution (decl))))) { warning (0, "inline function %q+D used but never defined", decl); - /* Avoid a duplicate warning from check_global_declaration_1. */ + /* Avoid a duplicate warning from check_global_declaration. */ TREE_NO_WARNING (decl) = 1; } } @@ -4779,12 +4781,13 @@ cp_write_global_declarations (void) if (priority_info_map) splay_tree_foreach (priority_info_map, generate_ctor_and_dtor_functions_for_priority, - /*data=*/&locus); + /*data=*/&locus_at_end_of_parsing); else if (c_dialect_objc () && objc_static_init_needed_p ()) /* If this is obj-c++ and we need a static init, call generate_ctor_or_dtor_function. */ generate_ctor_or_dtor_function (/*constructor_p=*/true, - DEFAULT_INIT_PRIORITY, &locus); + DEFAULT_INIT_PRIORITY, + &locus_at_end_of_parsing); /* We're done with the splay-tree now. */ if (priority_info_map) @@ -4800,9 +4803,6 @@ cp_write_global_declarations (void) /* Generate Java hidden aliases. */ build_java_method_aliases (); - timevar_stop (TV_PHASE_DEFERRED); - timevar_start (TV_PHASE_OPT_GEN); - if (flag_vtable_verify) { vtv_recover_class_info (); @@ -4810,32 +4810,6 @@ cp_write_global_declarations (void) vtv_build_vtable_verify_fndecl (); } - symtab->finalize_compilation_unit (); - - if (flag_vtable_verify) - { - /* Generate the special constructor initialization function that - calls __VLTRegisterPairs, and give it a very high - initialization priority. This must be done after - finalize_compilation_unit so that we have accurate - information about which vtable will actually be emitted. */ - vtv_generate_init_routine (); - } - - timevar_stop (TV_PHASE_OPT_GEN); - timevar_start (TV_PHASE_CHECK_DBGINFO); - - /* Now, issue warnings about static, but not defined, functions, - etc., and emit debugging information. */ - walk_namespaces (wrapup_globals_for_namespace, /*data=*/&reconsider); - if (vec_safe_length (pending_statics) != 0) - { - check_global_declarations (pending_statics->address (), - pending_statics->length ()); - emit_debug_global_declarations (pending_statics->address (), - pending_statics->length ()); - } - perform_deferred_noexcept_checks (); finish_repo (); @@ -4849,13 +4823,37 @@ cp_write_global_declarations (void) dump_tree_statistics (); dump_time_statistics (); } - input_location = locus; + + timevar_stop (TV_PHASE_DEFERRED); + timevar_start (TV_PHASE_PARSING); +} + +/* Perform any post compilation-proper cleanups for the C++ front-end. + This should really go away. No front-end should need to do + anything past the compilation process. */ + +void +cxx_post_compilation_parsing_cleanups (void) +{ + timevar_start (TV_PHASE_LATE_PARSING_CLEANUPS); + + if (flag_vtable_verify) + { + /* Generate the special constructor initialization function that + calls __VLTRegisterPairs, and give it a very high + initialization priority. This must be done after + finalize_compilation_unit so that we have accurate + information about which vtable will actually be emitted. */ + vtv_generate_init_routine (); + } + + input_location = locus_at_end_of_parsing; #ifdef ENABLE_CHECKING validate_conversion_obstack (); #endif /* ENABLE_CHECKING */ - timevar_stop (TV_PHASE_CHECK_DBGINFO); + timevar_stop (TV_PHASE_LATE_PARSING_CLEANUPS); } /* FN is an OFFSET_REF, DOTSTAR_EXPR or MEMBER_REF indicating the diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 62424e0..e4baac3 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -3896,7 +3896,7 @@ do_namespace_alias (tree alias, tree name_space) /* Emit debug info for namespace alias. */ if (!building_stmt_list_p ()) - (*debug_hooks->global_decl) (alias); + (*debug_hooks->early_global_decl) (alias); } /* Like pushdecl, only it places X in the current namespace, -- cgit v1.1