[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_9877F4C8240A0DDA7399A0F8E2EEE71E5D0A@qq.com>
Date: Fri, 21 Feb 2025 16:31:27 +0800
From: HUANG Zhaobin <huang_zhaobin@...mail.com>
To: ej@...i.de
Cc: airlied@...il.com,
boqun.feng@...il.com,
gregkh@...uxfoundation.org,
hch@...radead.org,
hpa@...or.com,
ksummit@...ts.linux.dev,
linux-kernel@...r.kernel.org,
miguel.ojeda.sandonis@...il.com,
rust-for-linux@...r.kernel.org,
torvalds@...ux-foundation.org
Subject: Re: C aggregate passing (Rust kernel policy)
On Thu, 20 Feb 2025 16:17:07 +0100 (CET), Jan Engelhardt <ej@...i.de> wrote:
>
> Returning aggregates in C++ is often implemented with a secret extra
> pointer argument passed to the function. The C backend does not
> perform that kind of transformation automatically. I surmise ABI reasons.
No, in both C and C++, fff accepts a secret extra pointer argument.
https://godbolt.org/z/13K9aEffe
For gcc, the difference is that `sb` is allocated then copied back in C,
while in C++ NRVO is applied so there is no extra allocation and copy.
Clang does NRVO for both C and C++ in this case, thus generating exactly
the same codes for them.
I have no idea why gcc doesn't do the same.
Powered by blists - more mailing lists