From patchwork Mon Jul 8 16:55:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1958052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=eZEEJe75; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WHr4N1lckz1xrP for ; Tue, 9 Jul 2024 03:01:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BBD93831E14 for ; Mon, 8 Jul 2024 17:01:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by sourceware.org (Postfix) with ESMTPS id A4BD8384CB94 for ; Mon, 8 Jul 2024 17:00:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4BD8384CB94 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=linux.intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A4BD8384CB94 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.11 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720458053; cv=none; b=CMfOrRQ6lTf12tGW/sTIeu13Mif0XblQaMelgbkOelozE22n5WPHKzNAALsL5F9RM7AwQ36DCwbCqLW67+cYqpSNju/L16b7E0/EYTdcdIYzsizEPD9uywbZw4HXioC+gDasWKJgpst6FUV2xtyma8u1lRlHwFvUfIN3n1xEYX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1720458053; c=relaxed/simple; bh=kZchPkuxr3JSRsRtOc6qRPj0Tj865h7sKEYPXan6Z5k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LXXCve9Kt/NqQt/InCZ5GuAbIVsxx7K46Tl0s9ttHTt+PSaw2CHKZaUlxnrpuc2Euyoru2Y5GtXnmQC4R5Kt9oIicoXcKpq1iz8Klxd5oUFcY4EH46Pvv43lwERVwYM2ilBHI3CSIrYnCdEAohZrbSKuyA46XXvT3FWOIbySH5U= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1720458052; x=1751994052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=kZchPkuxr3JSRsRtOc6qRPj0Tj865h7sKEYPXan6Z5k=; b=eZEEJe75yCF8eAUiIyvmEcjE59TOWSLUjIps0Rj8D5D7XmVuLmg18eGC zP0q8YolvEv0Q8E82YEvjMj/tmuARyk3iAFelbT88nGyT8rl5t6mLjdq0 6SKBdIhqXDB6Epp55cAdKeasQolWJA8mbNS4mxbFz39q99cuDtolrQj5g nuH7YYhjRwyHZNBb0RphrT7tcY2oFU7+yuifDvsJjfjECubenpQCagFLu yqyresqLAlw5VZE4Rkt3tectsNqmPVzVzk1ecwQrwhpsrFJPzgGVpyPij TKqF9rI4y6D55aQI74ZD52WOU+WR921vtC9v0K5cAbG3uNZEG2N4O/jNd Q==; X-CSE-ConnectionGUID: /+u94Y9YR2mpArBX3x+Udw== X-CSE-MsgGUID: uSJ0ETNpTnmhLg8filia3Q== X-IronPort-AV: E=McAfee;i="6700,10204,11127"; a="28279672" X-IronPort-AV: E=Sophos;i="6.09,192,1716274800"; d="scan'208";a="28279672" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2024 10:00:37 -0700 X-CSE-ConnectionGUID: q/4fcwflQtWXuiFrowuSqw== X-CSE-MsgGUID: 8SAm1xDZRMaKDCYuPUDtPA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,192,1716274800"; d="scan'208";a="47486294" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jul 2024 10:00:37 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: richard.guenther@gmail.com, josmyers@redhat.com, polacek@redhat.com, jakub@redhat.com, Andi Kleen Subject: [PATCH v9 02/10] Fix pro_and_epilogue for sibcalls at -O0 (PR115255) Date: Mon, 8 Jul 2024 09:55:54 -0700 Message-ID: <20240708170031.1621184-3-ak@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240708170031.1621184-1-ak@linux.intel.com> References: <20240708170031.1621184-1-ak@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Some of the cfg fixups in pro_and_epilogue for sibcalls were dependent on "optimize". Make them check cfun->tail_call_marked instead to handle the -O0 musttail case. This fixes the musttail test cases on arm targets. gcc/ChangeLog: PR target/115255 * function.cc (thread_prologue_and_epilogue_insns): Check cfun->tail_call_marked for sibcalls too. (rest_of_handle_thread_prologue_and_epilogue): Dito. --- gcc/function.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/function.cc b/gcc/function.cc index 4edd4da12474..a6f6de349420 100644 --- a/gcc/function.cc +++ b/gcc/function.cc @@ -2231,6 +2231,7 @@ use_register_for_decl (const_tree decl) /* We don't set DECL_IGNORED_P for the function_result_decl. */ if (optimize) return true; + /* Needed for [[musttail]] which can operate even at -O0 */ if (cfun->tail_call_marked) return true; /* We don't set DECL_REGISTER for the function_result_decl. */ @@ -6259,8 +6260,11 @@ thread_prologue_and_epilogue_insns (void) } /* Threading the prologue and epilogue changes the artificial refs in the - entry and exit blocks, and may invalidate DF info for tail calls. */ + entry and exit blocks, and may invalidate DF info for tail calls. + This is also needed for [[musttail]] conversion even when not + optimizing. */ if (optimize + || cfun->tail_call_marked || flag_optimize_sibling_calls || flag_ipa_icf_functions || in_lto_p) @@ -6557,7 +6561,7 @@ rest_of_handle_thread_prologue_and_epilogue (function *fun) { /* prepare_shrink_wrap is sensitive to the block structure of the control flow graph, so clean it up first. */ - if (optimize) + if (cfun->tail_call_marked || optimize) cleanup_cfg (0); /* On some machines, the prologue and epilogue code, or parts thereof,