diff mbox

[3/10] debug-early merge: C++ front-end

Message ID 554D5F75.6080901@redhat.com
State New
Headers show

Commit Message

Aldy Hernandez May 9, 2015, 1:14 a.m. UTC
On 05/08/2015 12:20 PM, Richard Biener wrote:

> Just meant that it's making the changes smaller if those bits can be checked in independently. If that's just a hassle...

Well, who am I to look a gift horse in the mouth?  Especially when 
you've volunteered to review most of this, and hopefully finish the LTO 
streaming work? :-)))))))

That being said... here is the latest C++ patch bereft of C++ mangling 
and Java aliases.  Indeed it looks mighty clean.  I'm tempted to commit 
it as obvious... :).

The rest of the patches remain as is.

Thanks.
Aldy
commit 73357de442ca317e478cfcb6c0f9da630d142775
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Fri May 8 17:26:32 2015 -0700

    	* cp-objcp-common.c: Update 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 (cp_write_global_declarations): Remove.
    	(cxx_post_compilation_parsing_cleanups): New.
    	(wrapup_globals_for_namespace): Add argument.
    	* decl.c (wrapup_globals_for_namespace): Tag unused argument with
    	ATTRIBUTE_UNUSED.
    	* decl2.c (locus_at_end_of_parsing): New global.
    	(c_parse_final_cleanups): Rename from
    	cp_write_global_declarations.  Use locus_at_end_of_parsing.
    	Start correct TV_PHASE_* timers.
    	Remove code calling finalize_compilation_unit.
    	Move vtable verify code into its own function...
    	(cxx_post_compilation_parsing_cleanups): ...here.
    	* name-lookup.c (do_namespace_alias): Rename global_decl to
    	early_global_decl.

Comments

Jason Merrill May 20, 2015, 7:18 p.m. UTC | #1
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?

> +  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.

Jason
diff mbox

Patch

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 4b27f5d..245a23e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,24 @@ 
+2015-05-08  Aldy Hernandez  <aldyh@redhat.com>
+
+	* cp-objcp-common.c: Update 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 (cp_write_global_declarations): Remove.
+	(cxx_post_compilation_parsing_cleanups): New.
+	(wrapup_globals_for_namespace): Add argument.
+	* decl.c (wrapup_globals_for_namespace): Tag unused argument with
+	ATTRIBUTE_UNUSED.
+	* decl2.c (locus_at_end_of_parsing): New global.
+	(c_parse_final_cleanups): Rename from
+	cp_write_global_declarations.  Use locus_at_end_of_parsing.
+	Start correct TV_PHASE_* timers.
+	Remove code calling finalize_compilation_unit.
+	Move vtable verify code into its own function...
+	(cxx_post_compilation_parsing_cleanups): ...here.
+	* name-lookup.c (do_namespace_alias): Rename global_decl to
+	early_global_decl.
+
 2015-05-08  Jason Merrill  <jason@redhat.com>
 
 	* decl2.c (mangling_aliases): New variable.
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 6ec1579..4a4cadf 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 d435af2..737db8c 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4358,6 +4358,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.  */
 
@@ -4405,17 +4407,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.  */
@@ -4447,6 +4448,7 @@  cp_write_global_declarations (void)
 
   /* FIXME - huh?  was  input_line -= 1;*/
 
+  timevar_stop (TV_PHASE_PARSING);
   timevar_start (TV_PHASE_DEFERRED);
 
   /* We now have to write out all the stuff we put off writing out.
@@ -4544,7 +4546,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.  */
@@ -4570,7 +4572,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
@@ -4578,7 +4580,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.  */
@@ -4721,7 +4723,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;
 	}
     }
@@ -4748,12 +4750,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)
@@ -4770,7 +4773,7 @@  cp_write_global_declarations (void)
   build_java_method_aliases ();
 
   timevar_stop (TV_PHASE_DEFERRED);
-  timevar_start (TV_PHASE_OPT_GEN);
+  timevar_start (TV_PHASE_PARSING);
 
   if (flag_vtable_verify)
     {
@@ -4779,31 +4782,10 @@  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 ());
-    }
+  /* Issue warnings about static, but not defined, functions, etc, and
+     generate initial debug information.  */
+  timevar_stop (TV_PHASE_PARSING);
+  timevar_start (TV_PHASE_DBGINFO);
 
   perform_deferred_noexcept_checks ();
 
@@ -4818,13 +4800,37 @@  cp_write_global_declarations (void)
       dump_tree_statistics ();
       dump_time_statistics ();
     }
-  input_location = locus;
+
+  timevar_stop (TV_PHASE_DBGINFO);
+  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,