functions with 'sret' argument must return void

Hello,

Attempting to add attributes to our compiled functions, I tried to
declare the first parameter "sret" since that's how our internal calling
convention works (the first parameter is a pointer to the function's
result). I got the error:

LLVM IR parsing error
<string>:6:8: error: functions with 'sret' argument must return void

Our functions return non-void because they return an integer status code
(either ok or some error). This seems to me like an obvious use case
for using result-value-written-to-a-pointer-parameter semantics, so
I don't understand why LLVM chokes on it. Is there a reason?

The reason I'm asking is that there is a function that I would
like to declare "readonly". But if I declare the function "readonly"
without that "sret" annotation, then LLVM of course is allowed to
assume the memory location containing the return value hasn't changed
at all.

Regards

Antoine.

On x86, the sret attribute arranges for the incoming sret pointer to be returned in eax, so the function can’t return anything else.

I think you’ll have to get by with a combination of other attributes instead of declaring the whole function as readnone. =/