diff mbox

Workaround LTO debug info bugs in dwarf2out (PR debug/69705)

Message ID 20160224190915.GK3017@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 24, 2016, 7:09 p.m. UTC
Hi!

This is something that I hope early debug for LTO will eventually
fix, but we aren't there yet and current trunk emits bogus debug info
for inlines - DW_TAG_subprogram of the inline doesn't contain any
parameters/variables/lexical blocks etc. in it, but in
DW_TAG_inlined_subroutine we add all those directly, without abstract
origins on children (except for one on the DW_TAG_inlined_subroutine
itself).  For Fortran DW_TAG_common_block we were expecting this doesn't
ever happen, and thus assumed that decl is always non-NULL, but LTO
breaks that.

Is the following workaround ok for GCC 6?  Bootstrapped/regtested on
x86_64-linux and i686-linux?

2016-02-24  Jakub Jelinek  <jakub@redhat.com>

	PR debug/69705
	* dwarf2out.c (gen_variable_die): Work around buggy LTO
	- allow NULL decl for Fortran DW_TAG_common_block variables.


	Jakub

Comments

Jason Merrill Feb. 24, 2016, 9:08 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

--- gcc/dwarf2out.c.jj	2016-01-25 12:10:59.000000000 +0100
+++ gcc/dwarf2out.c	2016-02-24 16:00:54.811874481 +0100
@@ -21055,7 +21055,7 @@  gen_variable_die (tree decl, tree origin
 		 DW_TAG_common_block and DW_TAG_variable.  */
 	      loc = loc_list_from_tree (com_decl, 2, NULL);
 	    }
-          else if (DECL_EXTERNAL (decl))
+	  else if (DECL_EXTERNAL (decl_or_origin))
 	    add_AT_flag (com_die, DW_AT_declaration, 1);
 	  if (want_pubnames ())
 	    add_pubname_string (cnam, com_die); /* ??? needed? */
@@ -21070,8 +21070,9 @@  gen_variable_die (tree decl, tree origin
 	  remove_AT (com_die, DW_AT_declaration);
 	}
       var_die = new_die (DW_TAG_variable, com_die, decl);
-      add_name_and_src_coords_attributes (var_die, decl);
-      add_type_attribute (var_die, TREE_TYPE (decl), decl_quals (decl), false,
+      add_name_and_src_coords_attributes (var_die, decl_or_origin);
+      add_type_attribute (var_die, TREE_TYPE (decl_or_origin),
+			  decl_quals (decl_or_origin), false,
 			  context_die);
       add_AT_flag (var_die, DW_AT_external, 1);
       if (loc)
@@ -21093,9 +21094,10 @@  gen_variable_die (tree decl, tree origin
 	    }
 	  add_AT_location_description (var_die, DW_AT_location, loc);
 	}
-      else if (DECL_EXTERNAL (decl))
+      else if (DECL_EXTERNAL (decl_or_origin))
 	add_AT_flag (var_die, DW_AT_declaration, 1);
-      equate_decl_number_to_die (decl, var_die);
+      if (decl)
+	equate_decl_number_to_die (decl, var_die);
       return;
     }