From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 2D7163857B85; Wed, 14 Sep 2022 12:51:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2D7163857B85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663159874; bh=BeEGcsp7b0KH7Dsd6rYnEIerRILAmOz2kggK8E1Zsgg=; h=From:To:Subject:Date:From; b=UymxeRZQ1jeGoNo6qvrcA1xYEBVS1Xh4X1kqZ9TCnfz4E7jLPk9nt3HQSgVazySC8 PTpySUiwEs4l7ZMzuMFDM92hFs5is6LNemPA9gblBvXgm7HqUPGcI/6kIWoMPGyfT7 tNaG9dGiqXIPuBkmZzawF8er3rSKeeaYRoVBYOCQ= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-2664] tree-optimization/106938 - cleanup abnormal edges after inlining X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 12a8d5e2f2e7d7535115e4e105c0f9eb4d50fdad X-Git-Newrev: cd14c97cd92ca11c66ee3d8dc4dd543c5aa8e024 Message-Id: <20220914125114.2D7163857B85@sourceware.org> Date: Wed, 14 Sep 2022 12:51:14 +0000 (GMT) List-Id: https://gcc.gnu.org/g:cd14c97cd92ca11c66ee3d8dc4dd543c5aa8e024 commit r13-2664-gcd14c97cd92ca11c66ee3d8dc4dd543c5aa8e024 Author: Richard Biener Date: Wed Sep 14 13:53:56 2022 +0200 tree-optimization/106938 - cleanup abnormal edges after inlining After inlining and IPA transforms we run fixup_cfg to fixup CFG effects in other functions. But that fails to clean abnormal edges from non-pure/const calls which might no longer be necessary when ->calls_setjmp is false. The following ensures this happens and refactors things so we call EH/abnormal cleanup only on the last stmt in a block. PR tree-optimization/106938 * tree-cfg.cc (execute_fixup_cfg): Purge dead abnormal edges for all last stmts in a block. Do EH cleanup only on the last stmt in a block. * gcc.dg/pr106938.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/pr106938.c | 36 ++++++++++++++++++++++++++++++++++++ gcc/tree-cfg.cc | 13 +++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/gcc/testsuite/gcc.dg/pr106938.c b/gcc/testsuite/gcc.dg/pr106938.c new file mode 100644 index 00000000000..7365a8c29fb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106938.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fno-ipa-pure-const -fno-tree-ccp -Wuninitialized" } */ + +int n; + +void +undefined (void); + +__attribute__ ((returns_twice)) int +zero (void) +{ + return 0; +} + +void +bar (int) +{ + int i; + + for (i = 0; i < -1; ++i) + n = 0; +} + +__attribute__ ((simd)) void +foo (void) +{ + int uninitialized; + + undefined (); + + while (uninitialized < 1) /* { dg-warning "uninitialized" } */ + { + bar (zero ()); + ++uninitialized; + } +} diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 41ce1b29d17..53be0c2ec5d 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -9836,16 +9836,12 @@ execute_fixup_cfg (void) int flags = gimple_call_flags (stmt); if (flags & (ECF_CONST | ECF_PURE | ECF_LOOPING_CONST_OR_PURE)) { - if (gimple_purge_dead_abnormal_call_edges (bb)) - todo |= TODO_cleanup_cfg; - if (gimple_in_ssa_p (cfun)) { todo |= TODO_update_ssa | TODO_cleanup_cfg; update_stmt (stmt); } } - if (flags & ECF_NORETURN && fixup_noreturn_call (stmt)) todo |= TODO_cleanup_cfg; @@ -9875,10 +9871,15 @@ execute_fixup_cfg (void) } } - if (maybe_clean_eh_stmt (stmt) + gsi_next (&gsi); + } + if (gimple *last = last_stmt (bb)) + { + if (maybe_clean_eh_stmt (last) && gimple_purge_dead_eh_edges (bb)) todo |= TODO_cleanup_cfg; - gsi_next (&gsi); + if (gimple_purge_dead_abnormal_call_edges (bb)) + todo |= TODO_cleanup_cfg; } /* If we have a basic block with no successors that does not