]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Thu, 24 Oct 2019 09:38:56 +0000 (09:38 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 24 Oct 2019 09:38:56 +0000 (09:38 +0000)
2019-10-24  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-10-17  Richard Biener  <rguenther@suse.de>

PR debug/91887
* dwarf2out.c (gen_formal_parameter_die): Also try to match
context_die against a DW_TAG_GNU_formal_parameter_pack parent.

* g++.dg/debug/dwarf2/pr91887.C: New testcase.

2019-09-19  Richard Biener  <rguenther@suse.de>

PR tree-optimization/91812
* tree-ssa-phiprop.c (propagate_with_phi): Do not replace
volatile loads.

* gcc.dg/torture/pr91812.c: New testcase.

From-SVN: r277370

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr91812.c [new file with mode: 0644]
gcc/tree-ssa-phiprop.c

index fe43786a8e1268a9a8c33d09d02872cb54d915c3..33024b99250753cc3e3d1a80babfb9d3483ded44 100644 (file)
@@ -1,3 +1,18 @@
+2019-10-24  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-10-17  Richard Biener  <rguenther@suse.de>
+
+       PR debug/91887
+       * dwarf2out.c (gen_formal_parameter_die): Also try to match
+       context_die against a DW_TAG_GNU_formal_parameter_pack parent.
+
+       2019-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91812
+       * tree-ssa-phiprop.c (propagate_with_phi): Do not replace
+       volatile loads.
+
 2019-10-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR tree-optimization/92131
index a7f560872c0bb309607fbdc0243b01f24a61ad95..5590845d2a431e3352e4becc3800218210889c64 100644 (file)
@@ -21212,7 +21212,10 @@ gen_formal_parameter_die (tree node, tree origin, bool emit_name_p,
 
       /* If the contexts differ, we may not be talking about the same
         thing.  */
-      if (parm_die && parm_die->die_parent != context_die)
+      if (parm_die
+         && parm_die->die_parent != context_die
+         && (parm_die->die_parent->die_tag != DW_TAG_GNU_formal_parameter_pack
+             || parm_die->die_parent->die_parent != context_die))
        {
          if (!DECL_ABSTRACT_P (node))
            {
index 9dfad63b9ab3e535d19e22a54b967449a98b431c..25a0ac91a958de0aa9e3093604bd3b6b55e6cf38 100644 (file)
@@ -1,3 +1,16 @@
+2019-10-24  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-10-17  Richard Biener  <rguenther@suse.de>
+
+       PR debug/91887
+       * g++.dg/debug/dwarf2/pr91887.C: New testcase.
+
+       2019-09-19  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/91812
+       * gcc.dg/torture/pr91812.c: New testcase.
+
 2019-10-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.c-torture/execute/20191023-1.c: New test.
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr91887.C
new file mode 100644 (file)
index 0000000..6cd99cc
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-options "-g -fdebug-types-section" }
+class A {
+public:
+  A();
+  template <typename U> A(U);
+};
+template <class> struct B { typedef A type; };
+template <class R, typename... Args>
+int Bind(R(Args...), typename B<Args>::type...) { return 0; }
+void KeepBufferRefs(A, A) { A a, b(Bind(KeepBufferRefs, a, b)); }
diff --git a/gcc/testsuite/gcc.dg/torture/pr91812.c b/gcc/testsuite/gcc.dg/torture/pr91812.c
new file mode 100644 (file)
index 0000000..ebc67a0
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+/* { dg-options "-fdump-tree-optimized-blocks" } */
+
+unsigned register1;
+unsigned register2;
+
+void busy_wait_for_register (int x)
+{
+  volatile unsigned* ptr;
+  switch(x) {
+    case 0x1111:
+    ptr = &register1;
+    break;
+
+    case 0x2222:
+    ptr = &register2;
+    break;
+
+    default:
+    return;
+  }
+  while (*ptr) {}
+}
+
+/* { dg-final { scan-tree-dump "loop depth 1" "optimized" } } */
index 4f5f95df4f1b7ec045710a67fce3dedcf09a6cb6..9cb474114457306bedc7cf43015a7597762d2ac3 100644 (file)
@@ -338,8 +338,15 @@ propagate_with_phi (basic_block bb, gphi *phi, struct phiprop_d *phivn,
            && (!type
                || types_compatible_p
                     (TREE_TYPE (gimple_assign_lhs (use_stmt)), type))
-           /* We cannot replace a load that may throw or is volatile.  */
-           && !stmt_can_throw_internal (use_stmt)))
+           /* We cannot replace a load that may throw or is volatile.
+              For volatiles the transform can change the number of
+              executions if the load is inside a loop but the address
+              computations outside (PR91812).  We could relax this
+              if we guard against that appropriately.  For loads that can
+              throw we could relax things if the moved loads all are
+              known to not throw.  */
+           && !stmt_can_throw_internal (use_stmt)
+           && !gimple_has_volatile_ops (use_stmt)))
        continue;
 
       /* Check if we can move the loads.  The def stmt of the virtual use