]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR c++/85659 (ICE with inline assembly inside virtual function)
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:51:44 +0000 (19:51 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:51:44 +0000 (19:51 +0200)
Backported from mainline
2018-05-06  Jakub Jelinek  <jakub@redhat.com>

PR c++/85659
* cfgexpand.c (expand_asm_stmt): Don't create a temporary if
the type is addressable.  Don't force op into register if it has
BLKmode.

* g++.dg/ext/asm14.C: New test.
* g++.dg/ext/asm15.C: New test.
* g++.dg/ext/asm16.C: New test.

From-SVN: r262098

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

index 6bafb746d894a50fee15281ba20f884b20c270ef..7d162fbcaa4233c62ce6f4e1a58242ac0a95f981 100644 (file)
@@ -1,6 +1,13 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-05-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/85659
+       * cfgexpand.c (expand_asm_stmt): Don't create a temporary if
+       the type is addressable.  Don't force op into register if it has
+       BLKmode.
+
        2018-04-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/85431
index b612293b1a7a6c03a2bf494276b4aec917bf15ee..2163bddbbd5515c27170a0d77b438b8e3516bc3c 100644 (file)
@@ -2974,14 +2974,14 @@ expand_asm_stmt (gasm *stmt)
 
       generating_concat_p = 0;
 
-      if ((TREE_CODE (val) == INDIRECT_REF
-          && allows_mem)
+      if ((TREE_CODE (val) == INDIRECT_REF && allows_mem)
          || (DECL_P (val)
              && (allows_mem || REG_P (DECL_RTL (val)))
              && ! (REG_P (DECL_RTL (val))
                    && GET_MODE (DECL_RTL (val)) != TYPE_MODE (type)))
          || ! allows_reg
-         || is_inout)
+         || is_inout
+         || TREE_ADDRESSABLE (type))
        {
          op = expand_expr (val, NULL_RTX, VOIDmode,
                            !allows_reg ? EXPAND_MEMORY : EXPAND_WRITE);
@@ -2990,7 +2990,7 @@ expand_asm_stmt (gasm *stmt)
 
          if (! allows_reg && !MEM_P (op))
            error ("output number %d not directly addressable", i);
-         if ((! allows_mem && MEM_P (op))
+         if ((! allows_mem && MEM_P (op) && GET_MODE (op) != BLKmode)
              || GET_CODE (op) == CONCAT)
            {
              rtx old_op = op;
index 92d3b5aaeb35a3ef4fdef85f9057356d6be16d5e..b9d590446fc3e180950e0d731eb9cd681c2f88d1 100644 (file)
@@ -1,6 +1,13 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-05-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/85659
+       * g++.dg/ext/asm14.C: New test.
+       * g++.dg/ext/asm15.C: New test.
+       * g++.dg/ext/asm16.C: New test.
+
        2018-04-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/85300
diff --git a/gcc/testsuite/g++.dg/ext/asm14.C b/gcc/testsuite/g++.dg/ext/asm14.C
new file mode 100644 (file)
index 0000000..f7f61aa
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/85659
+// { dg-do compile }
+
+struct S { S (); ~S (); int s; };
+
+void
+foo (S &s)
+{
+  __asm volatile ("" : "+m,r" (s) : : "memory");
+}
diff --git a/gcc/testsuite/g++.dg/ext/asm15.C b/gcc/testsuite/g++.dg/ext/asm15.C
new file mode 100644 (file)
index 0000000..c4946dd
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/85659
+// { dg-do compile }
+
+struct S { S (); ~S (); int s; };
+
+void
+foo (S &s)
+{
+  __asm volatile ("" : "+r" (s) : : "memory"); // { dg-error "" }
+}
diff --git a/gcc/testsuite/g++.dg/ext/asm16.C b/gcc/testsuite/g++.dg/ext/asm16.C
new file mode 100644 (file)
index 0000000..565cbb3
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/85659
+// { dg-do compile }
+
+struct S { S (); ~S (); int s[64]; } s;
+
+void
+foo ()
+{
+  __asm volatile ("" : "=r" (s) : : "memory"); // { dg-error "" }
+}