This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Support Emscripten EH/SjLj in Wasm64
ClosedPublic

Authored by aheejin on May 6 2021, 3:42 AM.

Details

Summary

In wasm64, the signatures of some library functions and global variables
defined in Emscripten change:

  • emscripten_longjmp: (i32, i32) -> () -> (i64, i32) -> () This changes because the first argument is the address of a memory buffer. This in turn causes more changes below.
  • setThrew: (i32, i32) -> () -> (i64, i32) -> () emscripten_longjmp calls setThrew with the i64 buffer argument as the first parameter.
  • __THREW__ (global var): i32 to i64 setThrew's first argument is set to this __THREW__ variable, so it should change to i64 as well.
  • testSetjmp: (i32, i32*, i32) -> (i32) -> (i64, i32*, i32) -> (i32) In the code transformation done in this pass, the value of __THREW__ is passed as the first parameter of testSetjmp.

This patch creates some helper functions to easily get types that become
different depending on the wasm32/wasm64, and uses them to change
various function signatures and code transformations. Also updates the
tests with WASM32/WASM64 check lines.

(Untested) Emscripten side patch: https://github.com/emscripten-core/emscripten/pull/14108

Diff Detail

Event Timeline

aheejin created this revision.May 6 2021, 3:42 AM
aheejin requested review of this revision.May 6 2021, 3:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2021, 3:42 AM
aheejin edited the summary of this revision. (Show Details)May 6 2021, 3:43 AM
aheejin edited the summary of this revision. (Show Details)
aardappel accepted this revision.May 6 2021, 11:44 AM
aardappel added inline comments.
llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
59

tip: you can declutter these kind of tests by passing -Dptr=i32 to Filecheck and then using a single CHECK line with [[ptr]] in them.

This revision is now accepted and ready to land.May 6 2021, 11:44 AM
aheejin updated this revision to Diff 344742.May 12 2021, 2:41 AM
aheejin marked an inline comment as done.

Use DPTR in tests

aheejin added inline comments.May 12 2021, 2:41 AM
llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
59

Thanks! This really simplifies things.

This revision was landed with ongoing or failed builds.May 14 2021, 3:45 AM
This revision was automatically updated to reflect the committed changes.