From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id E59543858D33; Tue, 7 Feb 2023 09:35:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E59543858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675762517; bh=r4IQ83YEM7+9yzCqiU5YBANLwRQlJqFa2O33cDDQ9zk=; h=From:To:Subject:Date:From; b=na13vpfxRCjY+lOw4En3GKxsKoWD9nBNROmZvfnggLQibLjF5+ztx0pGxsOGcUgAx xs3AJx31F5/gq9SRq2JHDpbUNwkWB/kOhroSW0hvmQQBhkERn+u00fC5lbe5sI8Au4 u4a7LErMRBqTPKyaPFBemoTAdQJta8qannDx4tgo= 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-5728] ipa-split: Don't split returns_twice functions [PR106923] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: cad2412cc84518195fceb2db31e82e6df7e5a2c2 X-Git-Newrev: 5321d53279a60ee589a3c9779beb46503f9fc49f Message-Id: <20230207093517.E59543858D33@sourceware.org> Date: Tue, 7 Feb 2023 09:35:17 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5321d53279a60ee589a3c9779beb46503f9fc49f commit r13-5728-g5321d53279a60ee589a3c9779beb46503f9fc49f Author: Jakub Jelinek Date: Tue Feb 7 10:34:45 2023 +0100 ipa-split: Don't split returns_twice functions [PR106923] As discussed in the PR, returns_twice functions are rare/special beasts that need special treatment in the cfg, and inside of their bodies we don't know which part actually works the weird returns twice way (either in the fork/vfork sense, or in the setjmp) and aren't updating ab edges to reflect that. I think easiest is just to never split these, like we already never split noreturn or malloc functions. 2023-02-07 Jakub Jelinek PR tree-optimization/106923 * ipa-split.cc (execute_split_functions): Don't split returns_twice functions. * gcc.dg/pr106923.c: New test. Diff: --- gcc/ipa-split.cc | 5 +++-- gcc/testsuite/gcc.dg/pr106923.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-split.cc b/gcc/ipa-split.cc index 0113461065c..6730f4f9d0e 100644 --- a/gcc/ipa-split.cc +++ b/gcc/ipa-split.cc @@ -1715,10 +1715,11 @@ execute_split_functions (void) struct cgraph_node *node = cgraph_node::get (current_function_decl); if (flags_from_decl_or_type (current_function_decl) - & (ECF_NORETURN|ECF_MALLOC)) + & (ECF_NORETURN|ECF_MALLOC|ECF_RETURNS_TWICE)) { if (dump_file) - fprintf (dump_file, "Not splitting: noreturn/malloc function.\n"); + fprintf (dump_file, "Not splitting: noreturn/malloc/returns_twice " + "function.\n"); return 0; } if (MAIN_NAME_P (DECL_NAME (current_function_decl))) diff --git a/gcc/testsuite/gcc.dg/pr106923.c b/gcc/testsuite/gcc.dg/pr106923.c new file mode 100644 index 00000000000..1c89f418810 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr106923.c @@ -0,0 +1,23 @@ +/* PR tree-optimization/106923 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -finline-small-functions -fpartial-inlining --param max-inline-insns-single=1 --param uninlined-function-insns=10000" } */ + +int n; + +int +baz (void); + +__attribute__ ((returns_twice)) int +bar (void) +{ + if (baz ()) + ++n; + + return 0; +} + +int +foo (void) +{ + return bar (); +}