This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Extract longjmp handling in EmSjLj to a function (NFC)
ClosedPublic

Authored by aheejin on Aug 25 2021, 2:22 PM.

Details

Summary

Emscripten SjLj and (soon-to-be-added) Wasm SjLj transformation share
many steps:

  1. Initialize setjmpTable and setjmpTableSize in the entry BB
  2. Handle setjmp callsites
  3. Handle longjmp callsites
  4. Cleanup and update SSA

1, 3, and 4 are identical for Emscripten SjLj and Wasm SjLj. Only the
step 2 is different. This CL extracts the current Emscripten SjLj's
longjmp callsites handling into a function. The reason to make this a
separate CL is, without this, the diff tool cannot compare things well
in the presence of moved code and added code in the followup Wasm SjLj
CL, and it ends up mixing them together, making the diff unreadable.

Also fixes some typos and variable names. So far we've been calling the
buffer argument to setjmp and longjmp jmpbuf, but the name used in
the man page for those functions is env, so updated them to be
consistent.

Diff Detail

Event Timeline

aheejin created this revision.Aug 25 2021, 2:22 PM
aheejin requested review of this revision.Aug 25 2021, 2:22 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2021, 2:22 PM

The diff still looks very messed up. What this does is simply extracting this part to a function named handleLongjmpableCallsForEmscriptenSjLj. (+ few variable name changes)

tlively accepted this revision.Aug 25 2021, 3:25 PM
tlively added inline comments.
llvm/lib/CodeGen/WasmEHPrepare.cpp
32

Is wasm_landingpad_context the same as wasm_lpad_context above? Should those names be consistent?

This revision is now accepted and ready to land.Aug 25 2021, 3:25 PM
aheejin updated this revision to Diff 368760.Aug 25 2021, 3:40 PM
aheejin marked an inline comment as done.

__wasm_landingpad_context -> __wasm_lpad_context

llvm/lib/CodeGen/WasmEHPrepare.cpp
32

Nice catch. Fixed.

This revision was landed with ongoing or failed builds.Aug 25 2021, 3:46 PM
This revision was automatically updated to reflect the committed changes.