From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: Jakub Jelinek <jakub@redhat.com>
Subject: [PATCH] middle-end/105165 - sorry instead of ICE for _Complex asm goto
Date: Wed, 6 Apr 2022 14:44:38 +0200 (CEST) [thread overview]
Message-ID: <20220406124439.B089F13A8E@imap2.suse-dmz.suse.de> (raw)
Complex lowering cannot currently deal with asm gotos with _Complex
output operands. Emit a sorry instead of ICEing, those should not
appear in practice.
Bootstrapped and tested on x86_64-unknown-linux-gnu.
OK for trunk and branch?
Thanks,
Richard.
2022-04-06 Richard Biener <rguenther@suse.de>
PR middle-end/105165
* tree-complex.cc (expand_complex_asm): Sorry for asm goto
_Complex outputs.
* gcc.dg/pr105165.c: New testcase.
---
gcc/testsuite/gcc.dg/pr105165.c | 13 +++++++++++++
gcc/tree-complex.cc | 16 ++++++++++++++++
2 files changed, 29 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/pr105165.c
diff --git a/gcc/testsuite/gcc.dg/pr105165.c b/gcc/testsuite/gcc.dg/pr105165.c
new file mode 100644
index 00000000000..055a10528b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr105165.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+unsigned int _Complex a0;
+unsigned int _Complex
+foo (unsigned int _Complex a1, unsigned int _Complex a2)
+{
+ unsigned int _Complex x;
+ asm goto ("" : "=r" (x) : : : lab); /* { dg-message "sorry, unimplemented" } */
+ a0 = x;
+ lab:
+ return x + a1 + a2 + 1;
+}
diff --git a/gcc/tree-complex.cc b/gcc/tree-complex.cc
index 8f03b236094..42db96a132b 100644
--- a/gcc/tree-complex.cc
+++ b/gcc/tree-complex.cc
@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3. If not see
#include "cfgloop.h"
#include "cfganal.h"
#include "gimple-fold.h"
+#include "diagnostic-core.h"
/* For each complex ssa name, a lattice value. We're interested in finding
@@ -1614,6 +1615,7 @@ expand_complex_asm (gimple_stmt_iterator *gsi)
{
gasm *stmt = as_a <gasm *> (gsi_stmt (*gsi));
unsigned int i;
+ bool diagnosed_p = false;
for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
{
@@ -1622,6 +1624,20 @@ expand_complex_asm (gimple_stmt_iterator *gsi)
if (TREE_CODE (op) == SSA_NAME
&& TREE_CODE (TREE_TYPE (op)) == COMPLEX_TYPE)
{
+ if (gimple_asm_nlabels (stmt) > 0)
+ {
+ if (!diagnosed_p)
+ {
+ sorry_at (gimple_location (stmt),
+ "%<asm goto%> with complex typed outputs");
+ diagnosed_p = true;
+ }
+ /* Make sure to not ICE later, see PR105165. */
+ tree zero = build_zero_cst (TREE_TYPE (TREE_TYPE (op)));
+ set_component_ssa_name (op, false, zero);
+ set_component_ssa_name (op, true, zero);
+ continue;
+ }
tree type = TREE_TYPE (op);
tree inner_type = TREE_TYPE (type);
tree r = build1 (REALPART_EXPR, inner_type, op);
--
2.34.1
next reply other threads:[~2022-04-06 12:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-06 12:44 Richard Biener [this message]
2022-04-06 15:20 ` Jeff Law
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=20220406124439.B089F13A8E@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/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).