public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r9-10043] middle-end/104786 - ICE with asm and VLA
Date: Fri,  6 May 2022 11:09:05 +0000 (GMT)	[thread overview]
Message-ID: <20220506110905.C83C3394FC07@sourceware.org> (raw)

https://gcc.gnu.org/g:4ebdbc7660e6ce6dd2184b9ab6c61f0a47e3a3ab

commit r9-10043-g4ebdbc7660e6ce6dd2184b9ab6c61f0a47e3a3ab
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Mar 9 10:55:49 2022 +0100

    middle-end/104786 - ICE with asm and VLA
    
    The following fixes an ICE observed with a MEM_REF allows_mem asm
    operand referencing a VLA.  The following makes sure to not attempt
    to go the temporary creation way when we cannot.
    
    2022-03-09  Richard Biener  <rguenther@suse.de>
    
            PR middle-end/104786
            * cfgexpand.c (expand_asm_stmt): Do not generate a copy
            for VLAs without an upper size bound.
    
            * gcc.dg/pr104786.c: New testcase.
    
    (cherry picked from commit ba3ff5e35144e2afff4ccef4ccbbbbaba9870afb)

Diff:
---
 gcc/cfgexpand.c                 | 4 +++-
 gcc/testsuite/gcc.dg/pr104786.c | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 26b6bf3e6c6..b1535e15d28 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3168,7 +3168,9 @@ expand_asm_stmt (gasm *stmt)
 		    && GET_MODE (DECL_RTL (val)) != TYPE_MODE (type)))
 	  || ! allows_reg
 	  || is_inout
-	  || TREE_ADDRESSABLE (type))
+	  || TREE_ADDRESSABLE (type)
+	  || (!tree_fits_poly_int64_p (TYPE_SIZE (type))
+	      && !known_size_p (max_int_size_in_bytes (type))))
 	{
 	  op = expand_expr (val, NULL_RTX, VOIDmode,
 			    !allows_reg ? EXPAND_MEMORY : EXPAND_WRITE);
diff --git a/gcc/testsuite/gcc.dg/pr104786.c b/gcc/testsuite/gcc.dg/pr104786.c
new file mode 100644
index 00000000000..3076d236d21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr104786.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90" } */
+
+void h(void *di, int num)
+{
+  char (*t)[num] = di;
+  __asm__ ("" : "=X"( *t));
+}


                 reply	other threads:[~2022-05-06 11:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220506110905.C83C3394FC07@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).