On 10/02/14 08:53, Jason Merrill wrote:
On 09/30/2014 02:43 PM, Aldy Hernandez wrote:
+  if (parm_die
+      /* Make sure the function to which this parameter belongs to is
+     not an abstract instance.  If it is, we can't reuse anything.
+     We must create a new DW_TAG_formal_parameter with a
+     corresponding DW_AT_abstract_origin.  */
+      && !get_AT (context_die, DW_AT_abstract_origin))

Can we use the same test here that we do later in this function, namely
origin && origin != node?

Actually yes. But I think you mean "!origin", for the parm_die==true case anyhow. So something like the following (as in the attached patch):

  /* If we have a previously generated DIE, use it, unless this is an
     abstract instance (origin != NULL), in which case we need a new
     DIE with a corresponding DW_AT_abstract_origin.  */
  bool reusing_die;
  if (parm_die && origin == NULL)
    reusing_die = true;
  else
    {
      parm_die = new_die (DW_TAG_formal_parameter, context_die, node);
      reusing_die = false;
    }


-  if (origin != NULL && origin != decl)
+  if (origin != NULL && (origin != decl || old_die))

Don't we want to go back to "if (origin != NULL)" here too?

Sure.

If you are ok with this incremental patch, I will push it to the branch.

Thanks for your comments.
Aldy
commit 96593217826a123b907c600c205fd46b012c77e4
Author: Aldy Hernandez <al...@redhat.com>
Date:   Thu Oct 2 12:21:12 2014 -0700

        * dwarf2out.c (gen_formal_parameter_die): Simplify check for
        abstract instance.
        (gen_subprogram_die): Same.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 6830abd..16998c5 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -17786,13 +17786,11 @@ gen_formal_parameter_die (tree node, tree origin, 
bool emit_name_p,
        }
     }
 
+  /* If we have a previously generated DIE, use it, unless this is an
+     abstract instance (origin != NULL), in which case we need a new
+     DIE with a corresponding DW_AT_abstract_origin.  */
   bool reusing_die;
-  if (parm_die
-      /* Make sure the function to which this parameter belongs to is
-        not an abstract instance.  If it is, we can't reuse anything.
-        We must create a new DW_TAG_formal_parameter with a
-        corresponding DW_AT_abstract_origin.  */
-      && !get_AT (context_die, DW_AT_abstract_origin))
+  if (parm_die && origin == NULL)
     reusing_die = true;
   else
     {
@@ -18349,7 +18347,7 @@ gen_subprogram_die (tree decl, dw_die_ref context_die)
       && debug_info_level > DINFO_LEVEL_TERSE)
     old_die = force_decl_die (decl);
 
-  if (origin != NULL && (origin != decl || old_die))
+  if (origin != NULL)
     {
       gcc_assert (!declaration || local_scope_p (context_die));
 

Reply via email to