Pushing the CatchRetScope early causes cleanups for catch parameters to be emitted in the basic block of the catch handler instead of the catchret.dest block. This is important because the latter is not part of the catchpad and this caused code truncations due to ARC PreISel intrinsics in WinEHPrepare.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
The approach follows the C++ try/catch implementation in clang/lib/CodeGen/CGException.cpp. I think this is the correct solution for what I attempted to fix with D134866 in the backend before.
Thanks, I can see the bug here:
https://gcc.godbolt.org/z/1xjMYarT9
You can see how storeStrong cleanup uses the catchpad funclet when it should not.
clang/test/CodeGenObjCXX/arc-exceptions-seh.mm | ||
---|---|---|
36 | Don't we need an exceptional cleanup here to release the exception if do_something or may_throw throw? |
clang/test/CodeGenObjCXX/arc-exceptions-seh.mm | ||
---|---|---|
36 | Thanks, that's a very good point! -fobjc-arc-exceptions tells clang to generate invokes here instead of calls and then we can check funclet tokens in cleanup pads too. |
Don't we need an exceptional cleanup here to release the exception if do_something or may_throw throw?