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: 53778 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2727027wrn; Tue, 7 Feb 2023 00:42:51 -0800 (PST) X-Google-Smtp-Source: AK7set/nnDuy9lkWQqvMOHxaFJl7a+BR0RSrLUPRabHaKmaQ+2XP56d1IU+wrQ7fqXz06+hPdnJA X-Received: by 2002:a17:906:5202:b0:878:7530:5303 with SMTP id g2-20020a170906520200b0087875305303mr2634449ejm.5.1675759371291; Tue, 07 Feb 2023 00:42:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675759371; cv=none; d=google.com; s=arc-20160816; b=RkF8d1b3I10FkRZ+yMeMTXrJO8f7OgLoTWOJAfEmlJTslI76DvlKKc7j0vZ3urx6hy k/bMeaAHDlDMQX1XLtAf3baE6E8BOWOP9lT/Ik57kbkT6U2DZJlq1g9lAUT+tYf5jLcg QOa2VG/Y6ayiMAeUCr7aAFIENNcX0q00SsQJGZaWsyWmKVsERPpKEwfDH8pFJJkYzhjL 8NheS4DwhhgYefrZWKFbf6SGAxW5Kw7qifRcOFFgSWeZ6lhRTTZDJj8443VdxPhHNUBR P6azmMrPpZO9R8m66bbsNoR80+o2Ccy09J62cfHZdKXmwMODhMTGQLhsu2ujO22GNjH2 gc7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=mfGnGdVGQRAP/SMfPPkPla9J4hzSwu5IBIDVSXDefsk=; b=xNGP6Wm/gdGfyt7YrhEIK53xV8FFKUZCR8q0//6VVGTOg24vMvxny1ZOezszPlHQYn y/UZwZayi7vvId4gJvfMh+2v2wIs9Kpf9frYhZSb2+T9oVGUjM94G5zezVkcDaLeTi+n 0hya2Z05VmFRU+1rK9UvstulSD8TMVp99mO+C2JxnXCsJsuv8XDtQkWyUCEEg0aK6/V1 ZhslI1KuZGnH3Ju6XA5Sf6MaeYFHkDtlZ3LIs+cIR48zMj9mONls/b5HuX9kv3OBiRvk Y8o0/WKSrPYzG/SBgTWEklyTHQoOrr3MdKyTpsZJSpuKC5HdfYKf31dEuw+DTENYQZFx wIZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=l6IIFyf+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n15-20020a17090673cf00b0087bda761997si17331161ejl.496.2023.02.07.00.42.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Feb 2023 00:42:51 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=l6IIFyf+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4CCA13858C20 for ; Tue, 7 Feb 2023 08:42:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CCA13858C20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675759370; 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=l6IIFyf+lhwSSNmP9yIGloJjza63BjxrGpwuM8n40BU/BMWNWtZjJ8rB2eSGEJ7VE ezbjJ+nshKQvDGKpIMWO54dUwLlqQopiRKWuodjds5obUQdESrZJt6zAgvawd7LPsu s7WnC+czXANIfEnG+Hui+gF0mqBNY8EARPvcvSEA= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757161058846838956?= X-GMAIL-MSGID: =?utf-8?q?1757161058846838956?= 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 (); +}