From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id 44D6A3858010; Tue, 25 Oct 2022 08:42:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44D6A3858010 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666687355; bh=Wxrl1YJEclLBWHyQjOBymLCBqk/7RVSxgK2/pzjFm2M=; h=From:To:Subject:Date:From; b=tkjiKhnhd/IPpiekPcmoujwrp7LV4X2ajmrxhuOu1/m0jb1kSGwT6/nz8dS+UETHN h7jFO78+LTCf6br6DndSRJIrvinu5FXRlaF79r0DUzuajtp4OUTRa0w0XvTCRSDEHy lPnlzW49zaFfVj/XtJ6N6A8tStxWg4+wcb6pcnUw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3478] gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 354c97ee05b23707efbfc7ff6640dcec7336ac7a X-Git-Newrev: 7d888535f7ab80e9b08a633bfd774a923b311cde Message-Id: <20221025084235.44D6A3858010@sourceware.org> Date: Tue, 25 Oct 2022 08:42:35 +0000 (GMT) List-Id: https://gcc.gnu.org/g:7d888535f7ab80e9b08a633bfd774a923b311cde commit r13-3478-g7d888535f7ab80e9b08a633bfd774a923b311cde Author: Jakub Jelinek Date: Tue Oct 25 10:39:20 2022 +0200 gimplify: Don't add GIMPLE_ASSUME if errors were seen [PR107369] 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. 2022-10-25 Jakub Jelinek 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. Diff: --- gcc/gimplify.cc | 2 +- gcc/testsuite/g++.dg/cpp23/attr-assume8.C | 12 ++++++++++++ gcc/testsuite/gcc.dg/attr-assume-4.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 69bad340d2e..44cc9e6677b 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -3568,7 +3568,7 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p, bool want_value) return GS_OK; } /* If not optimizing, ignore the assumptions. */ - if (!optimize) + if (!optimize || seen_error ()) { *expr_p = NULL_TREE; return GS_ALL_DONE; diff --git a/gcc/testsuite/g++.dg/cpp23/attr-assume8.C b/gcc/testsuite/g++.dg/cpp23/attr-assume8.C new file mode 100644 index 00000000000..3c7a62f7fc4 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp23/attr-assume8.C @@ -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 } diff --git a/gcc/testsuite/gcc.dg/attr-assume-4.c b/gcc/testsuite/gcc.dg/attr-assume-4.c new file mode 100644 index 00000000000..e8a2b8d316c --- /dev/null +++ b/gcc/testsuite/gcc.dg/attr-assume-4.c @@ -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" } */ +}