public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch 1/10] debug-early merge: Ada front-end
@ 2015-05-08  0:32 Aldy Hernandez
  2015-05-08 10:27 ` Eric Botcazou
  0 siblings, 1 reply; 10+ messages in thread
From: Aldy Hernandez @ 2015-05-08  0:32 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: dearly-ada.patch --]
[-- Type: text/x-patch, Size: 4165 bytes --]

gcc/ada/

	* gcc-interface/gigi.h (note_types_used_by_globals): New prototype.
	* gcc-interface/misc.c (gnat_parse_file): Call
	note_types_used_by_globals.
	* gcc-interface/utils.c: Remove global_decls.
	(gnat_pushdecl): Remove use of global_decls.
	(gnat_write_global_declarations): Rename to
	note_types_used_by_globals.
	Remove call to finalize_compilation_unit.
	Remove explicit call to debug_hooks.

diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index 6d65fc5..fead2be 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -535,8 +535,7 @@ extern tree gnat_type_for_size (unsigned precision, int unsignedp);
    an unsigned type; otherwise a signed type is returned.  */
 extern tree gnat_type_for_mode (machine_mode mode, int unsignedp);
 
-/* Emit debug info for all global variable declarations.  */
-extern void gnat_write_global_declarations (void);
+extern void note_types_used_by_globals (void);
 
 /* Return the unsigned version of a TYPE_NODE, a scalar type.  */
 extern tree gnat_unsigned_type (tree type_node);
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index edaab97..2056a61 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -122,6 +122,8 @@ gnat_parse_file (void)
 
   /* Call the front end.  */
   _ada_gnat1drv ();
+
+  note_types_used_by_globals ();
 }
 
 /* Return language mask for option processing.  */
@@ -972,8 +974,6 @@ gnat_init_ts (void)
 #define LANG_HOOKS_GETDECLS		lhd_return_null_tree_v
 #undef  LANG_HOOKS_PUSHDECL
 #define LANG_HOOKS_PUSHDECL		gnat_return_tree
-#undef  LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS	gnat_write_global_declarations
 #undef  LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET	gnat_get_alias_set
 #undef  LANG_HOOKS_PRINT_DECL
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 170aa4a..647b427 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -227,9 +227,6 @@ static GTY((deletable)) struct gnat_binding_level *free_binding_level;
 /* The context to be used for global declarations.  */
 static GTY(()) tree global_context;
 
-/* An array of global declarations.  */
-static GTY(()) vec<tree, va_gc> *global_decls;
-
 /* An array of builtin function declarations.  */
 static GTY(()) vec<tree, va_gc> *builtin_decls;
 
@@ -764,9 +761,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
 	  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
 	    vec_safe_push (builtin_decls, decl);
 	}
-      else if (global_bindings_p ())
-	vec_safe_push (global_decls, decl);
-      else
+      else if (!global_bindings_p ())
 	{
 	  DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block);
 	  BLOCK_VARS (current_binding_level->block) = decl;
@@ -5176,7 +5171,7 @@ smaller_form_type_p (tree type, tree orig_type)
 static GTY (()) tree dummy_global;
 
 void
-gnat_write_global_declarations (void)
+note_types_used_by_globals (void)
 {
   unsigned int i;
   tree iter;
@@ -5204,28 +5199,6 @@ gnat_write_global_declarations (void)
 	  types_used_by_var_decl_insert (t, dummy_global);
 	}
     }
-
-  /* Output debug information for all global type declarations first.  This
-     ensures that global types whose compilation hasn't been finalized yet,
-     for example pointers to Taft amendment types, have their compilation
-     finalized in the right context.  */
-  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
-    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
-      debug_hooks->global_decl (iter);
-
-  /* Proceed to optimize and emit assembly. */
-  symtab->finalize_compilation_unit ();
-
-  /* After cgraph has had a chance to emit everything that's going to
-     be emitted, output debug information for the rest of globals.  */
-  if (!seen_error ())
-    {
-      timevar_push (TV_SYMOUT);
-      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
-	if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
-	  debug_hooks->global_decl (iter);
-      timevar_pop (TV_SYMOUT);
-    }
 }
 
 /* ************************************************************************

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08  0:32 [patch 1/10] debug-early merge: Ada front-end Aldy Hernandez
@ 2015-05-08 10:27 ` Eric Botcazou
  2015-05-08 10:35   ` Richard Biener
                     ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Eric Botcazou @ 2015-05-08 10:27 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches

> @@ -5204,28 +5199,6 @@ gnat_write_global_declarations (void)
>  	  types_used_by_var_decl_insert (t, dummy_global);
>  	}
>      }
> -
> -  /* Output debug information for all global type declarations first.  This
> -     ensures that global types whose compilation hasn't been finalized
> yet, -     for example pointers to Taft amendment types, have their
> compilation -     finalized in the right context.  */
> -  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
> -    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
> -      debug_hooks->global_decl (iter);
> -
> -  /* Proceed to optimize and emit assembly. */
> -  symtab->finalize_compilation_unit ();
> -
> -  /* After cgraph has had a chance to emit everything that's going to
> -     be emitted, output debug information for the rest of globals.  */
> -  if (!seen_error ())
> -    {
> -      timevar_push (TV_SYMOUT);
> -      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
> -	if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
> -	  debug_hooks->global_decl (iter);
> -      timevar_pop (TV_SYMOUT);
> -    }
>  }

What's the replacement mechanism for the first pass on global_decls?  The 
comment explains that generating debug info must be delayed in this case.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08 10:27 ` Eric Botcazou
@ 2015-05-08 10:35   ` Richard Biener
  2015-05-08 15:22     ` Aldy Hernandez
  2015-05-08 16:23   ` Aldy Hernandez
  2015-05-21 21:33   ` Aldy Hernandez
  2 siblings, 1 reply; 10+ messages in thread
