This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Warn on exception spec for Emscripten EH
ClosedPublic

Authored by aheejin on May 19 2021, 11:24 AM.

Details

Summary

It turns out we have not correctly supported exception spec all along in
Emscripten EH. Emscripten EH supports throw() but not throw with
types. See https://bugs.llvm.org/show_bug.cgi?id=50396.

Wasm EH also only supports throw() but not throw with types, and we
have been printing a warning message for the latter. This prints the
same warning message for throw with types when Emscripten EH is used,
or more precisely, when Wasm EH is not used. (So this will print the
warning messsage even when -fno-exceptions is used but I think that
should be fine. It's cumbersome to do a complilcated option checking in
CGException.cpp and options checkings are mostly done in elsewhere.)

Diff Detail

Event Timeline

aheejin created this revision.May 19 2021, 11:24 AM
aheejin requested review of this revision.May 19 2021, 11:24 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 19 2021, 11:24 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

BTW Is there a way to disable this warning?
Since IIUC this could cause code that was not warning (because it used -fno-exceptions or used emscripten's default of -fignore-exceptions) to now start warning, sometimes that makes users who use -Werror unhappy.

clang/lib/CodeGen/CGException.cpp
508

Does emscripten's default of -fignore-exceptions also end up as haveing ExceptionHandlingKind::None even though exceptions aren't disabled?

BTW Is there a way to disable this warning?

The warning is like

test.cpp:3:6: warning: dynamic exception specifications with types are currently ignored in wasm [-Wwasm-exception-spec]

So -Wno-wasm-exception-spec will disable the warning.

Since IIUC this could cause code that was not warning (because it used -fno-exceptions or used emscripten's default of -fignore-exceptions) to now start warning, sometimes that makes users who use -Werror unhappy.

-fno-exceptions does not print this warning. -fignore-exceptions does. There is a way to disable this as I said above, but if this makes existing users unhappy, I can abandon this patch. It was just to give users a hint that this feature they are using is in fact not working.

clang/lib/CodeGen/CGException.cpp
508

Yes. This ExceptionHandlingKind has nothing to do with whether it is enabled or disabled. It is defined here: https://github.com/llvm/llvm-project/blob/a647100b4320923b0e9d156cc3872b3be470ad98/clang/include/clang/Basic/LangOptions.h#L233-L234

This is the clang counterpart to -exception-model in LLVM backend. If we don't use -fwasm-exceptions, ExceptionHandlingKind will be None whether Emscripten EH is enabled or not.

kripken accepted this revision.May 20 2021, 7:11 AM

I'm not very familiar with this code, but it looks right, and sgtm to add a warning here.

This revision is now accepted and ready to land.May 20 2021, 7:11 AM
dschuff accepted this revision.May 20 2021, 11:33 AM

Got it, this makes sense to me too. And since it can be turned off, I'm not too worried about annoying users.

This revision was automatically updated to reflect the committed changes.