branch out of catchpad

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?

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

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.