From patchwork Thu Jul 17 00:39:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Weigand X-Patchwork-Id: 370924 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 0E1BE14009B for ; Thu, 17 Jul 2014 10:40:14 +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=tHQ7V9Wg31eA4RIP awk31a6FB4hFKJ3yhYFlqJv+aGMKLz8DS4jCAvxDzRntsgIBi8xWy+ifqxagG/bd lEFSBqxhsKa60KmXLNrMy7UnRSsRlwqogjXu/Gm/6zlQmIiJhUIrjGnfJPSwHbwS QTjAho+/kiFAepiBp/MIM/q/CeQ= 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=jLq+2RqB/BVRQ8UxzoZDB2 TVhl8=; b=k1XraPG+51mDlyrOF+dkEskHnLXKN2n4Z3XGg+gnPmjQ3YM+tDRoC0 1lcysz8byNvbGVKLcZMvgcolK6dGWUmqQNcoWK5xfh+zSPRRa2WtReEbftMWqD8p gwTsgla3u+UjabMZHUxdis45qDWS8qvraNyuXOKv1Ig7BkxcLC+WA= Received: (qmail 5471 invoked by alias); 17 Jul 2014 00:40:08 -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 5426 invoked by uid 89); 17 Jul 2014 00:40:07 -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:40:06 +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:40:03 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) 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:40:00 +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 1BCB92190041 for ; Thu, 17 Jul 2014 01:39:46 +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 s6H0e0Id23331000 for ; Thu, 17 Jul 2014 00:40:00 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 s6H0dxID024002 for ; Wed, 16 Jul 2014 18:39:59 -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 s6H0dwaA023988; Wed, 16 Jul 2014 18:39:58 -0600 Message-Id: <201407170039.s6H0dwaA023988@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 17 Jul 2014 02:39:58 +0200 Subject: [PATCH, rs6000, 4.8/4.9] Fix aggregate alignment ABI issue To: gcc-patches@gcc.gnu.org Date: Thu, 17 Jul 2014 02:39:58 +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-0000008BFBA0 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/msg00995.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.c (rs6000_function_arg_boundary): Issue -Wpsabi note when encountering a type where future GCC releases will apply different alignment requirements. gcc/testsuite/ChangeLog: * gcc.target/powerpc/ppc64-abi-warn-2.c: New test. 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 @@ -9180,14 +9180,51 @@ rs6000_function_arg_boundary (enum machi || (type && TREE_CODE (type) == VECTOR_TYPE && int_size_in_bytes (type) >= 16)) return 128; - else if (((TARGET_MACHO && rs6000_darwin64_abi) - || DEFAULT_ABI == ABI_ELFv2 - || (DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm)) - && mode == BLKmode - && type && TYPE_ALIGN (type) > 64) + + /* Aggregate types that need > 8 byte alignment are quadword-aligned + in the parameter area in the ELFv2 ABI, and in the AIX ABI unless + -mcompat-align-parm is used. */ + if (((DEFAULT_ABI == ABI_AIX && !rs6000_compat_align_parm) + || DEFAULT_ABI == ABI_ELFv2) + && type && TYPE_ALIGN (type) > 64) + { + /* "Aggregate" means any AGGREGATE_TYPE except for single-element + or homogeneous float/vector aggregates here. We already handled + vector aggregates above, but still need to check for float here. */ + bool aggregate_p = (AGGREGATE_TYPE_P (type) + && !SCALAR_FLOAT_MODE_P (elt_mode)); + + /* We used to check for BLKmode instead of the above aggregate type + check. Warn when this results in any difference to the ABI. */ + if (aggregate_p != (mode == BLKmode)) + { + static bool warned; + if (!warned && warn_psabi) + { + warned = true; + inform (input_location, + "the ABI of passing aggregates with %d-byte alignment" + " will change in a future GCC release", + (int) TYPE_ALIGN (type) / BITS_PER_UNIT); + } + } + + /* GCC 4.8/4.9 Note: To avoid any ABI change on a release branch, we + keep using the BLKmode check, but warn if there will be differences + in future GCC releases. */ + if (mode == BLKmode) + return 128; + } + + /* Similar for the Darwin64 ABI. Note that for historical reasons we + implement the "aggregate type" check as a BLKmode check here; this + means certain aggregate types are in fact not aligned. */ + if (TARGET_MACHO && rs6000_darwin64_abi + && mode == BLKmode + && type && TYPE_ALIGN (type) > 64) return 128; - else - return PARM_BOUNDARY; + + return PARM_BOUNDARY; } /* The offset in words to the start of the parameter save area. */ Index: gcc-4_9-branch/gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-2.c =================================================================== --- /dev/null +++ gcc-4_9-branch/gcc/testsuite/gcc.target/powerpc/ppc64-abi-warn-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile { target { powerpc*-*-linux* && lp64 } } } */ + +struct test + { + long a __attribute__((aligned (16))); + }; + +void test (struct test a) /* { dg-message "note: the ABI of passing aggregates with 16-byte alignment will change" } */ +{ +} +