sret vs noalias

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?

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?

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?

Thanks,
Mikael

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.