[llvm-dev] branch out of catchpad

Carlo Kok via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 13 02:12:38 PDT 2021


Thanks. That helped a lot. I ended up using your cascading "returns" idea with a state variable per try/catch. (should anyone ever need this in the future), where I do something like state = 1; goto end_of_catch; end_of_catch catch ret to a jumping pad that jumped to the next location, recursively.

On Mon, Oct 11, 2021, at 21:36, Reid Kleckner wrote:
> I think LLVM supports multiple catchrets, so that should work as long as they both return to the same parent function/funclet.
> 
> However, if you need to branch through multiple levels, you will probably have to set up an alloca used by a branch at the point of the return. This is what that would look like:
> 
> void f() {
>   try { maythrow(); }
>   catch (...) {
>     try { maythrow(); }
>     catch (...) {
>       if (condition()) goto out; // need to thread the target through the cascading returns
>       stuff();
>     } // IR needs branch here
>     stuff();
>   } // IR needs branch here
>   return 0;
> out:
>   return 1;
> }
> 
> HTH
> 
> On Fri, Oct 8, 2021 at 12:45 PM Carlo Kok via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>> If I need to branch out of the catch (catchpad) can I use a conditional catchret (ie have a catch with multiple catchret's) or do I have to branch to the end of the catch, and branch out from after the catchpad point?
>> 
>> --
>> Carlo Kok
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211013/5a7ce61a/attachment.html>


More information about the llvm-dev mailing list