On Thu, 12 Jul 2018, Jakub Jelinek wrote:

> On Thu, Jul 12, 2018 at 12:29:20PM +0200, Richard Biener wrote:
> > 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?
> 
> Do you have a proof that BLOCK_NON_LOCALIZED_VAR is ever !DECL_IGNORED_P?
> 
> I see it is filled with:
>           if ((!optimize || debug_info_level > DINFO_LEVEL_TERSE)
>               && !DECL_IGNORED_P (old_var)
>               && nonlocalized_list)
>             vec_safe_push (*nonlocalized_list, old_var);
> (twice) in tree-inline.c.  Anything else that populates it?

No, I don't think so.  OK, I'll remove the loop over 
BLOCK_NON_LOCALIZED_VAR and keep the original check for it.

I also simplified stuff by hoisting the TREE_USED and friends checks.

Bootstrap & regtest running on x86_64-unknown-linux-gnu, ok?

Thanks,
Richard.

2018-07-12  Richard Biener  <rguent...@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..c2422e29658 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -25627,22 +25627,28 @@ gen_block_die (tree stmt, dw_die_ref context_die)
        we might have pruned all BLOCK_VARS as optimized out but we
        still want to generate high/low PC attributes so output it.  */
     must_output_die = 1;
-  else
+  else if (TREE_USED (stmt)
+          || TREE_ASM_WRITTEN (stmt)
+          || BLOCK_ABSTRACT (stmt))
     {
       /* 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)));
-      else if ((TREE_USED (stmt)
-               || TREE_ASM_WRITTEN (stmt)
-               || BLOCK_ABSTRACT (stmt))
-              && !dwarf2out_ignore_block (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 (BLOCK_NUM_NONLOCALIZED_VARS (stmt))
+           must_output_die = 1;
+         else
+           for (tree var = BLOCK_VARS (stmt); var; var = DECL_CHAIN (var))
+             if (!DECL_IGNORED_P (var))
+               {
+                 must_output_die = 1;
+                 break;
+               }
+       }
+      else if (!dwarf2out_ignore_block (stmt))
        must_output_die = 1;
     }
 

Reply via email to