]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR debug/42801
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 May 2010 16:15:38 +0000 (16:15 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 25 May 2010 16:15:38 +0000 (16:15 +0000)
* tree-inline.c (remap_decls): Remap DECL_VALUE_EXPR here...
(copy_bind_expr): ... instead of here.
(copy_tree_body_r): If id->remapping_type_depth clear TREE_BLOCK
if the block hasn't been remapped.
* dwarf2out.c (gen_formal_parameter_die, gen_variable_die): When
emitting concrete instance of abstract VLA, add DW_AT_type attribute.

* gcc.dg/guality/sra-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159826 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/sra-2.c [new file with mode: 0644]
gcc/tree-inline.c

index 02fb290b833963cc30b9fb42e04bf3132ea9ebcf..371bba7a040f3d5fc9bf09f1a0f058d75109fa0a 100644 (file)
@@ -1,3 +1,13 @@
+2010-05-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/42801
+       * tree-inline.c (remap_decls): Remap DECL_VALUE_EXPR here...
+       (copy_bind_expr): ... instead of here.
+       (copy_tree_body_r): If id->remapping_type_depth clear TREE_BLOCK
+       if the block hasn't been remapped.
+       * dwarf2out.c (gen_formal_parameter_die, gen_variable_die): When
+       emitting concrete instance of abstract VLA, add DW_AT_type attribute.
+
 2010-05-25  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/44069
index 19c322d8e21728d0f3e6d02bb25a4f153fd8b336..f77b9486a9d714f5f1d5ea7e18119a65bcb74bc1 100644 (file)
@@ -17906,22 +17906,26 @@ gen_formal_parameter_die (tree node, tree origin, bool emit_name_p,
        origin = ultimate_origin;
       if (origin != NULL)
        add_abstract_origin_attribute (parm_die, origin);
-      else
+      else if (emit_name_p)
+       add_name_and_src_coords_attributes (parm_die, node);
+      if (origin == NULL
+         || (! DECL_ABSTRACT (node_or_origin)
+             && variably_modified_type_p (TREE_TYPE (node_or_origin),
+                                          decl_function_context
+                                                           (node_or_origin))))
        {
-         tree type = TREE_TYPE (node);
-         if (emit_name_p)
-           add_name_and_src_coords_attributes (parm_die, node);
-         if (decl_by_reference_p (node))
+         tree type = TREE_TYPE (node_or_origin);
+         if (decl_by_reference_p (node_or_origin))
            add_type_attribute (parm_die, TREE_TYPE (type), 0, 0,
                                context_die);
          else
            add_type_attribute (parm_die, type,
-                               TREE_READONLY (node),
-                               TREE_THIS_VOLATILE (node),
+                               TREE_READONLY (node_or_origin),
+                               TREE_THIS_VOLATILE (node_or_origin),
                                context_die);
-         if (DECL_ARTIFICIAL (node))
-           add_AT_flag (parm_die, DW_AT_artificial, 1);
        }
+      if (origin == NULL && DECL_ARTIFICIAL (node))
+       add_AT_flag (parm_die, DW_AT_artificial, 1);
 
       if (node && node != origin)
         equate_decl_number_to_die (node, parm_die);
@@ -18624,8 +18628,9 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
   dw_die_ref var_die;
   dw_die_ref old_die = decl ? lookup_decl_die (decl) : NULL;
   dw_die_ref origin_die;
-  int declaration = (DECL_EXTERNAL (decl_or_origin)
-                    || class_or_namespace_scope_p (context_die));
+  bool declaration = (DECL_EXTERNAL (decl_or_origin)
+                     || class_or_namespace_scope_p (context_die));
+  bool specialization_p = false;
 
   ultimate_origin = decl_ultimate_origin (decl_or_origin);
   if (decl || ultimate_origin)
@@ -18769,6 +18774,7 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
     {
       /* This is a definition of a C++ class level static.  */
       add_AT_specification (var_die, old_die);
+      specialization_p = true;
       if (DECL_NAME (decl))
        {
          expanded_location s = expand_location (DECL_SOURCE_LOCATION (decl));
@@ -18782,16 +18788,26 @@ gen_variable_die (tree decl, tree origin, dw_die_ref context_die)
        }
     }
   else
+    add_name_and_src_coords_attributes (var_die, decl);
+
+  if ((origin == NULL && !specialization_p)
+      || (origin != NULL
+         && !DECL_ABSTRACT (decl_or_origin)
+         && variably_modified_type_p (TREE_TYPE (decl_or_origin),
+                                      decl_function_context
+                                                       (decl_or_origin))))
     {
-      tree type = TREE_TYPE (decl);
+      tree type = TREE_TYPE (decl_or_origin);
 
-      add_name_and_src_coords_attributes (var_die, decl);
-      if (decl_by_reference_p (decl))
+      if (decl_by_reference_p (decl_or_origin))
        add_type_attribute (var_die, TREE_TYPE (type), 0, 0, context_die);
       else
-       add_type_attribute (var_die, type, TREE_READONLY (decl),
-                           TREE_THIS_VOLATILE (decl), context_die);
+       add_type_attribute (var_die, type, TREE_READONLY (decl_or_origin),
+                           TREE_THIS_VOLATILE (decl_or_origin), context_die);
+    }
 
+  if (origin == NULL && !specialization_p)
+    {
       if (TREE_PUBLIC (decl))
        add_AT_flag (var_die, DW_AT_external, 1);
 
index 42e23ab5c70b4bbf2bd30bb1f5872437be67aab9..d520dd14834f70c528018540e2663df77e3dc1bd 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/42801
+       * gcc.dg/guality/sra-2.c: New test.
+
 2010-05-25  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/44069
diff --git a/gcc/testsuite/gcc.dg/guality/sra-2.c b/gcc/testsuite/gcc.dg/guality/sra-2.c
new file mode 100644 (file)
index 0000000..6773775
--- /dev/null
@@ -0,0 +1,55 @@
+/* PR debug/42801 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+void __attribute__((noinline))
+fn1 (int *x, int y)
+{
+  asm volatile ("" : : "rm" (x), "rm" (y) : "memory");
+}
+
+static inline __attribute__((always_inline)) int
+fn2 (int i)
+{
+  int a[i];
+  fn1 (a, i);
+  fn1 (a, i);          /* { dg-final { gdb-test 16 "sizeof (a)" "5 * sizeof (int)" } } */
+  return i;
+}
+
+static inline __attribute__((always_inline)) int
+fn3 (int i)
+{
+  int a[i];
+  fn1 (a, i);
+  fn1 (a, i);          /* { dg-final { gdb-test 25 "sizeof (a)" "6 * sizeof (int)" } } */
+  return i;
+}
+
+static inline __attribute__((always_inline)) int
+fn4 (int i)
+{
+  return fn3 (i);
+}
+
+int __attribute__((noinline))
+fn5 (void)
+{
+  return fn2 (5) + 1;
+}
+
+int __attribute__((noinline))
+fn6 (int i)
+{
+  return fn2 (i + 1) + fn4 (i + 2) + fn4 (i + 2) + 1;
+}
+
+int
+main (void)
+{
+  int x = 4;
+  asm volatile ("" : "+r" (x));
+  fn5 ();
+  fn6 (x);
+  return 0;
+}
index 4c51f3b10c837b4ca5c50b3d794e69a4ab46fcf3..342b5a5f082fdd23f807f365ad9b60b825468d3f 100644 (file)
@@ -574,6 +574,19 @@ remap_decls (tree decls, VEC(tree,gc) **nonlocalized_list, copy_body_data *id)
          gcc_assert (DECL_P (new_var));
          TREE_CHAIN (new_var) = new_decls;
          new_decls = new_var;
+         /* Also copy value-expressions.  */
+         if (TREE_CODE (new_var) == VAR_DECL
+             && DECL_HAS_VALUE_EXPR_P (new_var))
+           {
+             tree tem = DECL_VALUE_EXPR (new_var);
+             bool old_regimplify = id->regimplify;
+             id->remapping_type_depth++;
+             walk_tree (&tem, copy_tree_body_r, id, NULL);
+             id->remapping_type_depth--;
+             id->regimplify = old_regimplify;
+             SET_DECL_VALUE_EXPR (new_var, tem);
+           }
        }
     }
 
