From patchwork Thu Sep 5 15:44:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 97183 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 CF5BE384AB61 for ; Thu, 5 Sep 2024 15:45:32 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2062c.outbound.protection.outlook.com [IPv6:2a01:111:f403:260c::62c]) by sourceware.org (Postfix) with ESMTPS id 63F9C386546B for ; Thu, 5 Sep 2024 15:45:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 63F9C386546B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 63F9C386546B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:260c::62c ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1725551103; cv=pass; b=f04b34xYxzLqAEfnCAOEkz4u3rbcNkh0fo4V4b6QW4/rw5/rdEadSBOnqYE6uzDgHhbFZxXC8kEogBDnnTJc8114sibgNizU+JO54bzQeNq0uSNHDow9b14Ui00bTHR+D9v7OT9BV7l2H4UOo8DiRtV/ipuk2oGW0jC/IF+bD6Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1725551103; c=relaxed/simple; bh=8qGVtkpos+oxIrukAgg5947k+NfRJchBhq75FySSMqc=; h=DKIM-Signature:From:To:Subject:MIME-Version:Message-ID:Date; b=u911Obo0m8xNvVSUaH5ZVQVjsxi36AeWytkxfiW2s6NVDVOcVr6S/G4YnaacfM34g88yNmQu5cVJ+qhNa7xg2BU+tRuQ84/aaEUOVprdD3olrfYgQbza+3jxbtMNqldD9vHCU4oQzG7KV/E8LBG6zFuFZzSjvFhHVSRG6lAsgGU= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lf4Xa3u/KQWU/iaZpPdtLbsvOhepXjS/G8jK0yUhuHWA/4GB9ERTCujevfECNWUoWGWMBKCZ6UJVHNkbgh2qBG3iV47N+v62lvCk099VjEGOSzD2I18NrSf3eHRhwJ5ptCFwY9vACSqzq7ILWhafkmnAEij0avQqoFpDEBJKMpy1z5TO3D8hw38y9/Jc+MvI3Nlduhs4w9kGGna04Xp/R3l6Cj/eGF4/+kDVimUVxN1Sv+tseUxHIIdBUSpjcvsOimG5V+bWIpMt8akmhsCRQgim4P8oAJmRsldzcMMKX9+Dhq8r99zN/Jwexsc4cAoXnJpHsuWrbPni45nus4RaLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Xbt5GGPHyhiC3XnrhpLbp35KcPbhW3K72C7JHawKQOo=; b=JikbHcwqLSZSkvOLNq6IhZAQg0dmil/0rkji0nvpxbMJGV7pTyI6E222OQW6nnI8ueX9L/Sx8gnIpS8TGxmZXJZYH+YTLx4z6lVFdYiVMJbnM8rzFnVxUGuJK0p1hf0IZhA+18E6Ca4D/3P9kdVkz/WINuYuoUwiXvOswP3VgPEWV7VAaQC/a7woCsqoP2vkXCB2+gUkntEKmz3sjpcyjzz7gzdEEmRO0A6hB1xb8eNTSGHPcro6Gnd7h6b4N8KCPqKfuSzy5euN9rXx25SFE/yC/LLwzx/kYG93YKPiTAa+oiZ+y2XXn5upyHbeHJGgK2tGTYTX7i0oVr9zK2DpoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xbt5GGPHyhiC3XnrhpLbp35KcPbhW3K72C7JHawKQOo=; b=BphRdc36n8qayexngBnrKYsLuVSkMeRfYEw+G1X+ccUZJX/206ZY7TzX4lLyVO6yFqHcWODLh9VztdiG5qAER1M4L1c3VD+w2ffwjXuzznJYfVWWVRwu6iJJPrSH7CZkiARkoBpMOlduzotCLufEyLEUofU58tsSZpWasvaXdMc= Received: from AS4P195CA0018.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:5d6::15) by AS2PR02MB9739.eurprd02.prod.outlook.com (2603:10a6:20b:60d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.26; Thu, 5 Sep 2024 15:44:54 +0000 Received: from AM4PEPF00025F99.EURPRD83.prod.outlook.com (2603:10a6:20b:5d6:cafe::73) by AS4P195CA0018.outlook.office365.com (2603:10a6:20b:5d6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.14 via Frontend Transport; Thu, 5 Sep 2024 15:44:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=axis.com; Received-SPF: Pass (protection.outlook.com: domain of axis.com designates 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; pr=C Received: from mail.axis.com (195.60.68.100) by AM4PEPF00025F99.mail.protection.outlook.com (10.167.16.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7962.2 via Frontend Transport; Thu, 5 Sep 2024 15:44:53 +0000 Received: from SE-MAIL21W.axis.com (10.20.40.16) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Sep 2024 17:44:52 +0200 Received: from se-mail01w.axis.com (10.20.40.7) by SE-MAIL21W.axis.com (10.20.40.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Thu, 5 Sep 2024 17:44:52 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Thu, 5 Sep 2024 17:44:52 +0200 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id A40C6242; Thu, 5 Sep 2024 17:44:52 +0200 (CEST) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 9B4052044A; Thu, 5 Sep 2024 17:44:52 +0200 (CEST) From: Hans-Peter Nilsson To: Subject: [PATCH] testsuite/gcc.dg/pr84877.c: Add machinery to stabilize stack aligmnent MIME-Version: 1.0 Message-ID: <20240905154452.9B4052044A@pchp3.se.axis.com> Date: Thu, 5 Sep 2024 17:44:52 +0200 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00025F99:EE_|AS2PR02MB9739:EE_ X-MS-Office365-Filtering-Correlation-Id: 5dd5580d-0200-4956-b19a-08dccdc1af3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?q?ZhzZEkurtirl+Jmzj4jd/x+Sfv?= =?iso-8859-1?q?xMAl6yx4KSwNkPOFzvLc4/k2DlnZmbGXrISzeVCzv4iXDFoNjMC1/xZ4Ytmv?= =?iso-8859-1?q?m6633RXvWT9PsrIoZCmRWM7C/PgEDx/2dZlIBTVv6vbu6yTQeXrsOwnMmzA7?= =?iso-8859-1?q?3pA4zD+Mt8YBVKoKpl55+pD4XhbsY1lhSku9TjINqDPpG0kNRLJmxklhYr0C?= =?iso-8859-1?q?jz2tIpAXoZe55R+WNZsyrH9xeL4W7LWWGQvy93OPc3QqdvxliRKviyQYM3sj?= =?iso-8859-1?q?vJSNpWBl0CGb4IQSaq5XqRvN/pcoS0sCzRolPyaNnUSGa6ld/snjHZxYI+z6?= =?iso-8859-1?q?t/7WlNeI13lj2hqwfrS+WmAbICqT4BIxXZgT3QKfKnjK8qgaetWoAMyolJIf?= =?iso-8859-1?q?wCooyjFv1zKO/YMjh97gXevh9nuPYd9yKZXYuYE5uIRywJGoffCHTXam4AX5?= =?iso-8859-1?q?uzhcJ0dfpVRKuOLu81UnrNdsM+/Ys5/5uho61HXVkKG+wJhb9ufZx4sVhIPt?= =?iso-8859-1?q?VxclJwxXP60BOfHsniUpq5tkkbRJUCVKEirGyx0YAtrLv21znpvcKDHQ576i?= =?iso-8859-1?q?fcuNxfUm04IQXnd9ai45GkmCQnAHicd8czfSqP/kLSV1X1UKUMM1v8tsjSuM?= =?iso-8859-1?q?3ijXvUWcgFvGjYlVgoKaTPaVg7GPg7hZD/LSmhZs8UXFy+7auAxf4iT0+Nen?= =?iso-8859-1?q?q1070NBMaL0sc7XFkkEEtmKfF75k+lj3XVW6D5yc2vHNaOsDdkt6GBEXTwGL?= =?iso-8859-1?q?QrMYqQexZCTmeE4VTSGypvFjD7Z+10jAjUZUmEGJS0wehnPn1YWs6yK5BlSD?= =?iso-8859-1?q?dxIjAlEiBQtfIO7zQuzn5ZU5NjpUzdut1eoGEK1Zej5FYmmxKqOJ38LUyaiz?= =?iso-8859-1?q?RnWTVSojkuznXC+zpyWg+QJNSoSHg+It78TzB4NfYgOc0h5gK8ssT2sA+EKb?= =?iso-8859-1?q?HogC3yzYZpXSmxr6mN1jyDbEu1Q5fBeo2Q9vn405G5EqWsibmMOmNRQkw9xd?= =?iso-8859-1?q?vuhCk/U3HGb4pboahcuY+4q+CbbPml0ijB7wugBZpQ9d7NArfeV0ZqSlHI+B?= =?iso-8859-1?q?HO+x6JSWPBpxkBTkE68okhlkaJJXTKDywWAa7Yuzp19dDGqALG/wfRwPE+kU?= =?iso-8859-1?q?S9ohdovH5O8qKTuk81c1Jw7eut9uLDRcT+0ZxSQ49/mS12rxoEXibqck9lf7?= =?iso-8859-1?q?a+nOdtHiluje2Ue4h3l9vPguXRzDfO/yT6t2IAIAHZ2Bv8DDKepE4JGJR95Q?= =?iso-8859-1?q?n8DCV5zklVUmjJys7TU06xWTtSYfsZKsKeBJei9hcfzF/qGbW+d0m7m+nebQ?= =?iso-8859-1?q?KJngpHRbd+1KdLaiBNHcpCoh7AoTlrJ9Ry93REExPZmT9ztbDDtTuHbu+g6i?= =?iso-8859-1?q?all/552Q552M42GuPwn0KjLYalpe9s6E5oQmd8ELqbVKQ4JhA6Fn9Lt6vIoY?= =?iso-8859-1?q?k8wjFA3xoJPJWY9i1RqT9OXQ=3D=3D?= X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2024 15:44:53.1868 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5dd5580d-0200-4956-b19a-08dccdc1af3f X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00025F99.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR02MB9739 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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~patchwork=sourceware.org@gcc.gnu.org Tested adding 0..more-than-four environment variables, running cris-sim+cris-elf. I also checked that foo stays the same generated code regardless of the new code: this is not obviously true as foo is "just" noinline, not __noipa__. Ok to commit? -- >8 -- This test awkwardly "blinks"; xfails and xpasses apparently randomly for cris-elf using the "gdb simulator". On inspection, I see that the stack address depends on the number of environment variables, deliberately passed to the simulator, each adding the size of a pointer. This test is IMHO important enough not to be just skipped just because it blinks (fixing the actual problem is a different task). I guess a random non-16 stack-alignment could happen for other targets as well, so let's try and add a generic machinery to "stabilize" the test as failing, by allocating a dynamic amount to make sure it's misaligned. The most target-dependent item here is an offset between the incoming stack-pointer value (within main in the added framework) and outgoing (within "xmain" as called from main when setting up the p0 parameter). I know there are other wonderful stack shapes, but such targets would fall under the "complicated situations"-label and are no worse off than before. * gcc.dg/pr84877.c: Try to make the test result consistent by misaligning the stack. --- gcc/testsuite/gcc.dg/pr84877.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gcc/testsuite/gcc.dg/pr84877.c b/gcc/testsuite/gcc.dg/pr84877.c index e82991f42dd4..2f2e29578df9 100644 --- a/gcc/testsuite/gcc.dg/pr84877.c +++ b/gcc/testsuite/gcc.dg/pr84877.c @@ -3,6 +3,32 @@ #include +#ifdef __CRIS__ +#define OUTGOING_SP_OFFSET (-sizeof (void *)) +/* Suggestion: append #elif defined(____) after this comment, + either defining OUTGOING_SP_OFFSET to whatever the pertinent amount is at -O2, + if that makes your target consistently fail this test, or define + DO_NOT_TAMPER for more complicated situations. Either way, compile with + -DDO_NO_TAMPER to avoid any meddling. */ +#endif + +#if defined (OUTGOING_SP_OFFSET) && !defined (DO_NOT_TAMPER) +extern int xmain () __attribute__ ((__noipa__)); +int main () +{ + uintptr_t misalignment + = (OUTGOING_SP_OFFSET + + (15 & (uintptr_t) __builtin_stack_address ())); + /* Allocate a minimal amount if the stack was accidentally aligned. */ + void *q = __builtin_alloca (misalignment == 0); + xmain (); + /* Fake use to avoid the "allocation" being optimized out. */ + asm volatile ("" : : "rm" (q)); + return 0; +} +#define main xmain +#endif + struct U { int M0; int M1;