Avoid wrapping emscripten_asm_* calls in __invoke_* wrappers, which breaks
EM_ASM. See https://github.com/emscripten-core/emscripten/issues/8894.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 35711 Build 35710: arc lint + arc unit
Event Timeline
Interesting!
To make sure I understand, is the issue that in the presence of a setjmp we turn those calls into invokes, which means in wasm we end up with an indirect call - and then in binaryen we don't see the emscripten_asm_const_int etc., and instead just the indirect call? (Or does the backend do more processing here?)
if so, then I'm not sure this is the correct fix, since EM_ASM calls *may* throw (not just JS exceptions, but also they may call back into compiled code and do a longjmp from there, and that should work). Perhaps what we need to do is, in Binaryen, look at indirect calls and see if they are done with a constant index, and the function at that index is emscripten_asm_const_int? (Maybe this is what you were thinking earlier, and I didn't understand it? Sorry if so!)
Now that you mention it, it doesn't feel correct to me either. I think the fix would have to be in binaryen.