From patchwork Mon Feb 8 05:55:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 580160 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2CA5314076B for ; Mon, 8 Feb 2016 16:55:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xkdU6cVg; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=TALO8RjVN2S5q/frycd8UaC0DyN/q1qbk4x/C6TqMUmZdFdXVW dqk6JuKn8Tl83KW1d/7DSz158z4vNixrly2uM/jhRMzeIiEfgDwFhsBy2/jVD061 98PUMKJ01vh2amkk4TOwKp5t+09bWl7gxbMJ7wXbogkBRZuS+nS8z8NB0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=IcYltf1IZD2Ql9GY6i6hYBHJvSI=; b=xkdU6cVgR05k8CICFDC4 u2rHptJ9LjMNrs0WGeMs4PQx6CmpXxgNhFsS1C2F4MIotJ+O1aWTze/n2++OCCI5 AmGlMudmR/PEbbRlLt5q1Zrobgxkc5gCwAKLHsYTxuoh7pOSeMX0ZROBnrG0VczZ SrxtE/4gaXz2pln3Hrp/ux0= Received: (qmail 81054 invoked by alias); 8 Feb 2016 05:55:48 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 81044 invoked by uid 89); 8 Feb 2016 05:55:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=fnoinline, fno-inline, revise X-HELO: mail-pa0-f42.google.com Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 08 Feb 2016 05:55:46 +0000 Received: by mail-pa0-f42.google.com with SMTP id ho8so68337034pac.2 for ; Sun, 07 Feb 2016 21:55:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=Njfi+Oc0gjo8CXLxr52AjKMV88RknXTuOv2b1IrOTUo=; b=hzs8DMA3CbR0YMYDHLTchC9Z1LGeLD8LemumBbmkG9FdOHCfH5Uw3K9sjX+0xZ9nIA P2YYZbVDSdQsXNGmTjXZ6i+P2Nv7QVWf3LE11+UCV4w4ycTD6aldtHk2ECXpLE6JTcNE FZ6zyhe84PQXuLFkp8nqc09C3PF2qyUk/UL53ckFve0KE9Area18HuhtQsxlp9Rd5J7N bL96UhIR/u5cPGJovk4oo7v1NIdvGvevHZ/HlHCsPNEh1A77Cd0h07k2ICTp+XP5mPx3 4WGwD84/+Ex+Y20KaDtWuPxnd04r877BbON6HhrMcMp5X+KBaJMRCHEZVSyc/6p75tb3 s7LQ== X-Gm-Message-State: AG10YORo2t2wbupntbh02gPwjtVV5QwHf4Ln5mF5OrhzAyBbjtmg0t5YJwq8Glk/BZiWQw== X-Received: by 10.66.141.142 with SMTP id ro14mr39277779pab.112.1454910944491; Sun, 07 Feb 2016 21:55:44 -0800 (PST) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id x10sm40066911pas.37.2016.02.07.21.55.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Feb 2016 21:55:43 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 7229DEA0186; Mon, 8 Feb 2016 16:25:38 +1030 (ACDT) Date: Mon, 8 Feb 2016 16:25:38 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: Jan Hubicka , Eric Botcazou Subject: Correct c-torture stkalign test Message-ID: <20160208055538.GI22967@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes This test was added by git commit 7c5f55675 (svn 231569) Here's the log message from that commit: avoid alignment of static variables affecting stack's Function (or more narrow) scope static variables (as well as others not placed on the stack) should also not have any effect on the stack alignment. I noticed the issue first with Linux'es dynamic_pr_debug() construct using an 8-byte aligned sub-file-scope local variable. However, the test assumes that a local var will normally not be 64-bit aligned, causing it to fail on many targets. So the test needs to pass if the local var *is* normally 64-bit aligned. Done as follows. test2() is a duplicate of test() without the alignment on the static vars. Fails on x86_64 -m64 and -m32 if 7c5f55675 is reverted and passes now for powerpc64-linux. I expect sparc will pass too, so have reverted Eric's change. OK to apply? PR testsuite/68886 * gcc.c-torture/execute/stkalign.c: Revise test. diff --git a/gcc/testsuite/gcc.c-torture/execute/stkalign.c b/gcc/testsuite/gcc.c-torture/execute/stkalign.c index 2f8d041..e10a1d2 100644 --- a/gcc/testsuite/gcc.c-torture/execute/stkalign.c +++ b/gcc/testsuite/gcc.c-torture/execute/stkalign.c @@ -1,5 +1,6 @@ -/* { dg-xfail-run-if "invalid assumption" { sparc*-*-* && lp64 } "*" "" } */ /* { dg-options "-fno-inline" } */ +/* Check that stack alignment is not affected by variables not placed + on the stack. */ #include @@ -16,12 +17,28 @@ unsigned test(unsigned n, unsigned p) return n ? test(n - 1, x) : (x ^ p); } +unsigned test2(unsigned n, unsigned p) +{ + static struct { char c; } s; + unsigned x; + + assert(__alignof__(s) != ALIGNMENT); + asm ("" : "=g" (x), "+m" (s) : "0" (&x)); + + return n ? test2(n - 1, x) : (x ^ p); +} + int main (int argc, char *argv[] __attribute__((unused))) { - unsigned int x = test(argc, 0); + unsigned int x, y; + x = test(argc, 0); x |= test(argc + 1, 0); x |= test(argc + 2, 0); - return !(x & (ALIGNMENT - 1)); + y = test2(argc, 0); + y |= test2(argc + 1, 0); + y |= test2(argc + 2, 0); + + return (x & (ALIGNMENT - 1)) == 0 && (y & (ALIGNMENT - 1)) != 0 ? 1 : 0; }