functions with 'sret' argument must return void

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

functions with 'sret' argument must return void

Antoine Pitrou

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.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: functions with 'sret' argument must return void

Reid Kleckner-2
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. =/

On Thu, Jul 9, 2015 at 10:09 AM, Antoine Pitrou <[hidden email]> wrote:

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.


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev