This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add exception handling option
ClosedPublic

Authored by aheejin on Feb 23 2018, 8:04 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

aheejin created this revision.Feb 23 2018, 8:04 AM

Don't we already have -fexceptions and -fno-exceptions for this?

dschuff accepted this revision.Mar 1 2018, 11:11 AM

This flag turns on CPU features (i.e. there's one for each new wasm feature proposal that has to be feature-detected), so I think this makes sense to be consistent with all the others. I could imagine enabling exceptions in the frontend but having some kind of emulation in the backend (like we do today for emscripten). More generally the semantics -fno-exceptions unfortunately doesn't exactly match the kind of behavior people typically want because it doesn't allow you to compile code that has try/catch/throw at all. In PNaCl and emscripten the default behavior is instead to compile that code but to lower it away and turn throw into abort. Also IIRC even with -fno-exceptions the code still has to allow exceptions to propagate which means you end up with invokes everywhere instead of calls, so you are still paying most of the costs of enabling EH. So that bit is a little bit complex and we'll probably want to think a bit more carefully about what options we want to have. But a machine flag for enabling the CPU feature makes sense to start.

This revision is now accepted and ready to land.Mar 1 2018, 11:11 AM
This revision was automatically updated to reflect the committed changes.