Message ID | 554C0417.8020300@redhat.com |
---|---|
State | New |
Headers | show |
> @@ -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.
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
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
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
> 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.
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); - } } /* ************************************************************************