-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
As reported in #165589, the WebAssembly backend currently does not support the callbr instruction.
Currently callbr is only used for supporting the asm goto extension, which is mostly found in the Linux kernel and similar embedded scenarios where the code wouldn't directly work with Wasm and would need substantial porting effort. Hence there haven't yet been any requests for support or use cases surfaced where it would be needed. A recent RFC proposed using callbr for some intrinsics as well, so it's possible that in the future there might be some intrinsic that we want to support that would also use it.
#165589 has some discussion of the crash that currently occurs when trying to use callbr but in order to actually make it work we'd also need to handle the indirect control flow, which seems to operate similarly to indirectbr. Wasm currently supports indirectbr by lowering it away to a switch using the IndirectBrExpandPass. Perhaps we could do something similar for callbr, although it's not obvious how that would work if we wanted to have some kind of real assembly inside.
But I don't think it makes sense to work on this until we have some kind of concrete use case for it. So I'm thinking we can leave this bug open for now until it becomes clear whether this would be useful for anyone. (If that's you, please leave a comment!)