[llvm-dev] sret read after unwind

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Tue Jan 4 14:40:34 PST 2022


On Mon, Dec 13, 2021 at 12:13 PM Nikita Popov via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> I think the answer to this is "never", because sret is considered an ABI
> attribute -- though to be honest I'm not really clear in which way it
> actually affects the call ABI.
>

IMO the main effect of the sret attribute is to copy the struct pointer
into the return register on function exit. Consider the difference here:

https://gcc.godbolt.org/z/EoTMqq8bW
struct Big { int words[32]; };
Big foo() {  return Big{}; }
void bar(Big *b) { *b = Big{}; }

`foo` includes a copy from RDI to RAX, but bar does not.

This is what makes it an ABI attribute, and not an inferable attribute.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220104/36267176/attachment.html>


More information about the llvm-dev mailing list