Re: [patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-20 Thread Aldy Hernandez

On 05/20/2015 06:16 PM, Joseph Myers wrote:

On Wed, 20 May 2015, Aldy Hernandez wrote:


Update for the c-family bits removing the flag_syntax_only part Jason
requested.

And BTW, ping for you C front-end maintainers (unless Jason is reviewing the C
bits, in which case the rest of you can sit back and look pretty).


The C front-end changes are OK, assuming this has passed the usual
testing.



Yes they have.  Thank you.

Aldy


Re: [patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-20 Thread Joseph Myers
On Wed, 20 May 2015, Aldy Hernandez wrote:

> Update for the c-family bits removing the flag_syntax_only part Jason
> requested.
> 
> And BTW, ping for you C front-end maintainers (unless Jason is reviewing the C
> bits, in which case the rest of you can sit back and look pretty).

The C front-end changes are OK, assuming this has passed the usual 
testing.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-20 Thread Aldy Hernandez
Update for the c-family bits removing the flag_syntax_only part Jason 
requested.


And BTW, ping for you C front-end maintainers (unless Jason is reviewing 
the C bits, in which case the rest of you can sit back and look pretty).


Aldy
gcc/c-family/

	* c-common.h (c_parse_final_cleanups): New prototype.
	* c-opts.c (c_common_parse_file): Call c_parse_final_cleanups.

gcc/c/

	* c-decl.c (finish_struct): Save C_TYPE_INCOMPLETE_VARS and
	immediately clobber it.
	(c_write_global_declarations_1): Remove call to
	check_global_declaration_1.
	(c_write_global_declarations_2): Remove.
	(c_write_final_cleanups): Rename from c_write_global_declarations.
	Remove call to finalize_compilation_unit.
	Remove calls to debugging hooks.
	* c-objc-common.c: Adjust comment for c_warn_unused_global_decl.
	* c-objc-common.h: Remove LANG_HOOKS_WRITE_GLOBALS.
	* c-tree.h: Remove c_write_global_declarations.

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 62eac9f..155b799 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -892,6 +892,8 @@ extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
 /* This is the basic parsing function.  */
 extern void c_parse_file (void);
 
+extern void c_parse_final_cleanups (void);
+
 extern void warn_for_omitted_condop (location_t, tree);
 
 /* These macros provide convenient access to the various _STMT nodes.  */
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index e9eb511..89e7fbb 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1090,6 +1090,8 @@ c_common_parse_file (void)
   if (!this_input_filename)
 	break;
 }
+
+  c_parse_final_cleanups ();
 }
 
 /* Returns the appropriate dump file for PHASE to dump with FLAGS.  */
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 4f6761d..ca30a7c 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -7827,10 +7827,18 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 }
 
   /* If this structure or union completes the type of any previous
- variable declaration, lay it out and output its rtl.  */
-  for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
-   x;
-   x = TREE_CHAIN (x))
+ variable declaration, lay it out and output its rtl.
+
+ Note: C_TYPE_INCOMPLETE_VARS overloads TYPE_VFIELD which is used
+ in dwarf2out via rest_of_decl_compilation below and means
+ something totally different.  Since we will be clearing
+ C_TYPE_INCOMPLETE_VARS shortly after we iterate through them,
+ clear it ahead of time and avoid problems in dwarf2out.  Ideally,
+ C_TYPE_INCOMPLETE_VARS should use some language specific
+ node.  */
+  tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
+  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
+  for (x = incomplete_vars; x; x = TREE_CHAIN (x))
 {
   tree decl = TREE_VALUE (x);
   if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
@@ -7843,7 +7851,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 	  rest_of_decl_compilation (decl, toplevel, 0);
 	}
 }
-  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
 
   /* Update type location to the one of the definition, instead of e.g.
  a forward declaration.  */
@@ -10667,9 +10674,8 @@ finish_declspecs (struct c_declspecs *specs)
   return specs;
 }
 
-/* A subroutine of c_write_global_declarations.  Perform final processing
-   on one file scope's declarations (or the external scope's declarations),
-   GLOBALS.  */
+/* Perform final processing on one file scope's declarations (or the
+   external scope's declarations), GLOBALS.  */
 
 static void
 c_write_global_declarations_1 (tree globals)
@@ -10682,7 +10688,7 @@ c_write_global_declarations_1 (tree globals)
 {
   /* Check for used but undefined static functions using the C
 	 standard's definition of "used", and set TREE_NO_WARNING so
-	 that check_global_declarations doesn't repeat the check.  */
+	 that check_global_declaration doesn't repeat the check.  */
   if (TREE_CODE (decl) == FUNCTION_DECL
 	  && DECL_INITIAL (decl) == 0
 	  && DECL_EXTERNAL (decl)
@@ -10703,21 +10709,6 @@ c_write_global_declarations_1 (tree globals)
 	reconsider |= wrapup_global_declaration_2 (decl);
 }
   while (reconsider);
-
-  for (decl = globals; decl; decl = DECL_CHAIN (decl))
-check_global_declaration_1 (decl);
-}
-
-/* A subroutine of c_write_global_declarations Emit debug information for each
-   of the declarations in GLOBALS.  */
-
-static void
-c_write_global_declarations_2 (tree globals)
-{
-  tree decl;
-
-  for (decl = globals; decl ; decl = DECL_CHAIN (decl))
-debug_hooks->global_decl (decl);
 }
 
 /* Callback to collect a source_ref from a DECL.  */
@@ -10767,8 +10758,11 @@ for_each_global_decl (void (*callback) (tree decl))
 callback (decl);
 }
 
+/* Perform any final parser cleanups and generate initial debugging
+   information.  */
+
 void
-c_write_global_declarations (voi

[patch 2/10] debug-early merge: C front-end (include c-family/)

2015-05-07 Thread Aldy Hernandez
 gcc/c-family/

	* c-common.h (c_parse_final_cleanups): New prototype.
	* c-opts.c (c_common_parse_file): Call c_parse_final_cleanups.

gcc/c/

	* c-decl.c (finish_struct): Save C_TYPE_INCOMPLETE_VARS and
	immediately clobber it.
	(c_write_global_declarations_1): Remove call to
	check_global_declaration_1.
	(c_write_global_declarations_2): Remove.
	(c_write_final_cleanups): Rename from c_write_global_declarations.
	Remove call to finalize_compilation_unit.
	Remove calls to debugging hooks.
	* c-objc-common.c: Adjust comment for c_warn_unused_global_decl.
	* c-objc-common.h: Remove LANG_HOOKS_WRITE_GLOBALS.
	* c-tree.h: Remove c_write_global_declarations.

diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 603d3f0..9bc1dd9 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -884,6 +884,8 @@ extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
 /* This is the basic parsing function.  */
 extern void c_parse_file (void);
 
+extern void c_parse_final_cleanups (void);
+
 extern void warn_for_omitted_condop (location_t, tree);
 
 /* These macros provide convenient access to the various _STMT nodes.  */
diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 1a67b5a..37f2530 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -1080,6 +1080,9 @@ c_common_parse_file (void)
   if (!this_input_filename)
 	break;
 }
+
+  if (!flag_syntax_only)
+c_parse_final_cleanups ();
 }
 
 /* Returns the appropriate dump file for PHASE to dump with FLAGS.  */
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 4f6761d..ca30a7c 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -7827,10 +7827,18 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 }
 
   /* If this structure or union completes the type of any previous
- variable declaration, lay it out and output its rtl.  */
-  for (x = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
-   x;
-   x = TREE_CHAIN (x))
+ variable declaration, lay it out and output its rtl.
+
+ Note: C_TYPE_INCOMPLETE_VARS overloads TYPE_VFIELD which is used
+ in dwarf2out via rest_of_decl_compilation below and means
+ something totally different.  Since we will be clearing
+ C_TYPE_INCOMPLETE_VARS shortly after we iterate through them,
+ clear it ahead of time and avoid problems in dwarf2out.  Ideally,
+ C_TYPE_INCOMPLETE_VARS should use some language specific
+ node.  */
+  tree incomplete_vars = C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t));
+  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
+  for (x = incomplete_vars; x; x = TREE_CHAIN (x))
 {
   tree decl = TREE_VALUE (x);
   if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
@@ -7843,7 +7851,6 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 	  rest_of_decl_compilation (decl, toplevel, 0);
 	}
 }
-  C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0;
 
   /* Update type location to the one of the definition, instead of e.g.
  a forward declaration.  */
@@ -10667,9 +10674,8 @@ finish_declspecs (struct c_declspecs *specs)
   return specs;
 }
 
-/* A subroutine of c_write_global_declarations.  Perform final processing
-   on one file scope's declarations (or the external scope's declarations),
-   GLOBALS.  */
+/* Perform final processing on one file scope's declarations (or the
+   external scope's declarations), GLOBALS.  */
 
 static void
 c_write_global_declarations_1 (tree globals)
@@ -10682,7 +10688,7 @@ c_write_global_declarations_1 (tree globals)
 {
   /* Check for used but undefined static functions using the C
 	 standard's definition of "used", and set TREE_NO_WARNING so
-	 that check_global_declarations doesn't repeat the check.  */
+	 that check_global_declaration doesn't repeat the check.  */
   if (TREE_CODE (decl) == FUNCTION_DECL
 	  && DECL_INITIAL (decl) == 0
 	  && DECL_EXTERNAL (decl)
@@ -10703,21 +10709,6 @@ c_write_global_declarations_1 (tree globals)
 	reconsider |= wrapup_global_declaration_2 (decl);
 }
   while (reconsider);
-
-  for (decl = globals; decl; decl = DECL_CHAIN (decl))
-check_global_declaration_1 (decl);
-}
-
-/* A subroutine of c_write_global_declarations Emit debug information for each
-   of the declarations in GLOBALS.  */
-
-static void
-c_write_global_declarations_2 (tree globals)
-{
-  tree decl;
-
-  for (decl = globals; decl ; decl = DECL_CHAIN (decl))
-debug_hooks->global_decl (decl);
 }
 
 /* Callback to collect a source_ref from a DECL.  */
@@ -10767,8 +10758,11 @@ for_each_global_decl (void (*callback) (tree decl))
 callback (decl);
 }
 
+/* Perform any final parser cleanups and generate initial debugging
+   information.  */
+
 void
-c_write_global_declarations (void)
+c_parse_final_cleanups (void)
 {
   tree t;
   unsigned i;
@@ -10777,6 +10771,7 @@ c_write_global_declarations (void)
   if (pch_file)
 return;
 
+  timevar_stop (TV_PHASE_PARSING);
   timevar_start (T