<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Sep 8, 2016 at 12:25 AM, Mikael Holmén via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
In ArgumentPromotion there is a piece of code that replaces the "sret" attribute with "noalias" and I'm puzzled about this:<br>
<br>
// Replace sret attribute with noalias. This reduces register pressure by<br>
// avoiding a register copy.<br>
<br>
And the commit message when this was introduced says<br>
<br>
"Because sret implies noalias, we also replace the former with the latter."<br>
<br>
But if I read about "sret" at<br>
<br>
<a href="http://llvm.org/docs/LangRef.html#parameter-attributes" rel="noreferrer" target="_blank">http://llvm.org/docs/LangRef.<wbr>html#parameter-attributes</a><br>
<br>
I don't see anything saying that "sret" must only be used when it doesn't alias with anything else?<br></blockquote><div><br></div><div>Clang appears to set both attributes (sret and noalias) on implicit struct return pointer parameters. I think we might be better off having sret *not* imply noalias, and letting frontends set noalias separately. Argument promotion would then simply drop 'sret' when possible.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Also, there are several backends that look for the "sret" attribute, how does that work if "sret" has already been removed by ArgumentPromotion when running opt?<br></blockquote><div><br></div><div>It works as intended: those backends don't find sret, so they don't do the extra register copy that sret normally requires.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
And finally, if my own backend doesn't look at the "sret" attribute at all, is it then ok for my frontend to avoid emitting it, and just use noalias (when applicable) instead?<br></blockquote><div><br></div><div>Yes. </div></div></div></div>