From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 58598 invoked by alias); 22 Feb 2018 07:40:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 58585 invoked by uid 89); 22 Feb 2018 07:40:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 22 Feb 2018 07:40:28 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6E5E4AC76; Thu, 22 Feb 2018 07:40:26 +0000 (UTC) Date: Thu, 22 Feb 2018 07:40:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: <20180221223720.GT5867@tucnak> References: <20180221223720.GT5867@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] Fix TYPE_EMPTY_P handling - x86_64 ABI issue (PR target/84502) To: Jakub Jelinek ,Jeff Law ,Jason Merrill ,Marek Polacek CC: gcc-patches@gcc.gnu.org From: Richard Biener Message-ID: <57834523-1F08-40A2-BC6E-CEFFF61BD527@suse.de> X-SW-Source: 2018-02/txt/msg01260.txt.bz2 On February 21, 2018 11:37:20 PM GMT+01:00, Jakub Jelinek wrote: >Hi! > >The following testcase shows that we set TYPE_EMPTY_P just one of the >possibly many variants of an aggregate type. >On the testcase, in one case (in the callee) we check TYPE_EMPTY_P on X >which is >the type variant for the using type, and in another case we check it on >the >A type instead, which has TYPE_EMPTY_P set. > >Bootstrap/regtest pending on x86_64-linux and i686-linux, ok if it >passes? OK.=20 Richard.=20 >2018-02-21 Jakub Jelinek > > PR target/84502 > * stor-layout.c (finalize_type_size): Propagate TYPE_EMPTY_P flag > to all type variants. > > * g++.dg/torture/pr84502.C: New test. > >--- gcc/stor-layout.c.jj 2018-02-13 21:23:29.187981310 +0100 >+++ gcc/stor-layout.c 2018-02-21 21:43:24.783522853 +0100 >@@ -1883,6 +1883,9 @@ finalize_type_size (tree type) > && TREE_CODE (TYPE_SIZE_UNIT (type)) !=3D INTEGER_CST) > TYPE_SIZE_UNIT (type) =3D variable_size (TYPE_SIZE_UNIT (type)); >=20 >+ /* Handle empty records as per the x86-64 psABI. */ >+ TYPE_EMPTY_P (type) =3D targetm.calls.empty_record_p (type); >+ > /* Also layout any other variants of the type. */ > if (TYPE_NEXT_VARIANT (type) > || type !=3D TYPE_MAIN_VARIANT (type)) >@@ -1895,6 +1898,7 @@ finalize_type_size (tree type) > unsigned int precision =3D TYPE_PRECISION (type); > unsigned int user_align =3D TYPE_USER_ALIGN (type); > machine_mode mode =3D TYPE_MODE (type); >+ bool empty_p =3D TYPE_EMPTY_P (type); >=20 > /* Copy it into all variants. */ > for (variant =3D TYPE_MAIN_VARIANT (type); >@@ -1911,11 +1915,9 @@ finalize_type_size (tree type) > SET_TYPE_ALIGN (variant, valign); > TYPE_PRECISION (variant) =3D precision; > SET_TYPE_MODE (variant, mode); >+ TYPE_EMPTY_P (variant) =3D empty_p; > } > } >- >- /* Handle empty records as per the x86-64 psABI. */ >- TYPE_EMPTY_P (type) =3D targetm.calls.empty_record_p (type); > } >=20 >/* Return a new underlying object for a bitfield started with FIELD.=20 >*/ >--- gcc/testsuite/g++.dg/torture/pr84502.C.jj 2018-02-21 >22:13:22.279420017 +0100 >+++ gcc/testsuite/g++.dg/torture/pr84502.C 2018-02-21 >22:13:03.727424362 +0100 >@@ -0,0 +1,20 @@ >+// PR target/84502 >+// { dg-do run } >+ >+template >+struct A { }; >+using X =3D A; >+ >+void >+foo (X, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int >a8) >+{ >+ if (a1 !=3D 0 || a2 !=3D 1 || a3 !=3D 2 || a4 !=3D 3 >+ || a5 !=3D 4 || a6 !=3D 5 || a7 !=3D 6 || a8 !=3D 7) >+ __builtin_abort (); >+} >+ >+int >+main () >+{ >+ foo (X{}, 0, 1, 2, 3, 4, 5, 6, 7); >+} > > Jakub