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 B3D063858CDB for ; Wed, 24 May 2023 08:41:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3D063858CDB 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=1684917687; bh=KgeSJusNY+GnggnnlYwYon0Fd52E99p1rrCSX4PA3BQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=H/iN1aWMv5bGp7D5t/ttbvUBEYYArnyh4nGycU14D11/FQLMolzF2mAIGHBf5VaEH cYHIVy6iSfTBLBpaiBtDPKO8mXaKhHSAr6h9CtF/8ur0WETxMoXQyWacP8T6iVMDXp dj3Rg1piymYq5qF+QqsD5k04W3DOL6+xcDsZdAO0= Received: from localhost.localdomain (xry111.site [IPv6:2001:470:683e::1]) (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 D185165A44; Wed, 24 May 2023 04:41:26 -0400 (EDT) Message-ID: <356c3dfd86b82689483fc96f97790909a2e57c47.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, Jonathan Wakely Cc: i@xen0n.name, xuchenghua@loongson.cn Date: Wed, 24 May 2023 16:41:25 +0800 In-Reply-To: <2d33bf204b0d59f16df8714123ee812be5754617.camel@xry111.site> References: <20230524060407.19181-1-chenglulu@loongson.cn> <2d33bf204b0d59f16df8714123ee812be5754617.camel@xry111.site> 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.9 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: Wang Lei raised some concerns about Itanium C++ ABI, so let's ask a C++ expert here... Jonathan: AFAIK the standard and the Itanium ABI treats an empty class as size 1 in order to guarantee unique address, so for the following: class Empty {}; class Test { Empty empty; double a, b; }; When we pass "Test" via registers, we may only allocate the registers for Test::a and Test::b, and complete ignore Test::empty because there is no addresses of registers. Is this correct or not? On Wed, 2023-05-24 at 14:45 +0800, Xi Ruoyao via Gcc-patches wrote: > 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 structure and > > less than three floating-point members was passed through one or two > > floating-point > > registers, while nested empty structures are ignored. Which did not > > conform to the > > calling convention. >=20 > No, it's a deliberate decision I've made in > https://gcc.gnu.org/r12-8294.=C2=A0 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 :(. >=20 > We are also using the same "de-facto" ABI throwing away the empty > struct > for Clang++ (https://reviews.llvm.org/D132285).=C2=A0 So we should update > the > spec here, instead of changing every implementation. >=20 > The C++ standard treats the empty struct as size 1 for ensuring the > semantics of pointer comparison operations.=C2=A0 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 --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University