This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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][C++] Avoid PCH dependent mangling


With the passes.c hunk in the patch below we FAIL assembly comparison
of g++.dg/pch/system-[12].C because with PCH we have computed
DECL_ASSEMBLER_NAME and thus appended DW_AT_linkage_name early during
PCH generation while without PCH we compute it lazily and end up
appending DW_AT_specification earlier.  Thus we have swapped dwarf
attribute order and assembly comparison fails.

Clearly this kind of "IL" changes dependent on whether we are writing
a PCH file is going to cause differences down the food chain.
(there is another case in instantiate_decl calling add_pending_template
dependent on pch_file)

Now a simple solution is to simply not do that (mangle decls).  Another
would be to always mangle decls where we now do so conditional on PCH.
Another soulution is to declare we don't care about assembly differences
with/without using PCH and remove assembly comparison from the
testsuite harness.

Bootstrapped on x86_64-unknown-linux-gnu, testing + gdb testing in 
progress.

Ok for trunk (with note_decl_for_pch completely removed)?

The passes.c hunk is needed because we otherwise miss to properly
create the early DIEs for those kind of globals (we'll be left
with a declaration DIE from the type DIE creation and miss the
definition part).

Thanks,
Richard.

2015-08-27  Richard Biener  <rguenther@suse.de>

	* passes.c (rest_of_decl_compilation): Also call early_global_decl
	on global definitions in type context.

	cp/
	* semantics.c (note_decl_for_pch): Do not mangle the decl.

Index: gcc/passes.c
===================================================================
--- gcc/passes.c	(revision 227258)
+++ gcc/passes.c	(working copy)
@@ -318,7 +318,15 @@ rest_of_decl_compilation (tree decl,
       && !decl_function_context (decl)
       && !current_function_decl
       && DECL_SOURCE_LOCATION (decl) != BUILTINS_LOCATION
-      && !decl_type_context (decl)
+      && (!decl_type_context (decl)
+	  /* If we created a varpool node for the decl make sure to
+	     call early_global_decl.  Otherwise we miss changes
+	     introduced by member definitions like
+	       struct A { static int staticdatamember; };
+	       int A::staticdatamember;
+	     and thus have incomplete early debug.  */
+	  || (TREE_CODE (decl) == VAR_DECL
+	      && TREE_STATIC (decl) && !DECL_EXTERNAL (decl)))
       /* Avoid confusing the debug information machinery when there are
 	 errors.  */
       && !seen_error ())
Index: gcc/cp/semantics.c
===================================================================
--- gcc/cp/semantics.c	(revision 227258)
+++ gcc/cp/semantics.c	(working copy)
@@ -2962,15 +2962,21 @@ finish_member_declaration (tree decl)
    translation units which include the PCH file.  */
 
 void
-note_decl_for_pch (tree decl)
+note_decl_for_pch (tree)
 {
   gcc_assert (pch_file);
 
+  /* ???  This changes debug info with/without PCH as DW_AT_linkage_name
+     attributes are added at different times (early when with PCH
+     or late, via pending assembler names, when without PCH).
+     See g++.dg/pch/system-[12].C.  */
+#if 0
   /* There's a good chance that we'll have to mangle names at some
      point, even if only for emission in debugging information.  */
   if (VAR_OR_FUNCTION_DECL_P (decl)
       && !processing_template_decl)
     mangle_decl (decl);
+#endif
 }
 
 /* Finish processing a complete template declaration.  The PARMS are


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