[llvm-dev] Function with multi return path?

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Wed Jun 7 08:42:10 PDT 2017


On 7 Jun 2017, at 16:13, TONGARI J via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> 2017-06-07 22:51 GMT+08:00 David Chisnall <David.Chisnall at cl.cam.ac.uk>:
> You could approximate this using the address-of-label extension and passing the address of the return basic block to the function then, in the abnormal return path, jumping to that.  Doing anything else is likely to be very complicated because the live registers at all of the potential landing points will need to agree and you’re likely to cost more in code complexity than you save.
> 
> I don't think blockaddress/indirectbr supports non-local jump. Does it? 

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.  Note that this (along with your original suggestion) will have really poor interaction with any modern branch predictor.

David



More information about the llvm-dev mailing list