I haven't received any feedback about the approach I've taken yet (https://lists.llvm.org/pipermail/llvm-dev/2021-January/148175.html).
So I thought I'd try my luck here.
A splitted patchset can be found here: https://github.com/cynecx/llvm-project/commits/asmunwind-final
I've taken the following steps to add unwinding support from inline assembly:
- Add a new unwind "attribute" (like sideeffect) to the asm syntax:
invoke void asm sideeffect unwind "call thrower", "~{dirflag},~{fpsr},~{flags}"() to label %exit unwind label %uexit
2.) Add Bitcode writing/reading support + LLVM-IR parsing.
3.) Emit EHLabels around inline assembly lowering (SelectionDAGBuilder + GlobalISel) when InlineAsm::canThrow is enabled.
4.) Tweak InstCombineCalls/InlineFunction pass to not mark inline assembly "calls" as nounwind.
5.) Add clang support by introducing a new clobber: "unwind", which lower to the canThrow being enabled.
6.) Don't allow unwinding callbr.
This should be a compiler error diagnostic in SemaAsmStmt.cpp rather than an assert.