From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [committed] gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369]
Date: Tue, 25 Oct 2022 10:47:29 +0200 [thread overview]
Message-ID: <Y1eiocGGtzckn57A@tucnak> (raw)
Hi!
The FEs emit errors about jumps into assume attribute conditions,
but when we add GIMPLE_ASSUME for the condition which is reachable
through those jumps, we can run into cfg verification diagnostics.
Fixed by throwing the IFN_ASSUME away during gimplification if
seen_error () - like we already do for -O0. GIMPLE_ASSUME in the middle-end
is a pure optimization thing and if errors were reported, the optimizations
will not be beneficial for anything.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
2022-10-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/107369
* gimplify.cc (gimplify_call_expr): If seen_error, handle complex
IFN_ASSUME the same as for -O0.
* gcc.dg/attr-assume-4.c: New test.
* g++.dg/cpp23/attr-assume8.C: New test.
--- gcc/gimplify.cc.jj 2022-10-18 10:38:48.146406234 +0200
+++ gcc/gimplify.cc 2022-10-24 10:22:08.590902730 +0200
@@ -3570,7 +3570,7 @@ gimplify_call_expr (tree *expr_p, gimple
return GS_OK;
}
/* If not optimizing, ignore the assumptions. */
- if (!optimize)
+ if (!optimize || seen_error ())
{
*expr_p = NULL_TREE;
return GS_ALL_DONE;
--- gcc/testsuite/gcc.dg/attr-assume-4.c.jj 2022-10-24 10:31:30.654197800 +0200
+++ gcc/testsuite/gcc.dg/attr-assume-4.c 2022-10-24 10:33:21.214682782 +0200
@@ -0,0 +1,12 @@
+/* PR tree-optimization/107369 */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -O1" } */
+
+void
+foo (int x)
+{
+ if (x == 1)
+ goto l1; /* { dg-error "jump into statement expression" } */
+
+ [[gnu::assume (({ l1:; 1; }))]]; /* { dg-message "label 'l1' defined here" } */
+}
--- gcc/testsuite/g++.dg/cpp23/attr-assume8.C.jj 2022-10-24 10:48:35.550198403 +0200
+++ gcc/testsuite/g++.dg/cpp23/attr-assume8.C 2022-10-24 10:35:52.025616208 +0200
@@ -0,0 +1,12 @@
+// PR tree-optimization/107369
+// { dg-do compile { target c++11 } }
+// { dg-options "-O1" }
+
+void
+foo (int x)
+{
+ if (x == 1)
+ goto l1; // { dg-message "from here" }
+
+ [[assume (({ l1:; 1; }))]]; // { dg-error "jump to label 'l1'" }
+} // { dg-message "enters statement expression" "" { target *-*-* } .-1 }
Jakub
reply other threads:[~2022-10-25 8:47 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=Y1eiocGGtzckn57A@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@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).