]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR target/89752 (ICE in emit_move_insn, at expr.c:3723)
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 12:27:21 +0000 (14:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 12:27:21 +0000 (14:27 +0200)
Backported from mainline
2019-03-19  Jakub Jelinek  <jakub@redhat.com>

PR target/89752
* gimplify.c (gimplify_asm_expr): For output argument with
TREE_ADDRESSABLE type, clear allows_reg if it allows memory, otherwise
diagnose error.

* g++.dg/ext/asm15.C: Check for particular diagnostic wording.
* g++.dg/ext/asm16.C: Likewise.
* g++.dg/ext/asm17.C: New test.

From-SVN: r275136

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/asm15.C
gcc/testsuite/g++.dg/ext/asm16.C
gcc/testsuite/g++.dg/ext/asm17.C [new file with mode: 0644]

index 8c7eb971ffef90117fc71ea550e0a1dbc82c5d30..ab9eb91f95cb0630945364d2f8a2383969faf037 100644 (file)
@@ -3,6 +3,11 @@
        Backported from mainline
        2019-03-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/89752
+       * gimplify.c (gimplify_asm_expr): For output argument with
+       TREE_ADDRESSABLE type, clear allows_reg if it allows memory, otherwise
+       diagnose error.
+
        PR target/89726
        * config/i386/i386.c (ix86_expand_floorceildf_32): In ceil
        compensation use x2 += 1 instead of x2 -= -1 and when honoring
index ce90e7b77bae30740809e2d8d07ee187390a221d..8cc081e83117a83a21296740a1605246357b0e96 100644 (file)
@@ -5966,6 +5966,19 @@ gimplify_asm_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
          is_inout = false;
        }
 
+      /* If we can't make copies, we can only accept memory.  */
+      if (TREE_ADDRESSABLE (TREE_TYPE (TREE_VALUE (link))))
+       {
+         if (allows_mem)
+           allows_reg = 0;
+         else
+           {
+             error ("impossible constraint in %<asm%>");
+             error ("non-memory output %d must stay in memory", i);
+             return GS_ERROR;
+           }
+       }
+
       if (!allows_reg && allows_mem)
        mark_addressable (TREE_VALUE (link));
 
index 560f564f1eea783a1d3618ac3463a6ff75a19eda..10dd5579129cbe9425d391b947d197adddbff19f 100644 (file)
@@ -3,6 +3,11 @@
        Backported from mainline
        2019-03-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR target/89752
+       * g++.dg/ext/asm15.C: Check for particular diagnostic wording.
+       * g++.dg/ext/asm16.C: Likewise.
+       * g++.dg/ext/asm17.C: New test.
+
        PR target/89726
        * gcc.target/i386/fpprec-1.c (x): Add 6 new constants.
        (expect_round, expect_rint, expect_floor, expect_ceil, expect_trunc):
index c4946ddc5367019eb1e223226256fff4b06bfebe..6c6f3dfc3db3b8adee6a1f604e754376ed5c87bc 100644 (file)
@@ -6,5 +6,6 @@ struct S { S (); ~S (); int s; };
 void
 foo (S &s)
 {
-  __asm volatile ("" : "+r" (s) : : "memory"); // { dg-error "" }
+  __asm volatile ("" : "+r" (s) : : "memory"); // { dg-error "impossible constraint" }
+                                               // { dg-error "must stay in memory" "" { target *-*-* } .-1 }
 }
index 565cbb33e5f6cc8b605c99e16ec4120c68bf54cb..9ebb4dc15f9a45ffada74c9dabc8822f9c6fcb44 100644 (file)
@@ -6,5 +6,6 @@ struct S { S (); ~S (); int s[64]; } s;
 void
 foo ()
 {
-  __asm volatile ("" : "=r" (s) : : "memory"); // { dg-error "" }
+  __asm volatile ("" : "=r" (s) : : "memory"); // { dg-error "impossible constraint" }
+                                               // { dg-error "must stay in memory" "" { target *-*-* } .-1 }
 }
diff --git a/gcc/testsuite/g++.dg/ext/asm17.C b/gcc/testsuite/g++.dg/ext/asm17.C
new file mode 100644 (file)
index 0000000..9e7de37
--- /dev/null
@@ -0,0 +1,11 @@
+// PR target/89752
+// { dg-do compile }
+
+struct A { A (); ~A (); short c; };
+
+void
+foo ()
+{
+  A a0, a1;
+  __asm volatile ("" : "+rm" (a0), "+rm" (a1));
+}