On 05/20/2015 03:18 PM, Jason Merrill wrote:
On 05/08/2015 09:14 PM, Aldy Hernandez wrote:
+ if (!flag_syntax_only)
+ c_parse_final_cleanups ();
The condition is a significant change of behavior for the C++ front end;
doing final instantiation and such even with -fsyntax-only was a
deliberate choice. Can we drop the condition?
Sure. Done. Will repost this as part of the C front-end which has the
c-family/ bits where this appeared.
+ timevar_stop (TV_PHASE_PARSING);
+ timevar_start (TV_PHASE_DBGINFO);
perform_deferred_noexcept_checks ();
The only debug info stuff that was here has been removed, so there's no
longer any need to switch to a debug timevar. I think we should stay in
DEFERRED for the whole function.
Fixed.
How does this look?
Bootstrapped and retested on x86-64 for --enable-languages=all.
Aldy
gcc/cp/
* 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.
diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c
index dd8e7c5..40b13ef 100644
--- a/gcc/cp/cp-objcp-common.c
+++ b/gcc/cp/cp-objcp-common.c
@@ -60,7 +60,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 4136d98..1998992 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 261a12d..8dadb39 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -892,30 +892,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<tree, va_gc> *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 27bacab..dc384e4 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4367,6 +4367,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. */
@@ -4414,17 +4416,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. */
@@ -4441,6 +4442,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] */
@@ -4456,8 +4460,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:
@@ -4553,7 +4555,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. */
@@ -4579,7 +4581,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
@@ -4587,7 +4589,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. */
@@ -4730,7 +4732,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;
}
}
@@ -4757,12 +4759,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)
@@ -4778,9 +4781,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 ();
@@ -4788,32 +4788,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 ();
@@ -4827,13 +4801,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 9e4e0e3..ebeb479 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3899,7 +3899,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,