[llvm-dev] Unwinding support for inline assembly

Paul via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 27 11:03:41 PST 2021


Hi,

I am currently looking at unwinding support for inline assembly, which might be useful for a coroutine library I am working on. The idea is that inline assembly may emit a call to a function which might throw/unwind. The current approach for that would be to emit an `invoke` instruction:

```
invoke void asm "call thrower", "~{dirflag},~{fpsr},~{flags}"()
to label %exit unwind label %uexit
```

However, Codegen doesn't currently emit proper EH Begin/End labels for this to work (because unwinding requires exception tables). I have experimented with adding the required EH labels to SelectionDAGBuilder, which now emits working code which allows unwinding from inline assembly code.

I was wondering whether there would be support for a patchset (which implements this). I am not quite sure, whether there are sideeffects/invariants I am missing (except for a few places where its assumed that inline asm doesn't throw; like in the Inliner and InstCombineCall pass) or if there is a reason why this isn't possible right now.

Furthermore, there might be a need to signify that an inline assembly "invoke" might throw. Right now I've implemented this as a change to the invoke syntax (the unwind keyword after asm):

```
invoke void asm sideeffect unwind "call thrower", "~{dirflag},~{fpsr},~{flags}"()
to label %exit unwind label %uexit

```

Some feedback on this topic and general direction to this approach would be appreciated!

Regards,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210127/4a53a114/attachment-0001.html>


More information about the llvm-dev mailing list