re PR debug/83084 (-fcompare-debug failure on ppc64le)
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Nov 2017 10:02:19 +0000 (11:02 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 22 Nov 2017 10:02:19 +0000 (11:02 +0100)
PR debug/83084
* valtrack.c (propagate_for_debug_subst, propagate_for_debug): Reset
debug insns if they would contain UNSPEC_VOLATILE or volatile asm.
(dead_debug_insert_temp): Likewise, but also ignore even non-volatile
asm.

* g++.dg/opt/pr83084.C: New test.

From-SVN: r255051

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/pr83084.C [new file with mode: 0644]
gcc/valtrack.c

index ace7c7c0ce75e17453285c49cd193103e3fc56e1..edd3621c74198a376c8d1ef5ca8d615ed199ffa1 100644 (file)
@@ -1,5 +1,11 @@
 2017-11-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/83084
+       * valtrack.c (propagate_for_debug_subst, propagate_for_debug): Reset
+       debug insns if they would contain UNSPEC_VOLATILE or volatile asm.
+       (dead_debug_insert_temp): Likewise, but also ignore even non-volatile
+       asm.
+
        PR middle-end/82875
        * optabs.c (expand_doubleword_mult, expand_binop): Before calling
        expand_binop with *mul_widen_optab, make sure at least one of the
index b7e0c470c4c765a0938b0b5a2343c8fe4cdddf63..7bfd96b8e0221c26924b2eda5bab71e3af2936bb 100644 (file)
@@ -1,11 +1,12 @@
 2017-11-22  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/83084
+       * g++.dg/opt/pr83084.C: New test.
+
        PR middle-end/82875
        * gcc.dg/pr82875.c: New test.
        * gcc.c-torture/compile/pr82875.c: New test.
 
-2017-11-22  Jakub Jelinek  <jakub@redhat.com>
-
        PR debug/83034
        * gcc.dg/pr83034.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/pr83084.C b/gcc/testsuite/g++.dg/opt/pr83084.C
new file mode 100644 (file)
index 0000000..d21e308
--- /dev/null
@@ -0,0 +1,16 @@
+// PR debug/83084
+// { dg-do compile }
+// { dg-options "-O2 -fcompare-debug -Wno-return-type" }
+
+enum E { F };
+template <E = F> struct A {
+  bool foo ();
+  int b;
+};
+template <> bool A<>::foo () {
+  int a;
+  do
+    if (a)
+      return false;
+  while (__atomic_compare_exchange_n (&b, &a, 0, 1, 4, 0));
+}
index 38af3f0ce51d8a4a3d12dc5320eb281469866768..d4bab00c9534cb1ce41d3d131a022c34b4334810 100644 (file)
@@ -171,10 +171,13 @@ propagate_for_debug_subst (rtx from, const_rtx old_rtx, void *data)
        if (REG_P (*iter) && ++cnt > 1)
          {
            rtx dval = make_debug_expr_from_rtl (old_rtx);
+           rtx to = pair->to;
+           if (volatile_insn_p (to))
+             to = gen_rtx_UNKNOWN_VAR_LOC ();
            /* Emit a debug bind insn.  */
            rtx bind
              = gen_rtx_VAR_LOCATION (GET_MODE (old_rtx),
-                                     DEBUG_EXPR_TREE_DECL (dval), pair->to,
+                                     DEBUG_EXPR_TREE_DECL (dval), to,
                                      VAR_INIT_STATUS_INITIALIZED);
            rtx_insn *bind_insn = emit_debug_insn_before (bind, pair->insn);
            df_insn_rescan (bind_insn);
@@ -217,6 +220,8 @@ propagate_for_debug (rtx_insn *insn, rtx_insn *last, rtx dest, rtx src,
                                         dest, propagate_for_debug_subst, &p);
          if (loc == INSN_VAR_LOCATION_LOC (insn))
            continue;
+         if (volatile_insn_p (loc))
+           loc = gen_rtx_UNKNOWN_VAR_LOC ();
          INSN_VAR_LOCATION_LOC (insn) = loc;
          df_insn_rescan (insn);
        }
@@ -660,6 +665,12 @@ dead_debug_insert_temp (struct dead_debug_local *debug, unsigned int uregno,
                }
              return 0;
            }
+         /* Asm in DEBUG_INSN is never useful, we can't emit debug info for
+            that.  And for volatile_insn_p, it is actually harmful
+            - DEBUG_INSNs shouldn't have any side-effects.  */
+         else if (GET_CODE (src) == ASM_OPERANDS
+                  || volatile_insn_p (src))
+           set = NULL_RTX;
        }
 
       /* ??? Should we try to extract it from a PARALLEL?  */