[llvm-dev] Function with multi return path?
TONGARI J via llvm-dev
llvm-dev at lists.llvm.org
Wed Jun 7 18:45:00 PDT 2017
2017-06-07 23:42 GMT+08:00 David Chisnall <David.Chisnall at cl.cam.ac.uk>:
>
> No, but you can take the address of the block, pass it to the function,
> have the function return to the alternate return address and then (in the
> caller) jump immediately to the address in the return register.
Yeah, that's the closest way we can get in LLVM at this moment.
> Note that this (along with your original suggestion) will have really poor
> interaction with any modern branch predictor.
>
In my idea the caller and callee have full knowledge about the branch
destinations, so if the optimizer inlines the callee, it can jump to the
alternate destinations w/o indirection.
In case it's not inlined, the normal return path should incur no overhead
as well, and for alternate return paths it's just a matter of setting the
return register.
But as I said, I'm not an expert so I don't really know whether what I
described is implementable in LLVM on all architectures.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170608/6a331c31/attachment.html>
More information about the llvm-dev
mailing list