This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix DW_TAG_common_block generation


Hi!

As the comment in gen_variable_die says, we really should not generate
as many DW_TAG_common_block DIEs as there are variables in each common
block, just one DW_TAG_common_block grouping them all together is
sufficient.

Regtested on x86_64-linux, ok for trunk?

2008-08-15  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/23057
	* dwarf2out.c (gen_variable_die): Put all common vars for the
	same COMMON block under one DW_TAG_common_block.

--- gcc/dwarf2out.c.jj	2008-08-15 13:30:08.000000000 +0200
+++ gcc/dwarf2out.c	2008-08-15 16:10:11.000000000 +0200
@@ -13562,29 +13562,33 @@ gen_variable_die (tree decl, dw_die_ref 
   com_decl = fortran_common (decl, &off);
 
   /* Symbol in common gets emitted as a child of the common block, in the form
-     of a data member.
-
-     ??? This creates a new common block die for every common block symbol.
-     Better to share same common block die for all symbols in that block.  */
+     of a data member.  */
   if (com_decl)
     {
       tree field;
       dw_die_ref com_die;
-      const char *cnam = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (com_decl));
-      dw_loc_descr_ref loc = loc_descriptor_from_tree (com_decl);
 
       field = TREE_OPERAND (DECL_VALUE_EXPR (decl), 0);
-      var_die = new_die (DW_TAG_common_block, context_die, decl);
-      add_name_and_src_coords_attributes (var_die, field);
-      add_AT_flag (var_die, DW_AT_external, 1);
-      add_AT_loc (var_die, DW_AT_location, loc);
+      var_die = lookup_decl_die (com_decl);
+      if (var_die == NULL)
+	{
+	  const char *cnam
+	    = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (com_decl));
+	  dw_loc_descr_ref loc = loc_descriptor_from_tree (com_decl);
+
+	  var_die = new_die (DW_TAG_common_block, context_die, decl);
+	  add_name_and_src_coords_attributes (var_die, com_decl);
+	  add_AT_flag (var_die, DW_AT_external, 1);
+	  add_AT_loc (var_die, DW_AT_location, loc);
+	  add_pubname_string (cnam, var_die); /* ??? needed? */
+	  equate_decl_number_to_die (com_decl, var_die);
+	}
       com_die = new_die (DW_TAG_member, var_die, decl);
       add_name_and_src_coords_attributes (com_die, decl);
       add_type_attribute (com_die, TREE_TYPE (decl), TREE_READONLY (decl),
 			  TREE_THIS_VOLATILE (decl), context_die);
       add_AT_loc (com_die, DW_AT_data_member_location,
 		  int_loc_descriptor (off));
-      add_pubname_string (cnam, var_die); /* ??? needed? */
       return;
     }
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]