diff mbox

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

Message ID CAFiYyc3FKVgko0-ozdHropratHfmbAoDYqT_1TqmOCDvVDN2_g@mail.gmail.com
State New
Headers show

Commit Message

Richard Biener June 1, 2015, 8:04 a.m. UTC
On Mon, Jun 1, 2015 at 10:03 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Sun, May 31, 2015 at 10:38 PM, Jason Merrill <jason@redhat.com> wrote:
>> On 05/30/2015 08:52 PM, Aldy Hernandez wrote:
>>>
>>> On 05/29/2015 03:33 PM, Jason Merrill wrote:
>>>>
>>>> On 05/29/2015 03:26 PM, Richard Biener wrote:
>>>>>
>>>>> ISTR I had to mark the gimple reg used for the bound as
>>>>> non-DECL_IGNORED for the LTO stuff.
>>>>
>>>>
>>>> Let's go with that, then.
>>>
>>>
>>> Well, I did play around with that option originally, but temporaries do
>>> not end up in the symbol table, so we won't see them to feed them to
>>> late_global_decl.
>>
>>
>> The temporary has function scope, so I don't see why that would be an issue.
>
> Yeah, we should walk it via the function_decl hook on the containing function.

Btw, the following was my gimplify.c hunk:



> Richard.
>
>> Jason
>>

Comments

Aldy Hernandez June 1, 2015, 3:42 p.m. UTC | #1
On 06/01/2015 04:04 AM, Richard Biener wrote:
> On Mon, Jun 1, 2015 at 10:03 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Sun, May 31, 2015 at 10:38 PM, Jason Merrill <jason@redhat.com> wrote:
>>> On 05/30/2015 08:52 PM, Aldy Hernandez wrote:
>>>>
>>>> On 05/29/2015 03:33 PM, Jason Merrill wrote:
>>>>>
>>>>> On 05/29/2015 03:26 PM, Richard Biener wrote:
>>>>>>
>>>>>> ISTR I had to mark the gimple reg used for the bound as
>>>>>> non-DECL_IGNORED for the LTO stuff.
>>>>>
>>>>>
>>>>> Let's go with that, then.
>>>>
>>>>
>>>> Well, I did play around with that option originally, but temporaries do
>>>> not end up in the symbol table, so we won't see them to feed them to
>>>> late_global_decl.
>>>
>>>
>>> The temporary has function scope, so I don't see why that would be an issue.
>>
>> Yeah, we should walk it via the function_decl hook on the containing function.
>
> Btw, the following was my gimplify.c hunk:
>
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index d822913..10a9318 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -8994,6 +8994,12 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
>     *expr_p = unshare_expr (expr);
>
>     gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue);
> +
> +  /* The possibly generated temporary is interesting for debug information
> +     to complete the VLA type sizes and bounds.  Clear DECL_IGNORED_P.  */
> +  if (TREE_CODE (*expr_p) == VAR_DECL
> +      && DECL_ARTIFICIAL (*expr_p))
> +    DECL_IGNORED_P (*expr_p) = false;

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?

Aldy
Richard Biener June 1, 2015, 5 p.m. UTC | #2
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
>> <richard.guenther@gmail.com> wrote:
>>> On Sun, May 31, 2015 at 10:38 PM, Jason Merrill <jason@redhat.com>
>wrote:
>>>> On 05/30/2015 08:52 PM, Aldy Hernandez wrote:
>>>>>
>>>>> On 05/29/2015 03:33 PM, Jason Merrill wrote:
>>>>>>
>>>>>> On 05/29/2015 03:26 PM, Richard Biener wrote:
>>>>>>>
>>>>>>> ISTR I had to mark the gimple reg used for the bound as
>>>>>>> non-DECL_IGNORED for the LTO stuff.
>>>>>>
>>>>>>
>>>>>> Let's go with that, then.
>>>>>
>>>>>
>>>>> Well, I did play around with that option originally, but
>temporaries do
>>>>> not end up in the symbol table, so we won't see them to feed them
>to
>>>>> late_global_decl.
>>>>
>>>>
>>>> The temporary has function scope, so I don't see why that would be
>an issue.
>>>
>>> Yeah, we should walk it via the function_decl hook on the containing
>function.
>>
>> Btw, the following was my gimplify.c hunk:
>>
>> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
>> index d822913..10a9318 100644
>> --- a/gcc/gimplify.c
>> +++ b/gcc/gimplify.c
>> @@ -8994,6 +8994,12 @@ gimplify_one_sizepos (tree *expr_p, gimple_seq
>*stmt_p)
>>     *expr_p = unshare_expr (expr);
>>
>>     gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue);
>> +
>> +  /* The possibly generated temporary is interesting for debug
>information
>> +     to complete the VLA type sizes and bounds.  Clear
>DECL_IGNORED_P.  */
>> +  if (TREE_CODE (*expr_p) == VAR_DECL
>> +      && DECL_ARTIFICIAL (*expr_p))
>> +    DECL_IGNORED_P (*expr_p) = false;
>
>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).

Richard.

>Aldy
Aldy Hernandez June 1, 2015, 5:42 p.m. UTC | #3
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.

Aldy
Richard Biener June 2, 2015, 8:11 a.m. UTC | #4
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
diff mbox

Patch

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d822913..10a9318 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -8994,6 +8994,12 @@  gimplify_one_sizepos (tree *expr_p, gimple_seq *stmt_p)
   *expr_p = unshare_expr (expr);

   gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue);
+
+  /* The possibly generated temporary is interesting for debug information
+     to complete the VLA type sizes and bounds.  Clear DECL_IGNORED_P.  */
+  if (TREE_CODE (*expr_p) == VAR_DECL
+      && DECL_ARTIFICIAL (*expr_p))
+    DECL_IGNORED_P (*expr_p) = false;
 }

 /* Gimplify the body of statements of FNDECL and return a GIMPLE_BIND node