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] Fix PR86462


After my PR86413 fix to always annotate existing lexical block DIEs with
range attributes debuginfo grows significantly in case we previously
had "stale" lexical block DIEs without any variables.

The following fixes this by eliding those comletely and not emitting
a lexical block DIE for blocks that just contain DECL_INGORED_P
entities.  This solves the reported size regression and the
empty lexical block DIEs vanish.

Bootstrap & regtest running on x86_64-unknown-linux-gnu.

OK for trunk?

Thanks,
Richard.

2018-07-12  Richard Biener  <rguenther@suse.de>

	PR debug/86462
	* dwarf2out.c (gen_block_die): Only output blocks when they have
	at least one !DECL_IGNORED_P variable.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 1127713cbaf..995a463bddc 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -25632,13 +25632,30 @@ gen_block_die (tree stmt, dw_die_ref context_die)
       /* Determine if this block directly contains any "significant"
 	 local declarations which we will need to output DIEs for.  */
       if (debug_info_level > DINFO_LEVEL_TERSE)
-	/* We are not in terse mode so *any* local declaration counts
-	   as being a "significant" one.  */
-	must_output_die = ((BLOCK_VARS (stmt) != NULL
-			    || BLOCK_NUM_NONLOCALIZED_VARS (stmt))
-			   && (TREE_USED (stmt)
-			       || TREE_ASM_WRITTEN (stmt)
-			       || BLOCK_ABSTRACT (stmt)));
+	{
+	  /* We are not in terse mode so any local declaration that
+	     is not ignored for debug purposes counts as being a
+	     "significant" one.  */
+	  if (TREE_USED (stmt)
+	      || TREE_ASM_WRITTEN (stmt)
+	      || BLOCK_ABSTRACT (stmt))
+	    {
+	      for (tree var = BLOCK_VARS (stmt); var; var = DECL_CHAIN (var))
+		if (!DECL_IGNORED_P (var))
+		  {
+		    must_output_die = 1;
+		    break;
+		  }
+	      if (!must_output_die)
+		for (unsigned i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt);
+		     ++i)
+		  if (!DECL_IGNORED_P (BLOCK_NONLOCALIZED_VAR (stmt, i)))
+		    {
+		      must_output_die = 1;
+		      break;
+		    }
+	    }
+	}
       else if ((TREE_USED (stmt)
 		|| TREE_ASM_WRITTEN (stmt)
 		|| BLOCK_ABSTRACT (stmt))


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