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]

Re: [patch 10/10] debug-early merge: compiler proper


On Mon, Jun 1, 2015 at 7:42 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> On 06/01/2015 01:00 PM, Richard Biener wrote:
>>
>> On June 1, 2015 5:42:57 PM GMT+02:00, Aldy Hernandez <aldyh@redhat.com>
>> wrote:
>>>
>>> On 06/01/2015 04:04 AM, Richard Biener wrote:
>>>>
>>>> On Mon, Jun 1, 2015 at 10:03 AM, Richard Biener
>
>
>>> We still have the problem that function locals in dwarf2out are seen in
>>>
>>> decls_for_scope by iterating through BLOCK_VARS, and temporaries do not
>>>
>>> live in BLOCK_VARS.
>>>
>>> How did they get picked up and annotated in your approach?
>>
>>
>> The size type ones are in BLOCJ_VARS IIRC (or I have to check the last
>> posted patch for other related hunks).
>
>
> Hmmm, it doesn't seem so in my testcase:
>
> $ cat a.c
> unsigned int i=555;
>
> int main()
> {
>   unsigned int array[i];
>   __asm__ __volatile__ ("" : : "m" (array));
> }
>
> (gdb) print stmt
> $108 = <block 0x7ffff02b0420>
> (gdb) call debug_generic_stmt(stmt)
> BLOCK #0
>   SUPERCONTEXT: main
>   VARS: array
>
> The temporary has DECL_IGNORED_P appropriately.
>
> It does show up in DECL_STRUCT_FUNCTION()->local_decls, but so do a few
> other temporaries and SSA variables which we're not interested in.

Ok, so I have the following in my LTO debug patch (ignore the first part of the
2nd hunk - just look at the variably_modified_type_p case), which means you
are correct.  The ??? comment in process_vla_type needs fixing of course,
either there or in walk_type_fields (to catch all cases that have gimplified
sizes, see callers of gimplify_one_sizepos/gimplify_type_sizes).

I suppose we can change things this way as a followup (as it needs some work)

@@ -21036,6 +21263,31 @@ gen_block_die (tree stmt, dw_die_ref context_die)
     decls_for_scope (stmt, context_die);
 }

+static tree
+process_vla_type (tree *tp, int *walk_subtrees, void *ctx)
+{
+  /* ???  walk_type_fields doesn't walk TYPE_SIZE and friends and
+     while it walks TYPE_DOMAIN for arrays it doesn't walk
+     TYPE_MIN/MAX_VALUE.  Just special-case the ARRAY_TYPE domain
+     type case here for now.  */
+  if (TREE_CODE (*tp) == INTEGER_TYPE)
+    {
+      if (TREE_CODE (TYPE_MIN_VALUE (*tp)) == VAR_DECL
+         && DECL_ARTIFICIAL (TYPE_MIN_VALUE (*tp))
+         && !DECL_IGNORED_P (TYPE_MIN_VALUE (*tp)))
+       gen_decl_die (TYPE_MIN_VALUE (*tp), NULL_TREE, (dw_die_ref) ctx);
+      if (TREE_CODE (TYPE_MAX_VALUE (*tp)) == VAR_DECL
+         && DECL_ARTIFICIAL (TYPE_MAX_VALUE (*tp))
+         && !DECL_IGNORED_P (TYPE_MAX_VALUE (*tp)))
+       gen_decl_die (TYPE_MAX_VALUE (*tp), NULL_TREE, (dw_die_ref) ctx);
+    }
+
+  if (!TYPE_P (*tp))
+    *walk_subtrees = 0;
+
+  return NULL_TREE;
+}
+
 /* Process variable DECL (or variable with origin ORIGIN) within
    block STMT and add it to CONTEXT_DIE.  */
 static void
@@ -21061,7 +21313,44 @@ process_scope_var (tree stmt, tree decl, tree
origin, dw_die_ref context_die)
                                             stmt, context_die);
     }
   else
-    gen_decl_die (decl, origin, context_die);
+    {
+      if (decl && DECL_P (decl))
+       die = lookup_decl_die (decl);
+
+      if (in_lto_p
+         && die && die->die_parent != context_die)
+       {
+         /* ???  For non-LTO operation we do not want to get here via
+            dwarf2out_abstract_function / set_decl_origin_self which
+            ends up modifying the tree rep in some odd way instead
+            of just playing with the DIEs.  */
+         /* We associate vars with their DECL_CONTEXT first which misses
+            their BLOCK association.  Move them.  */
+         gcc_assert (die->die_parent != NULL);
+         /* ???  Moving is expensive.  Better fix DECL_CONTEXT?  */
+         dw_die_ref prev = die->die_parent->die_child;
+         while (prev->die_sib != die)
+           prev = prev->die_sib;
+         remove_child_with_prev (die, prev);
+         add_child_die (context_die, die);
+       }
+
+      if (in_lto_p
+         && TREE_CODE (decl) == VAR_DECL
+         && variably_modified_type_p (TREE_TYPE (decl), cfun->decl))
+       {
+         /* We need to add location attributes to decls refered to
+            from the decls type but we don't have DIEs for the type
+            itself materialized.  The decls are also not part of the
+            functions BLOCK tree (because they are artificial).  */
+         walk_tree (&TREE_TYPE (decl), process_vla_type, NULL, NULL);
+       }
+
+      /* ???  The following gets stray type DIEs created even for decls
+        that were created early.  */
+
+      gen_decl_die (decl, origin, context_die);
+    }
 }

 /* Generate all of the decls declared within a given scope and (recursively)


> Aldy


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