[clang] [CIR] Remove overly strict end_catch assertion in catch handler flattening (PR #193796)

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 24 09:54:56 PDT 2026


adams381 wrote:

The `getSinglePredecessor()` walk is the immediate trigger — cleanup scope flattening creates blocks with multiple predecessors in the Eigen case, so the walk returns null and the assertion fires.

But even if we fixed the predecessor walk, the assertion's invariant is too strict.  It checks that `end_catch` is the *last* non-branch operation before `yield`, but catch handlers can have legitimate cleanup code after `end_catch`.  The test shows this: `cir.call @cleanup()` and `cir.store` both follow `end_catch` before the `yield`.  `end_catch` marks the end of the exception-handling state, but user code can still execute after that.

The code after the assertion (replacing `yield` with `cir.br`) doesn't depend on `end_catch`'s position — it just redirects control flow out of the handler.

https://github.com/llvm/llvm-project/pull/193796


More information about the cfe-commits mailing list