public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: Jason Merrill <jason@redhat.com>, Jan Hubicka <hubicka@ucw.cz>,
		gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [patch 10/10] debug-early merge: compiler proper
Date: Tue, 02 Jun 2015 08:13:00 -0000	[thread overview]
Message-ID: <CAFiYyc3o5XxEmnzrboCrXdMAStAiySsVUcnKJqsG_NzesJ7riA@mail.gmail.com> (raw)
In-Reply-To: <556C998D.2050209@redhat.com>

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

  reply	other threads:[~2015-06-02  8:11 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08  0:41 Aldy Hernandez
2015-05-18 11:06 ` Richard Biener
2015-05-18 14:47   ` Jan Hubicka
     [not found]   ` <555CAD35.5040304@redhat.com>
2015-05-20 21:03     ` Aldy Hernandez
2015-05-20 21:11       ` Jan Hubicka
2015-05-20 22:11         ` Aldy Hernandez
2015-05-22  9:00           ` Eric Botcazou
2015-05-22 11:45           ` Richard Biener
2015-05-22 13:41             ` Aldy Hernandez
2015-05-22 11:26     ` Richard Biener
2015-05-22 14:29       ` Aldy Hernandez
2015-05-27 13:18         ` Richard Biener
2015-05-27 12:50     ` Jason Merrill
2015-05-28 20:12       ` Aldy Hernandez
2015-05-28 20:54         ` Jason Merrill
2015-05-28 21:01           ` Jan Hubicka
2015-05-28 21:10             ` Jason Merrill
2015-05-28 21:16               ` Jan Hubicka
2015-05-29 12:07           ` Richard Biener
2015-05-29 19:33           ` Aldy Hernandez
2015-05-29 19:40             ` Richard Biener
2015-05-29 19:49               ` Jason Merrill
2015-05-31  7:53                 ` Aldy Hernandez
2015-05-31 22:14                   ` Jason Merrill
2015-06-01  8:03                     ` Richard Biener
2015-06-01  8:04                       ` Richard Biener
2015-06-01 15:43                         ` Aldy Hernandez
2015-06-01 17:01                           ` Richard Biener
2015-06-01 17:42                             ` Aldy Hernandez
2015-06-02  8:13                               ` Richard Biener [this message]
2015-06-02 19:25                                 ` Aldy Hernandez
2015-05-29 19:47             ` Jason Merrill
2015-05-28 21:31       ` Aldy Hernandez
2015-05-29  6:33         ` Jason Merrill

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc3o5XxEmnzrboCrXdMAStAiySsVUcnKJqsG_NzesJ7riA@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=jason@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).