From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [IPv6:2001:470:683e::1]) by sourceware.org (Postfix) with ESMTPS id 84A6D3858C54 for ; Wed, 24 May 2023 06:45:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84A6D3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1684910718; bh=/WaRlCkDPUd0sBeARuJaXWwbugVREQoocV9Dl9Vfp6U=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=D/DcjexVAniLwVCn0zPKC0Js60An8rIYvC1qCQg7alQADfk6tkssexvr2kbSmIevD 3TwMeOGedu7YUJaAizWBjKOraI1M+v/FeIOxU0pP0S3H3XyqDTygWd7PhQIgHA95sd VA0M7CSqBDRvVPNiDvHRlveV1I13nhcrsQ9iWh+Q= Received: from [IPv6:240e:358:1192:8100:dc73:854d:832e:5] (unknown [IPv6:240e:358:1192:8100:dc73:854d:832e:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 0969D660BA; Wed, 24 May 2023 02:45:15 -0400 (EDT) Message-ID: <2d33bf204b0d59f16df8714123ee812be5754617.camel@xry111.site> Subject: Re: [PATCH] LoongArch: Fix the problem of structure parameter passing in C++. This structure has empty structure members and less than three floating point members. From: Xi Ruoyao To: Lulu Cheng , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn Date: Wed, 24 May 2023 14:45:07 +0800 In-Reply-To: <20230524060407.19181-1-chenglulu@loongson.cn> References: <20230524060407.19181-1-chenglulu@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,LIKELY_SPAM_FROM,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 2023-05-24 at 14:04 +0800, Lulu Cheng wrote: > An empty struct type that is not non-trivial for the purposes of calls > will be treated as though it were the following C type: >=20 > struct { > =C2=A0 char c; > }; >=20 > Before this patch was added, a structure parameter containing an empty st= ructure and > less than three floating-point members was passed through one or two floa= ting-point > registers, while nested empty structures are ignored. Which did not confo= rm to the > calling convention. No, it's a deliberate decision I've made in https://gcc.gnu.org/r12-8294. And we already agreed "the ABI needs to be updated" when we applied r12-8294, but I've never improved my English skill to revise the ABI myself :(. We are also using the same "de-facto" ABI throwing away the empty struct for Clang++ (https://reviews.llvm.org/D132285). So we should update the spec here, instead of changing every implementation. The C++ standard treats the empty struct as size 1 for ensuring the semantics of pointer comparison operations. When we pass it through the registers, there is no need to really consider the empty field because there is no pointers to registers. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University