C++ Logo

std-proposals

Advanced search

[std-proposals] Callee-cleanup, was Re: Relocation in C++

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Tue, 1 Feb 2022 14:46:06 -0500
On Tue, Feb 1, 2022 at 12:37 PM Gašper Ažman via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> For anyone considering callee-cleanup to be a desirable direction, please
> know that the general thought is more towards caller-cleanup and that
> callee-cleanup was a mistake.
>
> There are disagreements on the issue, but I don't think any feature that
> would end up mandating either of those will pass the committee. We're
> having similar issues with contracts (albeit there, we're having issues
> only on callee-cleanup arches).
>

Got any links for those who want to find out more? I'm ignorant of any
recent discussion.
My impression has always been that callee-cleanup is annoying because only
Microsoft does it; all "real" ABIs are caller-cleanup, and then there's
this one funky ABI that destroys parameters in the "wrong" order and
complicates the Standard.
*But*, every time cleanup order pops into the zeitgeist, it's someone
claiming that *callee*-cleanup (a.k.a. [[clang::trivial_abi]]) is strictly
better for codegen, because it lets you eliminate more aliasing, turn more
things into tail-calls (because now the caller's job is done at the `call`
instruction — no cleanup to be done afterward), and so on.
https://www.youtube.com/watch?v=rHIkrotSwcc&t=1303s (Chandler Carruth,
2019) for example.
So I'm surprised to hear that *callee*-cleanup is the "mistaken" one.

I absolutely agree (if needed) that no vendor is ever going to change their
calling convention from caller to callee nor from callee to caller, so a
proposal *mandating* either of those (at least for existing ordinary
types, as opposed to some brand-new species of type that has never existed
before) would be dead on arrival.

–Arthur

Received on 2022-02-01 19:46:18