From: Jakub Jelinek Date: Sun, 6 May 2018 21:14:35 +0000 (+0200) Subject: re PR c++/85659 (ICE with inline assembly inside virtual function) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d5754d94e47e277a761715da3d3b93158cf179d9;p=gcc.git re PR c++/85659 (ICE with inline assembly inside virtual function) 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: r259981 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f16a220efcc..d4623313b16 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-05-06 Jakub Jelinek + + 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-05-05 Roland McGrath PR other/77609 diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index deab9296001..ff2f4074df2 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -3044,14 +3044,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); @@ -3060,7 +3060,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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2de621f3083..ce19dfb6cf0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2018-05-06 Jakub Jelinek + + 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-05-06 Michael Eager * gcc.target/microblaze/others/picdtr.c: Correct option diff --git a/gcc/testsuite/g++.dg/ext/asm14.C b/gcc/testsuite/g++.dg/ext/asm14.C new file mode 100644 index 00000000000..f7f61aabd93 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/asm14.C @@ -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 index 00000000000..c4946ddc536 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/asm15.C @@ -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 index 00000000000..565cbb33e5f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/asm16.C @@ -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 "" } +}