[llvm-dev] branch out of catchpad

Reid Kleckner via llvm-dev llvm-dev at lists.llvm.org
Mon Oct 11 12:36:32 PDT 2021


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/20211011/24efdc1a/attachment.html>


More information about the llvm-dev mailing list