From: Jakub Jelinek Date: Tue, 19 Mar 2019 08:11:25 +0000 (+0100) Subject: re PR target/89752 (ICE in emit_move_insn, at expr.c:3723) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=edff2a0574bfab8c35737ae1b4514ec3e18c4c96;p=gcc.git re PR target/89752 (ICE in emit_move_insn, at expr.c:3723) 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: r269793 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5ef58714b3e..f96d515a92e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2019-03-19 Jakub Jelinek + + 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. + 2019-03-19 Eric Botcazou PR rtl-optimization/89753 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 6d7a314719d..e264700989f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -6155,6 +6155,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 %"); + error ("non-memory output %d must stay in memory", i); + return GS_ERROR; + } + } + if (!allows_reg && allows_mem) mark_addressable (TREE_VALUE (link)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4e35805af65..86be3ca1060 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-03-19 Jakub Jelinek + + 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. + 2019-03-19 Eric Botcazou * c-c++-common/unroll-7.c: New test. diff --git a/gcc/testsuite/g++.dg/ext/asm15.C b/gcc/testsuite/g++.dg/ext/asm15.C index c4946ddc536..6c6f3dfc3db 100644 --- a/gcc/testsuite/g++.dg/ext/asm15.C +++ b/gcc/testsuite/g++.dg/ext/asm15.C @@ -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 } } diff --git a/gcc/testsuite/g++.dg/ext/asm16.C b/gcc/testsuite/g++.dg/ext/asm16.C index 565cbb33e5f..9ebb4dc15f9 100644 --- a/gcc/testsuite/g++.dg/ext/asm16.C +++ b/gcc/testsuite/g++.dg/ext/asm16.C @@ -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 index 00000000000..9e7de37013e --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/asm17.C @@ -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)); +}