From: Richard Biener @ 2015-05-08 10:35 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: Aldy Hernandez, GCC Patches

On Fri, May 8, 2015 at 12:26 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> @@ -5204,28 +5199,6 @@ gnat_write_global_declarations (void)
>>         types_used_by_var_decl_insert (t, dummy_global);
>>       }
>>      }
>> -
>> -  /* Output debug information for all global type declarations first.  This
>> -     ensures that global types whose compilation hasn't been finalized
>> yet, -     for example pointers to Taft amendment types, have their
>> compilation -     finalized in the right context.  */
>> -  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
>> -    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
>> -      debug_hooks->global_decl (iter);

Shouldn't that have used ->type_decl (iter) anyway?  That is, are they not
already processed via rest_of_type_compilation or does the Ada FE not
use that?

>> -  /* Proceed to optimize and emit assembly. */
>> -  symtab->finalize_compilation_unit ();
>> -
>> -  /* After cgraph has had a chance to emit everything that's going to
>> -     be emitted, output debug information for the rest of globals.  */
>> -  if (!seen_error ())
>> -    {
>> -      timevar_push (TV_SYMOUT);
>> -      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
>> -     if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
>> -       debug_hooks->global_decl (iter);
>> -      timevar_pop (TV_SYMOUT);
>> -    }
>>  }
>
> What's the replacement mechanism for the first pass on global_decls?  The
> comment explains that generating debug info must be delayed in this case.

But yes, I don't think the patches add any replacement for processing
TYPE_DECLs that happen to be in global_decls.

Richard.

> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08 10:35   ` Richard Biener
@ 2015-05-08 15:22     ` Aldy Hernandez
  2015-05-09 11:31       ` Eric Botcazou
  0 siblings, 1 reply; 10+ messages in thread
From: Aldy Hernandez @ 2015-05-08 15:22 UTC (permalink / raw)
  To: Richard Biener, Eric Botcazou; +Cc: GCC Patches

On 05/08/2015 03:35 AM, Richard Biener wrote:
> On Fri, May 8, 2015 at 12:26 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> @@ -5204,28 +5199,6 @@ gnat_write_global_declarations (void)
>>>          types_used_by_var_decl_insert (t, dummy_global);
>>>        }
>>>       }
>>> -
>>> -  /* Output debug information for all global type declarations first.  This
>>> -     ensures that global types whose compilation hasn't been finalized
>>> yet, -     for example pointers to Taft amendment types, have their
>>> compilation -     finalized in the right context.  */
>>> -  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
>>> -    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
>>> -      debug_hooks->global_decl (iter);
>
> Shouldn't that have used ->type_decl (iter) anyway?  That is, are they not
> already processed via rest_of_type_compilation or does the Ada FE not
> use that?

My question exactly.  Perhaps that was my confusion.  Why is this using 
->global_decl?

For example, the C front-end uses rest_of_type_compilation (see 
finish_struct() in c/c-decl.c) which calls ->type_decl(), or it calls 
->type_decl() from record_builtin_type().

>
>>> -  /* Proceed to optimize and emit assembly. */
>>> -  symtab->finalize_compilation_unit ();
>>> -
>>> -  /* After cgraph has had a chance to emit everything that's going to
>>> -     be emitted, output debug information for the rest of globals.  */
>>> -  if (!seen_error ())
>>> -    {
>>> -      timevar_push (TV_SYMOUT);
>>> -      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
>>> -     if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
>>> -       debug_hooks->global_decl (iter);
>>> -      timevar_pop (TV_SYMOUT);
>>> -    }
>>>   }
>>
>> What's the replacement mechanism for the first pass on global_decls?  The
>> comment explains that generating debug info must be delayed in this case.
>
> But yes, I don't think the patches add any replacement for processing
> TYPE_DECLs that happen to be in global_decls.

I can put the code back, but calling ->type_decl()?  Assuming you folks 
(Ada) don't want to use rest_of_type_compilation().

Aldy

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08 10:27 ` Eric Botcazou
  2015-05-08 10:35   ` Richard Biener
@ 2015-05-08 16:23   ` Aldy Hernandez
  2015-05-09 11:31     ` Eric Botcazou
  2015-05-21 21:33   ` Aldy Hernandez
  2 siblings, 1 reply; 10+ messages in thread
From: Aldy Hernandez @ 2015-05-08 16:23 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

On 05/08/2015 03:26 AM, Eric Botcazou wrote:
>> @@ -5204,28 +5199,6 @@ gnat_write_global_declarations (void)
>>   	  types_used_by_var_decl_insert (t, dummy_global);
>>   	}
>>       }
>> -
>> -  /* Output debug information for all global type declarations first.  This
>> -     ensures that global types whose compilation hasn't been finalized
>> yet, -     for example pointers to Taft amendment types, have their
>> compilation -     finalized in the right context.  */
>> -  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
>> -    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
>> -      debug_hooks->global_decl (iter);
>> -
>> -  /* Proceed to optimize and emit assembly. */
>> -  symtab->finalize_compilation_unit ();
>> -
>> -  /* After cgraph has had a chance to emit everything that's going to
>> -     be emitted, output debug information for the rest of globals.  */
>> -  if (!seen_error ())
>> -    {
>> -      timevar_push (TV_SYMOUT);
>> -      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
>> -	if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
>> -	  debug_hooks->global_decl (iter);
>> -      timevar_pop (TV_SYMOUT);
>> -    }
>>   }
>
> What's the replacement mechanism for the first pass on global_decls?  The
> comment explains that generating debug info must be delayed in this case.
>

Ah, I see what you mean.  I'll address this and repost.

Thanks.
Aldy

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08 15:22     ` Aldy Hernandez
@ 2015-05-09 11:31       ` Eric Botcazou
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Botcazou @ 2015-05-09 11:31 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 918 bytes --]

> My question exactly.  Perhaps that was my confusion.  Why is this using
> ->global_decl?

Because that's equivalent to ->type_decl (iter, false) in DWARF.

> For example, the C front-end uses rest_of_type_compilation (see
> finish_struct() in c/c-decl.c) which calls ->type_decl(), or it calls
> ->type_decl() from record_builtin_type().

All right, let's follow the gospel then. :-)  Patch attached and installed.

> I can put the code back, but calling ->type_decl()?  Assuming you folks
> (Ada) don't want to use rest_of_type_compilation().

No, we don't use it for local types either (it's a no-op in DWARF in this case 
and we don't support STABS anymore because of the need to manually delay the 
generation of debug info for local types, which is a real pain in Ada).


	* gcc-interface/utils.c (gnat_write_global_declarations): Use type_decl
	method instead of global_decl for TYPE_DECLs.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 574 bytes --]

Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c	(revision 222673)
+++ gcc-interface/utils.c	(working copy)
@@ -5211,7 +5211,7 @@ gnat_write_global_declarations (void)
      finalized in the right context.  */
   FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
     if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
-      debug_hooks->global_decl (iter);
+      debug_hooks->type_decl (iter, false);
 
   /* Proceed to optimize and emit assembly. */
   symtab->finalize_compilation_unit ();

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08 16:23   ` Aldy Hernandez
@ 2015-05-09 11:31     ` Eric Botcazou
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Botcazou @ 2015-05-09 11:31 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches

> Ah, I see what you mean.  I'll address this and repost.

Thanks.  Did the first version pass the GDB testsuite?  I thought we had a 
testcase exercising the pointer to Taft amendment type case in it.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-08 10:27 ` Eric Botcazou
  2015-05-08 10:35   ` Richard Biener
  2015-05-08 16:23   ` Aldy Hernandez
@ 2015-05-21 21:33   ` Aldy Hernandez
  2015-05-22  8:52     ` Eric Botcazou
  2 siblings, 1 reply; 10+ messages in thread
From: Aldy Hernandez @ 2015-05-21 21:33 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, jason merrill

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

On 05/08/2015 06:26 AM, Eric Botcazou wrote:

[Jason, question below.]

> What's the replacement mechanism for the first pass on global_decls?  The
> comment explains that generating debug info must be delayed in this case.

My apologies for the delay on Ada.  I have reworked the patch to leave 
the first pass on the TYPE_DECLs which are definitely needed.  I also 
optimized things a bit, since we don't need to save all the globals any 
more.

There is one regression which I'd like you and Jason's input before 
proceeding:

+FAIL: gnat.dg/specs/debug1.ads scan-assembler-times DW_AT_artificial 17

The problem is that the Ada front-end twiddles the DECL_ARTIFICIAL flag 
*after* it has called debug_hooks->early_global_decl().  The function 
gnat_to_gnu_entity() calls create_var_decl_1->rest_of_decl_compilation, 
but then much later twiddles DECL_ARTIFICIAL:

       if (!Comes_From_Source (gnat_entity))
	DECL_ARTIFICIAL (gnu_decl) = 1;

Twiddling DECL_ARTIFICIAL after we create early dwarf, means the DIE 
does not get the DW_AT_artificial.  Would it be possible for you guys 
(ahem, Ada folk) to set DECL_ARTIFICIAL before calling 
rest_of_decl_compilation?

If not, Jason I suppose we could tag the DW_AT_artificial in 
late_global_decl when we notice it now has DECL_ARTIFICIAL set.  But I'd 
prefer not to hack things this way.

Thoughts?

Aldy

[-- Attachment #2: dearly-ada.patch --]
[-- Type: text/x-patch, Size: 4233 bytes --]

gcc/ada/

	* gcc-interface/gigi.h (note_types_used_by_globals): Rename from
	gnat_write_global_declarations.
	* gcc-interface/misc.c (gnat_parse_file): Call
	note_types_used_by_globals.
	Remove LANG_HOOKS_WRITE_GLOBALS.
	* gcc-interface/utils.c: Rename global_decls to type_decls.
	(gnat_write_global_declarations): Rename
	to note_types_used_by_globals.
	Remove call to finalize_compilation_unit.
	Remove debug_hooks->global_decl() call for globals.
	(gnat_pushdecls): Only insert into type_decls if TYPE_DECL.

diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index 6d65fc5..fead2be 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -535,8 +535,7 @@ extern tree gnat_type_for_size (unsigned precision, int unsignedp);
    an unsigned type; otherwise a signed type is returned.  */
 extern tree gnat_type_for_mode (machine_mode mode, int unsignedp);
 
-/* Emit debug info for all global variable declarations.  */
-extern void gnat_write_global_declarations (void);
+extern void note_types_used_by_globals (void);
 
 /* Return the unsigned version of a TYPE_NODE, a scalar type.  */
 extern tree gnat_unsigned_type (tree type_node);
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index edaab97..2056a61 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -122,6 +122,8 @@ gnat_parse_file (void)
 
   /* Call the front end.  */
   _ada_gnat1drv ();
+
+  note_types_used_by_globals ();
 }
 
 /* Return language mask for option processing.  */
@@ -972,8 +974,6 @@ gnat_init_ts (void)
 #define LANG_HOOKS_GETDECLS		lhd_return_null_tree_v
 #undef  LANG_HOOKS_PUSHDECL
 #define LANG_HOOKS_PUSHDECL		gnat_return_tree
-#undef  LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS	gnat_write_global_declarations
 #undef  LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET	gnat_get_alias_set
 #undef  LANG_HOOKS_PRINT_DECL
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 5968857..3ef3a3a 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -227,8 +227,8 @@ static GTY((deletable)) struct gnat_binding_level *free_binding_level;
 /* The context to be used for global declarations.  */
 static GTY(()) tree global_context;
 
-/* An array of global declarations.  */
-static GTY(()) vec<tree, va_gc> *global_decls;
+/* An array of global type declarations.  */
+static GTY(()) vec<tree, va_gc> *type_decls;
 
 /* An array of builtin function declarations.  */
 static GTY(()) vec<tree, va_gc> *builtin_decls;
@@ -765,7 +765,10 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
 	    vec_safe_push (builtin_decls, decl);
 	}
       else if (global_bindings_p ())
-	vec_safe_push (global_decls, decl);
+	{
+	  if (TREE_CODE (decl) == TYPE_DECL)
+	    vec_safe_push (type_decls, decl);
+	}
       else
 	{
 	  DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block);
@@ -5176,7 +5179,7 @@ smaller_form_type_p (tree type, tree orig_type)
 static GTY (()) tree dummy_global;
 
 void
-gnat_write_global_declarations (void)
+note_types_used_by_globals (void)
 {
   unsigned int i;
   tree iter;
@@ -5209,23 +5212,9 @@ gnat_write_global_declarations (void)
      ensures that global types whose compilation hasn't been finalized yet,
      for example pointers to Taft amendment types, have their compilation
      finalized in the right context.  */
-  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
-    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
+  FOR_EACH_VEC_SAFE_ELT (type_decls, i, iter)
+    if (!DECL_IGNORED_P (iter))
       debug_hooks->type_decl (iter, false);
-
-  /* Proceed to optimize and emit assembly. */
-  symtab->finalize_compilation_unit ();
-
-  /* After cgraph has had a chance to emit everything that's going to
-     be emitted, output debug information for the rest of globals.  */
-  if (!seen_error ())
-    {
-      timevar_push (TV_SYMOUT);
-      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
-	if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
-	  debug_hooks->global_decl (iter);
-      timevar_pop (TV_SYMOUT);
-    }
 }
 
 /* ************************************************************************

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-21 21:33   ` Aldy Hernandez
@ 2015-05-22  8:52     ` Eric Botcazou
  2015-05-22 12:33       ` Aldy Hernandez
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Botcazou @ 2015-05-22  8:52 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches, jason merrill