@@ -665,23 +678,9 @@ copy_bind_expr (tree *tp, int *walk_subtrees, copy_body_data *id)
     }
 
   if (BIND_EXPR_VARS (*tp))
-    {
-      tree t;
-
-      /* This will remap a lot of the same decls again, but this should be
-        harmless.  */
-      BIND_EXPR_VARS (*tp) = remap_decls (BIND_EXPR_VARS (*tp), NULL, id);
-      /* Also copy value-expressions.  */
-      for (t = BIND_EXPR_VARS (*tp); t; t = TREE_CHAIN (t))
-       if (TREE_CODE (t) == VAR_DECL
-           && DECL_HAS_VALUE_EXPR_P (t))
-         {
-           tree tem = DECL_VALUE_EXPR (t);
-           walk_tree (&tem, copy_tree_body_r, id, NULL);
-           SET_DECL_VALUE_EXPR (t, tem);
-         }
-    }
+    /* This will remap a lot of the same decls again, but this should be
+       harmless.  */
+    BIND_EXPR_VARS (*tp) = remap_decls (BIND_EXPR_VARS (*tp), NULL, id);
 }
 
 
@@ -1116,8 +1115,9 @@ copy_tree_body_r (tree *tp, int *walk_subtrees, void *data)
              tree *n;
              n = (tree *) pointer_map_contains (id->decl_map,
                                                 TREE_BLOCK (*tp));
-             gcc_assert (n);
-             new_block = *n;
+             gcc_assert (n || id->remapping_type_depth != 0);
+             if (n)
+               new_block = *n;
            }
          TREE_BLOCK (*tp) = new_block;
        }