public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-9425] middle-end/114299 - missing error recovery from gimplify failure
@ 2024-03-11 10:22 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-03-11 10:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:119f5ae0455f02568159eafa9008a555605e7d71

commit r14-9425-g119f5ae0455f02568159eafa9008a555605e7d71
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Mar 11 09:35:07 2024 +0100

    middle-end/114299 - missing error recovery from gimplify failure
    
    When internal_get_tmp_var fails to gimplify the value the temporary
    SSA name is supposed to be initialized with we can leak SSA names
    with a NULL SSA_NAME_DEF_STMT into the IL.  That's bad, so recover
    from this by instead returning a decl in that case.
    
            PR middle-end/114299
            * gimplify.cc (internal_get_tmp_var): When gimplification
            of VAL failed, return a decl.
    
            * gcc.target/i386/pr114299.c: New testcase.

Diff:
---
 gcc/gimplify.cc                          |  5 +++++
 gcc/testsuite/gcc.target/i386/pr114299.c | 14 ++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 6ebca964cb2..d64bbf3ffbd 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -652,6 +652,11 @@ internal_get_tmp_var (tree val, gimple_seq *pre_p, gimple_seq *post_p,
   gimplify_and_add (mod, pre_p);
   ggc_free (mod);
 
+  /* If we failed to gimplify VAL then we can end up with the temporary
+     SSA name not having a definition.  In this case return a decl.  */
+  if (TREE_CODE (t) == SSA_NAME && ! SSA_NAME_DEF_STMT (t))
+    return lookup_tmp_var (val, is_formal, not_gimple_reg);
+
   return t;
 }
 
diff --git a/gcc/testsuite/gcc.target/i386/pr114299.c b/gcc/testsuite/gcc.target/i386/pr114299.c
new file mode 100644
index 00000000000..b4f30b7a95f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr114299.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-mgeneral-regs-only" } */
+
+typedef __attribute__((__vector_size__(8))) __bf16 V;
+typedef __attribute__((__vector_size__(16))) __bf16 W;
+
+V v;
+_Atomic V a;
+
+W
+foo(void) /* { dg-error "SSE" } */
+{
+  return __builtin_shufflevector(v, a, 1, 2, 5, 0, 1, 6, 6, 4); /* { dg-error "invalid" } */
+}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-11 10:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-11 10:22 [gcc r14-9425] middle-end/114299 - missing error recovery from gimplify failure Richard Biener

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).