[llvm-dev] sret vs noalias
Reid Kleckner via llvm-dev
llvm-dev at lists.llvm.org
Thu Sep 8 08:48:18 PDT 2016
On Thu, Sep 8, 2016 at 12:25 AM, Mikael Holmén via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hi,
>
> In ArgumentPromotion there is a piece of code that replaces the "sret"
> attribute with "noalias" and I'm puzzled about this:
>
> // Replace sret attribute with noalias. This reduces register pressure by
> // avoiding a register copy.
>
> And the commit message when this was introduced says
>
> "Because sret implies noalias, we also replace the former with the latter."
>
> But if I read about "sret" at
>
> http://llvm.org/docs/LangRef.html#parameter-attributes
>
> I don't see anything saying that "sret" must only be used when it doesn't
> alias with anything else?
>
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.
> 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?
>
It works as intended: those backends don't find sret, so they don't do the
extra register copy that sret normally requires.
> 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?
>
Yes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160908/56169e89/attachment.html>
More information about the llvm-dev
mailing list