From patchwork Tue Feb 7 08:42:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 64435 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 402DA3858C33 for ; Tue, 7 Feb 2023 08:42:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 402DA3858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675759355; bh=mfGnGdVGQRAP/SMfPPkPla9J4hzSwu5IBIDVSXDefsk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=ibyDMf2FV7PTalYnwhdkOOhhLYW0tNKzhgQVOhvbuRiVGenrxivaVW04urLA1k/ar jYL6ZJDr5GOoxYz6nKM8Eayf7Fk0Yyi04P/RWAVuMWSKd0Yb/uNnLY43pJcPtRzvb4 mvSgkO7e+GqDpJtttfq+ymS7Fz+LpEm1rZCWA8Hc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B65753858C27 for ; Tue, 7 Feb 2023 08:42:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B65753858C27 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-YkfoekG3PwaugIDrKpD4BQ-1; Tue, 07 Feb 2023 03:42:05 -0500 X-MC-Unique: YkfoekG3PwaugIDrKpD4BQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADCA7858F09; Tue, 7 Feb 2023 08:42:04 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6ADF72166B29; Tue, 7 Feb 2023 08:42:04 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3178g1pC957520 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 7 Feb 2023 09:42:01 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3178g0V1957519; Tue, 7 Feb 2023 09:42:00 +0100 Date: Tue, 7 Feb 2023 09:42:00 +0100 To: Jan Hubicka , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] ipa-split: Don't split returns_twice functions [PR106923] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 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. Jakub --- gcc/ipa-split.cc.jj 2023-01-02 09:32:22.492283737 +0100 +++ gcc/ipa-split.cc 2023-02-06 14:15:08.343271251 +0100 @@ -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))) --- gcc/testsuite/gcc.dg/pr106923.c.jj 2023-02-06 14:19:33.464449400 +0100 +++ gcc/testsuite/gcc.dg/pr106923.c 2023-02-06 14:18:25.498429162 +0100 @@ -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 (); +}