> My apologies for the delay on Ada.  I have reworked the patch to leave
> the first pass on the TYPE_DECLs which are definitely needed.  I also
> optimized things a bit, since we don't need to save all the globals any
> more.

Thanks, this looks fine modulo a couple of nits, see below.

> There is one regression which I'd like you and Jason's input before
> proceeding:
> 
> +FAIL: gnat.dg/specs/debug1.ads scan-assembler-times DW_AT_artificial 17
> 
> The problem is that the Ada front-end twiddles the DECL_ARTIFICIAL flag
> *after* it has called debug_hooks->early_global_decl().  The function
> gnat_to_gnu_entity() calls create_var_decl_1->rest_of_decl_compilation,
> but then much later twiddles DECL_ARTIFICIAL:
> 
>        if (!Comes_From_Source (gnat_entity))
> 	DECL_ARTIFICIAL (gnu_decl) = 1;
> 
> Twiddling DECL_ARTIFICIAL after we create early dwarf, means the DIE
> does not get the DW_AT_artificial.  Would it be possible for you guys
> (ahem, Ada folk) to set DECL_ARTIFICIAL before calling
> rest_of_decl_compilation?

Sure, just add a ??? comment before the above lines for now.


@@ -535,8 +535,7 @@ extern tree gnat_type_for_size (unsigned precision, int 
unsignedp);
    an unsigned type; otherwise a signed type is returned.  */
 extern tree gnat_type_for_mode (machine_mode mode, int unsignedp);
 
-/* Emit debug info for all global variable declarations.  */
-extern void gnat_write_global_declarations (void);
+extern void note_types_used_by_globals (void);

The comment needs to be adjusted instead of removed and preferably be the same 
as the one (ajusted too) above the function in utils.c.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [patch 1/10] debug-early merge: Ada front-end
  2015-05-22  8:52     ` Eric Botcazou
@ 2015-05-22 12:33       ` Aldy Hernandez
  0 siblings, 0 replies; 10+ messages in thread
From: Aldy Hernandez @ 2015-05-22 12:33 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, jason merrill

[-- Attachment #1: Type: text/plain, Size: 1844 bytes --]

On 05/22/2015 04:31 AM, Eric Botcazou wrote:
>> My apologies for the delay on Ada.  I have reworked the patch to leave
>> the first pass on the TYPE_DECLs which are definitely needed.  I also
>> optimized things a bit, since we don't need to save all the globals any
>> more.
>
> Thanks, this looks fine modulo a couple of nits, see below.
>
>> There is one regression which I'd like you and Jason's input before
>> proceeding:
>>
>> +FAIL: gnat.dg/specs/debug1.ads scan-assembler-times DW_AT_artificial 17
>>
>> The problem is that the Ada front-end twiddles the DECL_ARTIFICIAL flag
>> *after* it has called debug_hooks->early_global_decl().  The function
>> gnat_to_gnu_entity() calls create_var_decl_1->rest_of_decl_compilation,
>> but then much later twiddles DECL_ARTIFICIAL:
>>
>>         if (!Comes_From_Source (gnat_entity))
>> 	DECL_ARTIFICIAL (gnu_decl) = 1;
>>
>> Twiddling DECL_ARTIFICIAL after we create early dwarf, means the DIE
>> does not get the DW_AT_artificial.  Would it be possible for you guys
>> (ahem, Ada folk) to set DECL_ARTIFICIAL before calling
>> rest_of_decl_compilation?
>
> Sure, just add a ??? comment before the above lines for now.

Done.

>
>
> @@ -535,8 +535,7 @@ extern tree gnat_type_for_size (unsigned precision, int
> unsignedp);
>      an unsigned type; otherwise a signed type is returned.  */
>   extern tree gnat_type_for_mode (machine_mode mode, int unsignedp);
>
> -/* Emit debug info for all global variable declarations.  */
> -extern void gnat_write_global_declarations (void);
> +extern void note_types_used_by_globals (void);
>
> The comment needs to be adjusted instead of removed and preferably be the same
> as the one (ajusted too) above the function in utils.c.

Done.

I have queued the attached patch for merge into mainline once the rest 
of the patches are approved.

Thank you.


[-- Attachment #2: dearly-ada.patch --]
[-- Type: text/x-patch, Size: 5415 bytes --]

gcc/ada/

	* gcc-interface/gigi.h (note_types_used_by_globals): Rename from
	gnat_write_global_declarations.
	* gcc-interface/misc.c (gnat_parse_file): Call
	note_types_used_by_globals.
	Remove LANG_HOOKS_WRITE_GLOBALS.
	* gcc-interface/utils.c: Rename global_decls to type_decls.
	(gnat_write_global_declarations): Rename
	to note_types_used_by_globals.
	Remove call to finalize_compilation_unit.
	Remove debug_hooks->global_decl() call for globals.
	(gnat_pushdecls): Only insert into type_decls if TYPE_DECL.

diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index d908a1b..e778616 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -5241,6 +5241,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
       && !Present (Alias (gnat_entity))
       && !(Present (Renamed_Object (gnat_entity)) && saved))
     {
+      /* ?? DECL_ARTIFICIAL, and possibly DECL_IGNORED_P below, should
+	 be set before calling rest_of_decl_compilation above (through
+	 create_var_decl_1).  This is because rest_of_decl_compilation
+	 calls the debugging backend and will create a DIE without
+	 DW_AT_artificial.
+
+	 This is currently causing gnat.dg/specs/debug1.ads to FAIL.  */
       if (!Comes_From_Source (gnat_entity))
 	DECL_ARTIFICIAL (gnu_decl) = 1;
 
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index 6d65fc5..ace4ac8 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -535,8 +535,9 @@ extern tree gnat_type_for_size (unsigned precision, int unsignedp);
    an unsigned type; otherwise a signed type is returned.  */
 extern tree gnat_type_for_mode (machine_mode mode, int unsignedp);
 
-/* Emit debug info for all global variable declarations.  */
-extern void gnat_write_global_declarations (void);
+/* Keep track of types used at the global level and emit debug info
+   for all global types.  */
+extern void note_types_used_by_globals (void);
 
 /* Return the unsigned version of a TYPE_NODE, a scalar type.  */
 extern tree gnat_unsigned_type (tree type_node);
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c
index edaab97..2056a61 100644
--- a/gcc/ada/gcc-interface/misc.c
+++ b/gcc/ada/gcc-interface/misc.c
@@ -122,6 +122,8 @@ gnat_parse_file (void)
 
   /* Call the front end.  */
   _ada_gnat1drv ();
+
+  note_types_used_by_globals ();
 }
 
 /* Return language mask for option processing.  */
@@ -972,8 +974,6 @@ gnat_init_ts (void)
 #define LANG_HOOKS_GETDECLS		lhd_return_null_tree_v
 #undef  LANG_HOOKS_PUSHDECL
 #define LANG_HOOKS_PUSHDECL		gnat_return_tree
-#undef  LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS	gnat_write_global_declarations
 #undef  LANG_HOOKS_GET_ALIAS_SET
 #define LANG_HOOKS_GET_ALIAS_SET	gnat_get_alias_set
 #undef  LANG_HOOKS_PRINT_DECL
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index 5968857..915cbe1 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -227,8 +227,8 @@ static GTY((deletable)) struct gnat_binding_level *free_binding_level;
 /* The context to be used for global declarations.  */
 static GTY(()) tree global_context;
 
-/* An array of global declarations.  */
-static GTY(()) vec<tree, va_gc> *global_decls;
+/* An array of global type declarations.  */
+static GTY(()) vec<tree, va_gc> *type_decls;
 
 /* An array of builtin function declarations.  */
 static GTY(()) vec<tree, va_gc> *builtin_decls;
@@ -765,7 +765,10 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
 	    vec_safe_push (builtin_decls, decl);
 	}
       else if (global_bindings_p ())
