<div dir="ltr"><div dir="ltr">On Mon, Dec 13, 2021 at 12:13 PM Nikita Popov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div>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.</div></div></div></blockquote><div><br></div><div>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:</div><div><br></div><div><a href="https://gcc.godbolt.org/z/EoTMqq8bW">https://gcc.godbolt.org/z/EoTMqq8bW</a><br></div><div>struct Big { int words[32]; };<br>Big foo() {  return Big{}; }<br>void bar(Big *b) { *b = Big{}; }<br></div><div><br></div><div>`foo` includes a copy from RDI to RAX, but bar does not.</div><div><br></div><div>This is what makes it an ABI attribute, and not an inferable attribute.</div></div></div>