From: Jakub Jelinek Date: Fri, 30 Aug 2019 12:27:21 +0000 (+0200) Subject: backport: re PR target/89752 (ICE in emit_move_insn, at expr.c:3723) X-Git-Tag: releases/gcc-7.5.0~227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b8d77b92690197285b7999ed4743d0d7ed6a31a;p=thirdparty%2Fgcc.git backport: re PR target/89752 (ICE in emit_move_insn, at expr.c:3723) Backported from mainline 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. * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c7eb971ffef..ab9eb91f95cb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,11 @@ Backported from mainline 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. + PR target/89726 * config/i386/i386.c (ix86_expand_floorceildf_32): In ceil compensation use x2 += 1 instead of x2 -= -1 and when honoring diff --git a/gcc/gimplify.c b/gcc/gimplify.c index ce90e7b77bae..8cc081e83117 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -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 %"); + 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 560f564f1eea..10dd5579129c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,11 @@ Backported from mainline 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. + PR target/89726 * gcc.target/i386/fpprec-1.c (x): Add 6 new constants. (expect_round, expect_rint, expect_floor, expect_ceil, expect_trunc): diff --git a/gcc/testsuite/g++.dg/ext/asm15.C b/gcc/testsuite/g++.dg/ext/asm15.C index c4946ddc5367..6c6f3dfc3db3 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 565cbb33e5f6..9ebb4dc15f9a 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 000000000000..9e7de37013e3 --- /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)); +}