From patchwork Mon Jul 29 18:11:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 1966183 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=ENKEsc7O; 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 4WXmfQ49nhz1ybX for ; Tue, 30 Jul 2024 04:12:14 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 24E1B3858408 for ; Mon, 29 Jul 2024 18:12:12 +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.13]) by sourceware.org (Postfix) with ESMTPS id 99ECC3858C3A; Mon, 29 Jul 2024 18:11:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99ECC3858C3A 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 99ECC3858C3A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722276711; cv=none; b=XMVtt0IjQOvPERkCnIujUON9YdjOwXtGSmE9vq0UMVP0q2kMqOZ2lS7/jhzS/xwh/3xAffqgdupug1WWoKMX18Rz8z/y3o7tM4nnCDkj54DoEmQg/Br+E60AVSup1n6L4Jt329IW3nUpuuvq1Rj9LP9RARsly2jYDMsBWiIO65U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722276711; c=relaxed/simple; bh=+Xrki3t5Kjtrbsgp527KXq0s8G4g8llQOGwl7ufzxlM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=NRbzcQ9aIBUOhTcVoVIsBtBrL/WupwhNbkjEKHwsNgPlcJxxJyoHOjGaRF0KFqR5WLdqb1ObB0rRrucyXP+diT+F/NlhMq4yNY2LZgjZ6hqQiLhUrhzM8zvW5ClXuljY9LbxJCU1Z42bUUICOap7ZrdbDkDAIfX7WgufaWqlurM= 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=1722276709; x=1753812709; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=+Xrki3t5Kjtrbsgp527KXq0s8G4g8llQOGwl7ufzxlM=; b=ENKEsc7ObBBJEN4SN97EXA6lrK0nzvceFE2wVwSC6J47mKndjBvBgYyC v3FHJAAnrhdVdWF3PIUYwsbsdwL1rFRreg8HlhKgJD0hwbP43jAEt6ZcN yt61J42/Bl49rfsJ3X/qU967B8rfP5QLGQzizybnQowwbz/RYqiES5iDg BSO5wQsF2qm3/dfpZdyk9b4dMQjchVPiPQB6FtR+zvXDwaN93PFAlWm9h u1BsjZBYQrqNi4O232pUMDNndJVEZ5gy2vSg3jZdJiGEXpD1WAxQLwF6J ScmjrcHCp7QKgNRLjkTVAyZ6qp6qxxrppgpPZ5O1OwZHiB51tI2JV12V3 Q==; X-CSE-ConnectionGUID: LwvfpepLSlqjUS7fYODpjQ== X-CSE-MsgGUID: o4W4q2ISQb6wB7YYfo4riw== X-IronPort-AV: E=McAfee;i="6700,10204,11148"; a="22959844" X-IronPort-AV: E=Sophos;i="6.09,246,1716274800"; d="scan'208";a="22959844" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 11:11:47 -0700 X-CSE-ConnectionGUID: KZLN3szpQ1aKUJkSyzn+Og== X-CSE-MsgGUID: oUCUs+uEQ+idfPnDIjv8JA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,246,1716274800"; d="scan'208";a="53958852" Received: from tassilo.jf.intel.com ([10.54.38.190]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2024 11:11:47 -0700 From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH] PR116080: Fix test suite checks for musttail Date: Mon, 29 Jul 2024 11:11:42 -0700 Message-ID: <20240729181142.1618467-1-ak@linux.intel.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 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 This is a new attempt to fix PR116080. The previous try was reverted because it just broke a bunch of tests, hiding the problem. - musttail behaves differently than tailcall at -O0. Some of the test run at -O0, so add separate effective target tests for musttail. - New effective target tests need to use unique file names to make dejagnu caching work - Change the tests to use new targets - Add a external_musttail test to check for target's ability to do tail calls between translation units. This covers some powerpc ABIs. gcc/testsuite/ChangeLog: PR testsuite/116080 * c-c++-common/musttail1.c: Use musttail target. * c-c++-common/musttail12.c: Use struct_musttail target. * c-c++-common/musttail2.c: Use musttail target. * c-c++-common/musttail3.c: Likewise. * c-c++-common/musttail4.c: Likewise. * c-c++-common/musttail7.c: Likewise. * c-c++-common/musttail8.c: Likewise. * g++.dg/musttail10.C: Likewise. Replace powerpc checks with external_musttail. * g++.dg/musttail11.C: Use musttail target. * g++.dg/musttail6.C: Use musttail target. Replace powerpc checks with external_musttail. * g++.dg/musttail9.C: Use musttail target. * lib/target-supports.exp: Add musttail, struct_musttail, external_musttail targets. Remove optimization for musttail. Use unique file names for musttail. --- gcc/testsuite/c-c++-common/musttail1.c | 2 +- gcc/testsuite/c-c++-common/musttail12.c | 2 +- gcc/testsuite/c-c++-common/musttail2.c | 2 +- gcc/testsuite/c-c++-common/musttail3.c | 2 +- gcc/testsuite/c-c++-common/musttail4.c | 2 +- gcc/testsuite/c-c++-common/musttail7.c | 2 +- gcc/testsuite/c-c++-common/musttail8.c | 2 +- gcc/testsuite/g++.dg/musttail10.C | 4 ++-- gcc/testsuite/g++.dg/musttail11.C | 2 +- gcc/testsuite/g++.dg/musttail6.C | 4 ++-- gcc/testsuite/g++.dg/musttail9.C | 2 +- gcc/testsuite/lib/target-supports.exp | 30 ++++++++++++++++++++----- 12 files changed, 37 insertions(+), 19 deletions(-) diff --git a/gcc/testsuite/c-c++-common/musttail1.c b/gcc/testsuite/c-c++-common/musttail1.c index 74efcc2a0bc6..51549672e02a 100644 --- a/gcc/testsuite/c-c++-common/musttail1.c +++ b/gcc/testsuite/c-c++-common/musttail1.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { musttail && { c || c++11 } } } } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ int __attribute__((noinline,noclone,noipa)) diff --git a/gcc/testsuite/c-c++-common/musttail12.c b/gcc/testsuite/c-c++-common/musttail12.c index 4140bcd00950..475afc5af3f3 100644 --- a/gcc/testsuite/c-c++-common/musttail12.c +++ b/gcc/testsuite/c-c++-common/musttail12.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { struct_tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { struct_musttail && { c || c++11 } } } } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ struct str diff --git a/gcc/testsuite/c-c++-common/musttail2.c b/gcc/testsuite/c-c++-common/musttail2.c index 86f2c3d77404..1970c4edd670 100644 --- a/gcc/testsuite/c-c++-common/musttail2.c +++ b/gcc/testsuite/c-c++-common/musttail2.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { musttail && { c || c++11 } } } } */ struct box { char field[256]; int i; }; diff --git a/gcc/testsuite/c-c++-common/musttail3.c b/gcc/testsuite/c-c++-common/musttail3.c index ea9589c59ef2..7499fd6460b4 100644 --- a/gcc/testsuite/c-c++-common/musttail3.c +++ b/gcc/testsuite/c-c++-common/musttail3.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { struct_musttail && { c || c++11 } } } } */ extern int foo2 (int x, ...); diff --git a/gcc/testsuite/c-c++-common/musttail4.c b/gcc/testsuite/c-c++-common/musttail4.c index 23f4b5e1cd68..bd6effa4b931 100644 --- a/gcc/testsuite/c-c++-common/musttail4.c +++ b/gcc/testsuite/c-c++-common/musttail4.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { musttail && { c || c++11 } } } } */ struct box { char field[64]; int i; }; diff --git a/gcc/testsuite/c-c++-common/musttail7.c b/gcc/testsuite/c-c++-common/musttail7.c index c753a3fe9b2a..d17cb71256d7 100644 --- a/gcc/testsuite/c-c++-common/musttail7.c +++ b/gcc/testsuite/c-c++-common/musttail7.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { musttail && { c || c++11 } } } } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ void __attribute__((noipa)) f() {} diff --git a/gcc/testsuite/c-c++-common/musttail8.c b/gcc/testsuite/c-c++-common/musttail8.c index 9fa10e0b54c4..50ca1ac0dd48 100644 --- a/gcc/testsuite/c-c++-common/musttail8.c +++ b/gcc/testsuite/c-c++-common/musttail8.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call && { c || c++11 } } } } */ +/* { dg-do compile { target { musttail && { c || c++11 } } } } */ float f1(void); diff --git a/gcc/testsuite/g++.dg/musttail10.C b/gcc/testsuite/g++.dg/musttail10.C index ff7fcc7d8755..49430b1263a5 100644 --- a/gcc/testsuite/g++.dg/musttail10.C +++ b/gcc/testsuite/g++.dg/musttail10.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call } } } */ +/* { dg-do compile { target { musttail } } } */ /* { dg-options "-std=gnu++11" } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ @@ -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_musttail } } } */ template __attribute__((noinline, noclone, noipa)) diff --git a/gcc/testsuite/g++.dg/musttail11.C b/gcc/testsuite/g++.dg/musttail11.C index 1779e3287a93..dca87247d504 100644 --- a/gcc/testsuite/g++.dg/musttail11.C +++ b/gcc/testsuite/g++.dg/musttail11.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call } } } */ +/* { dg-do compile { target { musttail } } } */ /* { dg-options "-std=gnu++11" } */ /* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */ diff --git a/gcc/testsuite/g++.dg/musttail6.C b/gcc/testsuite/g++.dg/musttail6.C index 5c6f69407ddb..5dcf302139ae 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-do compile { target { struct_musttail } } } */ +/* { dg-require-effective-target external_musttail } */ /* 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/g++.dg/musttail9.C b/gcc/testsuite/g++.dg/musttail9.C index fb0262e751be..85937dcdcd31 100644 --- a/gcc/testsuite/g++.dg/musttail9.C +++ b/gcc/testsuite/g++.dg/musttail9.C @@ -1,4 +1,4 @@ -/* { dg-do compile { target { tail_call } } } */ +/* { dg-do compile { target { musttail } } } */ /* { 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..10b2969f747a 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -12744,16 +12744,34 @@ proc check_effective_target_tail_call { } { } {-O2 -fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. } -# Return 1 if the target can perform tail-call optimizations for structures +# Return 1 if the target can perform musttail optimizations of the +# most trivial type. This is separate from tail_call because musttail +# is supported at -O0. +proc check_effective_target_musttail { } { + return [check_no_messages_and_pattern musttail ",SIBCALL" rtl-expand { + __attribute__((__noipa__)) void foo (void) { } + __attribute__((__noipa__)) void bar (void) { [[gnu::musttail]] return foo(); } + } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. +} + +# Return 1 if the target can perform musttail for externals +proc check_effective_target_external_musttail { } { + return [check_no_messages_and_pattern external_musttail ",SIBCALL" rtl-expand { + extern __attribute__((__noipa__)) void foo (void); + __attribute__((__noipa__)) void bar (void) { [[gnu::musttail]] return foo(); } + } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. +} + +# Return 1 if the target can perform musttail optimizations for structures # checking with C++ because the C++ compiler has less tail call ability # due to PR115606 on some targets -proc check_effective_target_struct_tail_call { } { - return [check_no_messages_and_pattern tail_call ",SIBCALL" rtl-expand { +proc check_effective_target_struct_musttail { } { + return [check_no_messages_and_pattern struct_musttail ",SIBCALL" rtl-expand { // C++ struct foo { int a, b; }; - __attribute__((__noipa__)) struct foo foo (void) { return {}; } - __attribute__((__noipa__)) struct foo bar (void) { return foo(); } - } {-O2 -fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. + extern __attribute__((__noipa__)) struct foo foo (void); + __attribute__((__noipa__)) struct foo bar (void) { [[gnu::musttail]] return foo(); } + } {-fdump-rtl-expand-all}] ;# The "SIBCALL" note requires a detailed dump. } # Return 1 if the target's calling sequence or its ABI