From patchwork Mon Jul 14 19:01:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 369744 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 449C114011B for ; Tue, 15 Jul 2014 05:01:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:subject:to:date:from:cc:in-reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=MmN lDImrOOL6Uo2imj/mZBk5fj8EtyxETnaQcFlHqaNknUEOQkd/gvSm4s5eEOKR08Q I0SZpP7RlUgrldGdP+8jQEiaV06cA/hU7Ijw7U3hz6yYql/UCZR3GpYqMTz7Tuap 3wKLOjfK6muqHTaDSdc1+QY9Xgxc2kzoAOQmvPIY= 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 :message-id:subject:to:date:from:cc:in-reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=ajtpJlSal sVbus5U9rIS6PIzqTQ=; b=gvRkDChztletNcxW0Ah/XVUY+Z2ULMKQvSO1rTsJh Tp9D0Mf6XeAdqUfWI62EbCe10gbqekus+1ZKHUiicMZirnJV5MMd8rEEJjLSdYES bYvQkvRGSjh/Q/EnjWsSXn/30X9x6OtAYgbBqljX/mxUxN0juUCKMsF/2m3AiMeb VQ= Received: (qmail 18217 invoked by alias); 14 Jul 2014 19:01:41 -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 18069 invoked by uid 89); 14 Jul 2014 19:01:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, MSGID_FROM_MTA_HEADER, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: e06smtp15.uk.ibm.com Received: from e06smtp15.uk.ibm.com (HELO e06smtp15.uk.ibm.com) (195.75.94.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 14 Jul 2014 19:01:35 +0000 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Jul 2014 20:01:32 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 Jul 2014 20:01:29 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 0AB062190045 for ; Mon, 14 Jul 2014 20:01:15 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6EJ1Scf32112652 for ; Mon, 14 Jul 2014 19:01:28 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s6EJ1Squ016964 for ; Mon, 14 Jul 2014 13:01:28 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with SMTP id s6EJ1RpN016910; Mon, 14 Jul 2014 13:01:27 -0600 Message-Id: <201407141901.s6EJ1RpN016910@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Mon, 14 Jul 2014 21:01:27 +0200 Subject: Re: [RFC, rs6000, v2] Fix alignment of non-Altivec vector struct fields To: gcc-patches@gcc.gnu.org Date: Mon, 14 Jul 2014 21:01:27 +0200 (CEST) From: "Ulrich Weigand" Cc: dje.gcc@gmail.com In-Reply-To: <201407141855.s6EItihe011118@d06av02.portsmouth.uk.ibm.com> from "Ulrich Weigand" at Jul 14, 2014 08:55:44 PM MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14071419-0342-0000-0000-00000071742A [ Sorry, re-sending with fixed email address. ] Hello, this is an attempt to update the prior patch: https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00635.html to add a -Wpsabi note as discussed. However, this is causing a bit of difficulties. First of all, the warning triggers in a larger number of tests -- which was probably to be expected since a number of tests in the suite explicitly work on GCC vectors defined using various vector_size values, and any size except 16 will result in the warning. Note that the warning gets issued at the site of definition of the structure type -- it does not have to be used in a function call. More problematic is that this new warning causes four tests to fail (it's actually 38 new FAILS since each of the tests fails in multiple optimization levels): FAIL: gcc.c-torture/execute/20050316-1.c compilation gcc.c-torture/execute/20050316-1.c:53:9: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10 FAIL: gcc.c-torture/execute/20050316-3.c compilation gcc.c-torture/execute/20050316-3.c:26:9: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10 FAIL: gcc.c-torture/execute/20050604-1.c compilation gcc.c-torture/execute/20050604-1.c:12:1: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10 FAIL: gcc.c-torture/execute/pr23135.c compilation gcc.c-torture/execute/pr23135.c:20:1: note: the layout of aggregates containing vectors with 8-byte alignment has changed in GCC 4.10 Unfortunately, while most of the tests in the suite use the dg-test framework which ignores "note" messages, the gcc.c-torture/execute tests still use the old "torture" test framework, which does *not*. (Also, in the old framework you cannot even add dg-... commands to ignore those messages for a certain test, or add a -Wno-psabi option.) Therefore, I'm not proposing to commit this patch as-is, but would like to ask for feedback on how to best proceed with this. One option might be to move the affected tests to the dg-test framework. Or else we might decide we don't actually need a warning for this change, since it only affects GCC synthetic vectors, where we might not have made strict ABI guarantees anyway ... Thoughts? Bye, Ulrich gcc/ChangeLog: * config/rs6000/rs6000-protos.h (rs6000_special_adjust_field_align_p): Add prototype. * config/rs6000/rs6000.c (rs6000_special_adjust_field_align_p): New function. * config/rs6000/sysv4.h (ADJUST_FIELD_ALIGN): Call it. * config/rs6000/linux64.h (ADJUST_FIELD_ALIGN): Likewise. * config/rs6000/freebsd64.h (ADJUST_FIELD_ALIGN): Likewise. gcc/testsuite/ChangeLog: * gcc.target/powerpc/ppc64-abi-warn-3.c: New test. Index: gcc/config/rs6000/rs6000-protos.h =================================================================== --- gcc/config/rs6000/rs6000-protos.h (revision 212147) +++ gcc/config/rs6000/rs6000-protos.h (working copy) @@ -155,6 +155,7 @@ #ifdef TREE_CODE extern unsigned int rs6000_data_alignment (tree, unsigned int, enum data_align); +extern bool rs6000_special_adjust_field_align_p (tree, unsigned int); extern unsigned int rs6000_special_round_type_align (tree, unsigned int, unsigned int); extern unsigned int darwin_rs6000_special_round_type_align (tree, unsigned int, Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 212147) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -5878,6 +5878,32 @@ return align; } +/* Previous GCC releases forced all vector types to have 16-byte alignment. */ + +bool +rs6000_special_adjust_field_align_p (tree field, unsigned int computed) +{ + if (TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (field)) == VECTOR_TYPE) + { + if (computed != 128) + { + static bool warned; + if (!warned && warn_psabi) + { + warned = true; + inform (input_location, + "the layout of aggregates containing vectors with" + " %d-byte alignment has changed in GCC 4.10", + computed / BITS_PER_UNIT); + } + } + /* In current GCC there is no special case. */ + return false; + } + + return false; +} + /* AIX increases natural record alignment to doubleword if the first field is an FP double while the FP fields remain word aligned. */ Index: gcc/config/rs6000/sysv4.h =================================================================== --- gcc/config/rs6000/sysv4.h (revision 212147) +++ gcc/config/rs6000/sysv4.h (working copy) @@ -292,7 +292,7 @@ /* An expression for the alignment of a structure field FIELD if the alignment computed in the usual way is COMPUTED. */ #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ - ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \ + (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \ ? 128 : COMPUTED) #undef BIGGEST_FIELD_ALIGNMENT Index: gcc/config/rs6000/linux64.h =================================================================== --- gcc/config/rs6000/linux64.h (revision 212147) +++ gcc/config/rs6000/linux64.h (working copy) @@ -246,7 +246,7 @@ /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */ #undef ADJUST_FIELD_ALIGN #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ - ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \ + (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \ ? 128 \ : (TARGET_64BIT \ && TARGET_ALIGN_NATURAL == 0 \ Index: gcc/config/rs6000/freebsd64.h =================================================================== --- gcc/config/rs6000/freebsd64.h (revision 212147) +++ gcc/config/rs6000/freebsd64.h (working copy) @@ -367,7 +367,7 @@ /* PowerPC64 Linux word-aligns FP doubles when -malign-power is given. */ #undef ADJUST_FIELD_ALIGN #define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ - ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \ + (rs6000_special_adjust_field_align_p ((FIELD), (COMPUTED)) \ ? 128 \ : (TARGET_64BIT \ && TARGET_ALIGN_NATURAL == 0 \ Index: gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-3.c =================================================================== --- /dev/null +++ gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-3.c (revision 0) @@ -0,0 +1,9 @@ +/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */ +/* { dg-require-effective-target powerpc_altivec_ok } */ +/* { dg-options "-maltivec" } */ + +struct test + { + int a __attribute__((vector_size (8))); + }; /* { dg-message "note: the layout of aggregates containing vectors with 8-byte alignment has changed" } */ +