-	vec_safe_push (global_decls, decl);
+	{
+	  if (TREE_CODE (decl) == TYPE_DECL)
+	    vec_safe_push (type_decls, decl);
+	}
       else
 	{
 	  DECL_CHAIN (decl) = BLOCK_VARS (current_binding_level->block);
@@ -5175,8 +5178,11 @@ smaller_form_type_p (tree type, tree orig_type)
 
 static GTY (()) tree dummy_global;
 
+/* Keep track of types used at the global level and emit debug info
+   for all global types.  */
+
 void
-gnat_write_global_declarations (void)
+note_types_used_by_globals (void)
 {
   unsigned int i;
   tree iter;
@@ -5206,26 +5212,12 @@ gnat_write_global_declarations (void)
     }
 
   /* Output debug information for all global type declarations first.  This
-     ensures that global types whose compilation hasn't been finalized yet,
+     ensures that global types whose compilation haven't been finalized yet,
      for example pointers to Taft amendment types, have their compilation
      finalized in the right context.  */
-  FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
-    if (TREE_CODE (iter) == TYPE_DECL && !DECL_IGNORED_P (iter))
+  FOR_EACH_VEC_SAFE_ELT (type_decls, i, iter)
+    if (!DECL_IGNORED_P (iter))
       debug_hooks->type_decl (iter, false);
-
-  /* Proceed to optimize and emit assembly. */
-  symtab->finalize_compilation_unit ();
-
-  /* After cgraph has had a chance to emit everything that's going to
-     be emitted, output debug information for the rest of globals.  */
-  if (!seen_error ())
-    {
-      timevar_push (TV_SYMOUT);
-      FOR_EACH_VEC_SAFE_ELT (global_decls, i, iter)
-	if (TREE_CODE (iter) != TYPE_DECL && !DECL_IGNORED_P (iter))
-	  debug_hooks->global_decl (iter);
-      timevar_pop (TV_SYMOUT);
-    }
 }
 
 /* ************************************************************************

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-05-22 12:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-08  0:32 [patch 1/10] debug-early merge: Ada front-end Aldy Hernandez
2015-05-08 10:27 ` Eric Botcazou
2015-05-08 10:35   ` Richard Biener
2015-05-08 15:22     ` Aldy Hernandez
2015-05-09 11:31       ` Eric Botcazou
2015-05-08 16:23   ` Aldy Hernandez
2015-05-09 11:31     ` Eric Botcazou
2015-05-21 21:33   ` Aldy Hernandez
2015-05-22  8:52     ` Eric Botcazou
2015-05-22 12:33       ` Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).