From patchwork Thu Jul 25 22:55:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1964929 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=Zf8H6hLX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4WVR7D3WpQz1yY9 for ; Fri, 26 Jul 2024 08:55:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4DFF2385840E for ; Thu, 25 Jul 2024 22:55:33 +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 [198.175.65.15]) by sourceware.org (Postfix) with ESMTPS id 53A113858C41; Thu, 25 Jul 2024 22:55:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53A113858C41 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 53A113858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721948110; cv=none; b=e6thTJkTEXHVFXdmO3xwj2Wh09icOZxHYQrR7UEceszTvuADOYyK/sZKe52jOq9X3hhXRVmILW7miuWirI2kEIohYcgmNlCUzRm+A1RlHWjKbanT54kd8cX9CpPaaWJtWr7CXysvVO7Inih2aG0l9YJ6B8rkcJ5E1ubX/R7gAIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721948110; c=relaxed/simple; bh=dmK6ay0dWT9+iA0/JyWMG/yXkdBV8cLbdLjcH2r2VSU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NZsoQAs/4EvjMTTQ4onqkJSn7oTD+ZA2lr8XoXJWhHyCJBEk1YI5MxjjqxUEutvGseM/02N7oxkp87S70z25b5ffjIaMzQstTFNd0KKFyngk8ig8cT7Kb/9leQA5qPGi7nJfjFeiIGgomoyecfTtKS5wBBLC1l4Q6Os+zxmnXfo= 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=1721948109; x=1753484109; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=dmK6ay0dWT9+iA0/JyWMG/yXkdBV8cLbdLjcH2r2VSU=; b=Zf8H6hLXNG1i6RA9SzhQFEEP6GwYsqeRls7MxKdVt1NwmDryqNP23qkF Kinp6yPOonmsmanuMihcZJhfZMJko8U/p4drWvxYajGHCdWGhU2qoGKH/ ArZBdkHKypo4jpUrVcmVOUCoSLjyNUQYX1qdRR9Hapsmyml6/P/pT7FN1 IEbDbh7wSBYJ8xWF+ysX2B1IZ+MQALAXnqK8Q3aiNf5Sf6Hsz4GeTncfo xF12sb81DYg8ewUraH+ZwgPBQeeZAhf/rIKKmP1EMraXoCaIcD6125qDt 5VWiboBSav4pX1JSF0cMnOgb5/FDRjBocvg18okoNguMMhEy9DO4YZbak A==; X-CSE-ConnectionGUID: it3pG2AdT7eiSaSmF5Yg7g== X-CSE-MsgGUID: NT3n2K9HQA2ku9rYmWjfVw== X-IronPort-AV: E=McAfee;i="6700,10204,11144"; a="23476149" X-IronPort-AV: E=Sophos;i="6.09,237,1716274800"; d="scan'208";a="23476149" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2024 15:55:08 -0700 X-CSE-ConnectionGUID: wi46sfHcRo25LXCmQQj/Jg== X-CSE-MsgGUID: b3tB3odWRgW8HOvwpynyjA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,237,1716274800"; d="scan'208";a="57875791" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2024 15:55:08 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH v1 1/2] PR116080: Fix tail call dejagnu checks Date: Thu, 25 Jul 2024 15:55:01 -0700 Message-ID: <20240725225502.1550809-1-ak@linux.intel.com> X-Mailer: git-send-email 2.45.2 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 From: Andi Kleen - Run the target_effective tail_call checks without optimization to match the actual test cases. - Add an extra check for external tail calls to handle targets like powerpc that cannot tail call between different object files. This one will also cover templates. gcc/testsuite/ChangeLog: PR testsuite/116080 * g++.dg/musttail10.C: Use external tail call target check. * g++.dg/musttail6.C: Dito. * lib/target-supports.exp: Add external_tail_call. Disable optimization for tail call checks. --- gcc/testsuite/g++.dg/musttail10.C | 2 +- gcc/testsuite/g++.dg/musttail6.C | 2 +- gcc/testsuite/lib/target-supports.exp | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/g++.dg/musttail10.C b/gcc/testsuite/g++.dg/musttail10.C index ff7fcc7d8755..bd75affa2220 100644 --- a/gcc/testsuite/g++.dg/musttail10.C +++ b/gcc/testsuite/g++.dg/musttail10.C @@ -8,7 +8,7 @@ double g() { [[gnu::musttail]] return f(); } /* { dg-error "cannot tail-cal template __attribute__((noinline, noclone, noipa)) -T g1() { [[gnu::musttail]] return f(); } /* { dg-error "target is not able" "" { target powerpc*-*-* } } */ +T g1() { [[gnu::musttail]] return f(); } /* { dg-error "target is not able" "" { target { external_tail_call } } } */ template __attribute__((noinline, noclone, noipa)) diff --git a/gcc/testsuite/g++.dg/musttail6.C b/gcc/testsuite/g++.dg/musttail6.C index 5c6f69407ddb..81f6d9f3ca77 100644 --- a/gcc/testsuite/g++.dg/musttail6.C +++ b/gcc/testsuite/g++.dg/musttail6.C @@ -1,6 +1,6 @@ /* { dg-do compile { target { struct_tail_call } } } */ +/* { dg-require-effective-target external_tail_call } */ /* A lot of architectures will not build this due to PR115606 and PR115607 */ -/* { dg-skip-if "powerpc does not support sibcall to templates" { powerpc*-*-* } } */ /* { dg-options "-std=gnu++11" } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index d368251ef9a4..0a3946e82d4b 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -12741,7 +12741,15 @@ proc check_effective_target_tail_call { } { return [check_no_messages_and_pattern tail_call ",SIBCALL" rtl-expand { __attribute__((__noipa__)) void foo (void) { } __attribute__((__noipa__)) void bar (void) { foo(); } - } {-O2 -fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. + } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. +} + +# Return 1 if the target can perform tail-calls for externals +proc check_effective_target_external_tail_call { } { + return [check_no_messages_and_pattern tail_call ",SIBCALL" rtl-expand { + extern __attribute__((__noipa__)) void foo (void); + __attribute__((__noipa__)) void bar (void) { foo(); } + } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. } # Return 1 if the target can perform tail-call optimizations for structures @@ -12751,9 +12759,9 @@ proc check_effective_target_struct_tail_call { } { return [check_no_messages_and_pattern tail_call ",SIBCALL" rtl-expand { // C++ struct foo { int a, b; }; - __attribute__((__noipa__)) struct foo foo (void) { return {}; } + extern __attribute__((__noipa__)) struct foo foo (void); __attribute__((__noipa__)) struct foo bar (void) { return foo(); } - } {-O2 -fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. + } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. } # Return 1 if the target's calling sequence or its ABI From patchwork Thu Jul 25 22:55:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1964930 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=mGjjQQvg; 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 4WVR7G4W7sz1yY9 for ; Fri, 26 Jul 2024 08:55:38 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BBDED385C6C0 for ; Thu, 25 Jul 2024 22:55:36 +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 [198.175.65.15]) by sourceware.org (Postfix) with ESMTPS id CA6DA3858C31; Thu, 25 Jul 2024 22:55:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CA6DA3858C31 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 CA6DA3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.15 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721948115; cv=none; b=EWMggdQ08lp/cHSa8afuX91NBaXMq36vyJoJRK2bcNeGQ6hmGgPbyE9/hJWzFwh0oh5KtSs+t8nGkrpuwxsJ/Gu9FTye+4TRBorz2Ho0nCNbOAZg9z6jMLxXgI0J/uigXJAGukyH7VR7RbrUpHrCaV3s6Z48nkCsrGNx9Le4jeo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721948115; c=relaxed/simple; bh=jVCya8f6GdiAulAXoPVSdICZlYPkzwOiCZbdAuzC1Ik=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=T8IWYK6nWid+FPqsrjr8kt5noJPd9PnUdc8B1ixbI2RTxoz9PW2XKCM60PKmOMA8L//iZH/LdmAAiZ18hH23yJop3igfrwh4PMKySWuITb/K2lWplMy0PWQagfE48rvi/Z/8acCZ1AycTJOoOi5hArHsfgO5gwPsMUXcKASxatU= 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=1721948112; x=1753484112; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jVCya8f6GdiAulAXoPVSdICZlYPkzwOiCZbdAuzC1Ik=; b=mGjjQQvgmbarjFJPPDMU4pvIv9QQyaMmG5ICYDRg56u4nEzvwJysnwiT fdKtUN9F+Dqm3m6Oowrqz8KqLy6s4ABGgA4rQV8E3YdB+DlUDjvePmemN uyngWoe+VVXwzq4lPDfMYvJPkFn/BQDnv3Hq+z54BTrGHuMu3hx6VQq5c O+j6FVvaGiTuMy2son0XyYBLowGD/t5C2s4w3X8f0xAfgM+p+ii8U4zN2 CQvn3gPMdAjQxBNHBhEShc2dQpb2ufBFkJql2tBiV/tAYuKW11nx0B32L S2cH47PqrXvzk9PSEmczJQaXAEjMgrtqkeFVC+5Wg/3T+5oE4Q7PEBNjz A==; X-CSE-ConnectionGUID: KwQ40RmlRHqDvZLs0OexGQ== X-CSE-MsgGUID: UDs1AjrXQ5qHiak83ySCaQ== X-IronPort-AV: E=McAfee;i="6700,10204,11144"; a="23476150" X-IronPort-AV: E=Sophos;i="6.09,237,1716274800"; d="scan'208";a="23476150" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa107.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2024 15:55:08 -0700 X-CSE-ConnectionGUID: vggZOecdTAG4bz18eq011Q== X-CSE-MsgGUID: 4y/xDGITTtKwUOlYeUdNcA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,237,1716274800"; d="scan'208";a="57875792" Received: from tassilo.jf.intel.com ([10.54.38.190]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jul 2024 15:55:08 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH v1 2/2] PR116019: Improve tail call error message Date: Thu, 25 Jul 2024 15:55:02 -0700 Message-ID: <20240725225502.1550809-2-ak@linux.intel.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240725225502.1550809-1-ak@linux.intel.com> References: <20240725225502.1550809-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 From: Andi Kleen The "tail call must be the same type" message is common on some targets with C++, or without optimization. It is generated when gcc believes there is an access of the return value after the call. However usually it does not actually corespond to a type mismatch, but can be caused for other reasons. Make it slightly more vague to be less misleading. gcc/ChangeLog: PR c++/116019 * tree-tailcall.cc (find_tail_calls): Change tail call error message. --- gcc/tree-tailcall.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc index a68079d4f507..1901b1a13f99 100644 --- a/gcc/tree-tailcall.cc +++ b/gcc/tree-tailcall.cc @@ -632,7 +632,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret, bool only_musttail, && may_be_aliased (result_decl) && ref_maybe_used_by_stmt_p (call, result_decl, false)) { - maybe_error_musttail (call, _("tail call must be same type")); + maybe_error_musttail (call, _("return value used after call")); return; }