Page MenuHomePhabricator

[WebAssembly] Make SjLj lowering globals thread-local
ClosedPublic

Authored by tlively on Sep 24 2020, 2:42 PM.

Details

Summary

Emscripten's longjump and exception mechanism depends on two global variables,
__THREW__ and __threwValue, which are changed to be defined as thread-local
in https://github.com/emscripten-core/emscripten/pull/12056. This patch updates
the corresponding code in the WebAssembly backend to properly declare these
globals as thread-local as well.

Diff Detail

Event Timeline

tlively created this revision.Sep 24 2020, 2:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 24 2020, 2:42 PM
tlively requested review of this revision.Sep 24 2020, 2:42 PM

Just to be sure, is it ok to do this even when atomics are not enabled?

sbc100 accepted this revision.Sep 24 2020, 2:47 PM

Awesome thanks!

llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
322

I'm surprised this is the cleanest way to do make the global as TLS... I still find lambdas a little harder to parse that straight line code. It kind of makes me what to write a little named functions called makeTLSGlobal to make this easier tfor me to read, but maybe thats just me.

This revision is now accepted and ready to land.Sep 24 2020, 2:47 PM

Just to be sure, is it ok to do this even when atomics are not enabled?

Yes, because I moved the CoalesceFeaturesAndStripAtomics and LowerAtomics passes to run after this changed pass.

tlively added inline comments.Sep 24 2020, 2:50 PM
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
322

Yeah, although I think the readability problem is mostly due to the huge number of arguments the GlobalVariable constructor takes. It would be nice if they had some more specific factory methods or constructor overloads.

@kripken I'm going to land this. Will you take care of the combined roll with https://github.com/emscripten-core/emscripten/pull/12056?

aheejin accepted this revision.Sep 24 2020, 2:52 PM
This revision was landed with ongoing or failed builds.Sep 24 2020, 2:56 PM
This revision was automatically updated to reflect the committed changes.

I can do a roll if needed, sure. (Is one needed? Let's see on the bots I guess...)