re PR debug/87443 (GCC mixes abstract and concrete instances in abstract origins...
authorRichard Biener <rguenther@suse.de>
Wed, 26 Sep 2018 14:35:48 +0000 (14:35 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 26 Sep 2018 14:35:48 +0000 (14:35 +0000)
2018-09-26  Richard Biener  <rguenther@suse.de>

PR debug/87443
* dwarf2out.c (gen_lexical_block_die): Do not equate inline
or concrete instance DIE to the tree.  Create abstract origin
attributes also for concrete instances.

* gcc.dg/debug/dwarf2/inline5.c: New testcase.

From-SVN: r264643

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c [new file with mode: 0644]

index 1531c39102beeb61ea81a7d1d56cc0ab12a7d58e..a9e276957d2a828149ca3a2d24fc896d92f64335 100644 (file)
@@ -1,3 +1,10 @@
+2018-09-26  Richard Biener  <rguenther@suse.de>
+
+       PR debug/87443
+       * dwarf2out.c (gen_lexical_block_die): Do not equate inline
+       or concrete instance DIE to the tree.  Create abstract origin
+       attributes also for concrete instances.
+
 2018-09-26  Alexey Neyman  <stilor@att.net>
 
        * graphite.h: Include <isl/id.h> and <isl/space.h>; these
index 3c10ec8bbccf87028c4fdff19f7a392daef429fd..b0c5c4f2512ce79ccbc779e719d3270e74e57095 100644 (file)
@@ -24091,18 +24091,16 @@ gen_lexical_block_die (tree stmt, dw_die_ref context_die)
     }
   else if (BLOCK_ABSTRACT_ORIGIN (stmt))
     {
-      /* If this is an inlined instance, create a new lexical die for
-        anything below to attach DW_AT_abstract_origin to.  */
+      /* If this is an inlined or conrecte instance, create a new lexical
+        die for anything below to attach DW_AT_abstract_origin to.  */
       if (old_die)
-       {
-         stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
-         equate_block_to_die (stmt, stmt_die);
-         old_die = NULL;
-       }
+       stmt_die = new_die (DW_TAG_lexical_block, context_die, stmt);
 
       tree origin = block_ultimate_origin (stmt);
-      if (origin != NULL_TREE && origin != stmt)
+      if (origin != NULL_TREE && (origin != stmt || old_die))
        add_abstract_origin_attribute (stmt_die, origin);
+
+      old_die = NULL;
     }
 
   if (old_die)
index 49df3a1398b263ebadc5d71ab839e4365a1be320..aa005e71441722601bd4618bfe094ddd49afef9d 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-26  Richard Biener  <rguenther@suse.de>
+
+       PR debug/87443
+       * gcc.dg/debug/dwarf2/inline5.c: New testcase.
+
 2018-09-26  Martin Jambor  <mjambor@suse.cz>
 
        PR c/87347
diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/inline5.c
new file mode 100644 (file)
index 0000000..4f4463b
--- /dev/null
@@ -0,0 +1,26 @@
+/* Verify that the concrete instance DW_TAG_lexical_block has an abstract
+   origin.  Verify that the inline instance has the abstract instance as
+   abstract origin rather than the concrete one.  */
+/* { dg-options "-O -gdwarf -dA" } */
+/* { dg-do compile } */
+/* { dg-final { scan-assembler-times "DW_TAG_inlined_subroutine" 2 } } */
+/* { dg-final { scan-assembler-times "DW_TAG_lexical_block\\)\[^#\]*# DW_AT_abstract_origin" 2 } } */
+/* { dg-final { scan-assembler-times "DW_TAG_lexical_block\\)\[^#\]*# \\(DIE \\(0x\[0-9a-f\]*\\) DW_TAG_variable" 1 } } */
+/* We do not know which is output first so look for both invalid abstract
+   origins on the lexical blocks (knowing that the abstract instance has
+   no attribute following the DW_TAG_lexical_block.  */
+/* { dg-final { scan-assembler-not "\\(DIE \\(0x(\[0-9a-f\]*)\\) DW_TAG_lexical_block\\)\[^#\]*# \[^(\].*DW_TAG_lexical_block\\)\[^#x\]*x\\1\[^#\]*# DW_AT_abstract_origin" } } */
+/* { dg-final { scan-assembler-not "DW_TAG_lexical_block\\)\[^#x\]*x(\[0-9a-f\]*)\[^#\]*# DW_AT_abstract_origin.*\\(DIE \\(0x\\1\\) DW_TAG_lexical_block\\)\[^#\]*# DW_AT" } } */
+
+int foo (int i)
+{
+    {
+      volatile int j = i + 3;
+      return j - 2;
+    }
+}
+int main()
+{
+  volatile int z = foo (-1);
+  return z;
+}