[llvm] [Coroutines] fix coroutines + std::unique_ptr with async exceptions validation errors (PR #149691)

via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 29 11:03:09 PST 2025


tzuralon wrote:

> I'm afraid it is not working. Backend rejects the transformed IR. [godbolt](https://godbolt.org/z/937jzd7PT)
> 
> You can reproduce it with
> 
> ```shell
> opt pr148035_inst_does_not_dominate.ll -passes='cgscc(coro-split),coro-cleanup' | llc
> ```

This is due to the fact that the pass `simplifycfg`, which is used also in `coro-cleanup` impacts IR with both EH scopes and multiple block-tails.
The bug relates to an optimization called "block-tail merging", which unifies similar nodes with a single ret instruction to a "common.ret", then the code-gen experience an assertion violation because this same common.ret is visited in more than one EH scope.
I'm showing it here: [godbolt](https://godbolt.org/z/vvfKbdvrM), I took your IR and splitted `common.ret` back to 3 different ret nodes, and stripped it from coroutine context. on the above pane you can see that llc passes, on the bottom pane another opt pass of simplifycfg and then llc fails.
So, this is an incompatibility between simplifycfg and exception handling, not restricted to coroutines only.
This bug is not introduced with my changes to coroutines, the question is how you'd like to proceed, as it seems out of scope for this PR, and not related only to coroutines.

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


More information about the llvm-commits mailing list