From patchwork Thu Jul 17 00:41:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 370929 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 A77FC14009B for ; Thu, 17 Jul 2014 10:41:56 +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:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=MRUPq0ocVwAuPEJF N/DRoTSkaMxyqXzzZt70cWSe40ISnzG9YYsIav+vR+LVkYYk1ONbRTbU5zSfj15o lbO+0bNeqni3Ru+nZzdwLOkLlxa9DoHPvJM15r1LNpHl0oxdwsDDf4YNiO3DTcMd +VZZ9a1i2C+drHzmhTo6AqCnQ0g= 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:mime-version:content-type :content-transfer-encoding; s=default; bh=yDMatGAkZICAJEqsv0bVw6 tvzUg=; b=B/IMGjE5/upTNRri/ObLb7aaDQc8AwQzjNsyJxMyUZonHEurvC+pz3 Nl8GCAcnxMzMaJdyiMQRP6z73Ua1w2yEb/GJYcdzfY+Lp63uEAAYjW7A53wBs6DD jrWJx+2d6o0+CcrfTls8PCOMxXZQKptPdiDDIWD659j/H2ntq18sA= Received: (qmail 10133 invoked by alias); 17 Jul 2014 00:41:50 -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 10120 invoked by uid 89); 17 Jul 2014 00:41:49 -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: e06smtp14.uk.ibm.com Received: from e06smtp14.uk.ibm.com (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 17 Jul 2014 00:41:47 +0000 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Jul 2014 01:41:44 +0100 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 17 Jul 2014 01:41:42 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8FDF21B08040 for ; Thu, 17 Jul 2014 01:42:22 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6H0ffIE30015740 for ; Thu, 17 Jul 2014 00:41:41 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 s6H0ffgC024919 for ; Wed, 16 Jul 2014 18:41:41 -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 s6H0fe1G024910; Wed, 16 Jul 2014 18:41:40 -0600 Message-Id: <201407170041.s6H0fe1G024910@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 17 Jul 2014 02:41:40 +0200 Subject: [PATCH, rs6000, 4.8/4.9] Fix alignment of non-Altivec vector struct fields To: gcc-patches@gcc.gnu.org Date: Thu, 17 Jul 2014 02:41:40 +0200 (CEST) From: "Ulrich Weigand" Cc: dje.gcc@gmail.com MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14071700-1948-0000-0000-0000008BFBEE Hello, this is the variant intended for the 4.8/4.9 branches of the patch: https://gcc.gnu.org/ml/gcc-patches/2014-07/msg01072.html As discussed, it does *not* actually change ABI, but only warn when encountering a situation where the ABI will change in a future GCC. (Avoiding the specific term "GCC 4.10" here since I'm not certain whether the next GCC release will in fact be called that ...) Tested on powerpc64-linux and powerpc64le-linux; also verified using the ABI compat suite (against an unpatched GCC) that this patch does not change the ABI. OK for 4.8/4.9 once the mainline patch is in? 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. Issue -Wpsabi warning if future GCC releases will use different field alignment rules for this type. * 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. * gcc.c-torture/execute/20050316-1.x: Add -Wno-psabi. * gcc.c-torture/execute/20050604-1.x: Add -Wno-psabi. * gcc.c-torture/execute/20050316-3.x: New file. Add -Wno-psabi. * gcc.c-torture/execute/pr23135.x: Likewise. Index: gcc-4_9-branch/gcc/config/rs6000/rs6000-protos.h =================================================================== --- gcc-4_9-branch.orig/gcc/config/rs6000/rs6000-protos.h +++ gcc-4_9-branch/gcc/config/rs6000/rs6000-protos.h @@ -155,6 +155,7 @@ extern void rs6000_split_logical (rtx [] #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-4_9-branch/gcc/config/rs6000/rs6000.c =================================================================== --- gcc-4_9-branch.orig/gcc/config/rs6000/rs6000.c +++ gcc-4_9-branch/gcc/config/rs6000/rs6000.c @@ -5871,6 +5871,34 @@ rs6000_data_alignment (tree type, unsign 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 will change in a future GCC release", + computed / BITS_PER_UNIT); + } + } + /* GCC 4.8/4.9 Note: To avoid any ABI change on a release branch, we + keep the special treatment of vector types, but warn if there will + be differences in future GCC releases. */ + return true; + } + + 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-4_9-branch/gcc/config/rs6000/sysv4.h =================================================================== --- gcc-4_9-branch.orig/gcc/config/rs6000/sysv4.h +++ gcc-4_9-branch/gcc/config/rs6000/sysv4.h @@ -292,7 +292,7 @@ do { \ /* 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-4_9-branch/gcc/config/rs6000/linux64.h =================================================================== --- gcc-4_9-branch.orig/gcc/config/rs6000/linux64.h +++ gcc-4_9-branch/gcc/config/rs6000/linux64.h @@ -246,7 +246,7 @@ extern int dot_symbols; /* 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-4_9-branch/gcc/config/rs6000/freebsd64.h =================================================================== --- gcc-4_9-branch.orig/gcc/config/rs6000/freebsd64.h +++ gcc-4_9-branch/gcc/config/rs6000/freebsd64.h @@ -367,7 +367,7 @@ extern int dot_symbols; /* 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-4_9-branch/gcc/testsuite/gcc.c-torture/execute/20050316-1.x =================================================================== --- gcc-4_9-branch.orig/gcc/testsuite/gcc.c-torture/execute/20050316-1.x +++ gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/20050316-1.x @@ -4,4 +4,5 @@ if { [check_effective_target_int16] } { return 1 } +set additional_flags "-Wno-psabi" return 0; Index: gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/20050316-3.x =================================================================== --- /dev/null +++ gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/20050316-3.x @@ -0,0 +1,2 @@ +set additional_flags "-Wno-psabi" +return 0 Index: gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/20050604-1.x =================================================================== --- gcc-4_9-branch.orig/gcc/testsuite/gcc.c-torture/execute/20050604-1.x +++ gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/20050604-1.x @@ -6,4 +6,5 @@ if { [istarget "i?86-*-*"] || [istarget set additional_flags "-mno-mmx" } +set additional_flags "-Wno-psabi" return 0 Index: gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/pr23135.x =================================================================== --- /dev/null +++ gcc-4_9-branch/gcc/testsuite/gcc.c-torture/execute/pr23135.x @@ -0,0 +1,2 @@ +set additional_flags "-Wno-psabi" +return 0 Index: gcc-4_9-branch/gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-3.c =================================================================== --- /dev/null +++ gcc-4_9-branch/gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-3.c @@ -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 will change" } */ +