diff mbox

[1/2] Crude debug language selection for LTO

Message ID alpine.LNX.2.00.1009171301560.28912@zhemvz.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Sept. 17, 2010, 11:04 a.m. UTC
This implements choosing a better DW_AT_language for LTO produced
debug information.  It still keeps a single DW_TAG_compile_unit,
so it will work perfectly only for a single source language.

This first patch tries to avoid using the global comp_unit_die
where easily possible.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

2010-09-17  Richard Guenther  <rguenther@suse.de>

	* dwarf2out.c (is_cu_die): New function.
	(add_pubtype): Use it.
	(gen_subprogram_die): Likewise.
	(gen_struct_or_union_type_die): Likewise.
	(dwarf2out_finish): Likewise.
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 164364)
+++ gcc/dwarf2out.c	(working copy)
@@ -9496,6 +9496,14 @@  is_symbol_die (dw_die_ref c)
 	  || c->die_tag == DW_TAG_module);
 }
 
+/* Returns true iff C is a compile-unit DIE.  */
+
+static inline bool
+is_cu_die (dw_die_ref c)
+{
+  return c->die_tag == DW_TAG_compile_unit;
+}
+
 static char *
 gen_internal_sym (const char *prefix)
 {
@@ -11343,7 +11351,7 @@  add_pubtype (tree decl, dw_die_ref die)
 
   e.name = NULL;
   if ((TREE_PUBLIC (decl)
-       || die->die_parent == comp_unit_die)
+       || is_cu_die (die->die_parent))
       && (die->die_tag == DW_TAG_typedef || COMPLETE_TYPE_P (decl)))
     {
       e.die = die;
@@ -18729,7 +18737,7 @@  gen_subprogram_die (tree decl, dw_die_re
 	 instances of inlines, since the spec requires the out-of-line copy
 	 to have the same parent.  For local class methods, this doesn't
 	 apply; we just use the old DIE.  */
-      if ((old_die->die_parent == comp_unit_die || context_die == NULL)
+      if ((is_cu_die (old_die->die_parent) || context_die == NULL)
 	  && (DECL_ARTIFICIAL (decl)
 	      || (get_AT_file (old_die, DW_AT_decl_file) == file_index
 		  && (get_AT_unsigned (old_die, DW_AT_decl_line)
@@ -19740,7 +19748,7 @@  gen_struct_or_union_type_die (tree type,
 
   scope_die = scope_die_for (type, context_die);
 
-  if (! type_die || (nested && scope_die == comp_unit_die))
+  if (! type_die || (nested && is_cu_die (scope_die)))
     /* First occurrence of type or toplevel definition of nested class.  */
     {
       dw_die_ref old_die = type_die;
@@ -22366,7 +22378,7 @@  dwarf2out_finish (const char *filename)
 
 	  if (origin)
 	    add_child_die (origin->die_parent, die);
-	  else if (die == comp_unit_die)
+	  else if (is_cu_die (die))
 	    ;
 	  else if (seen_error ())
 	    /* It's OK to be confused by errors in the input.  */