This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Restore stack pointer right after catch instruction
ClosedPublic

Authored by aheejin on Jan 29 2019, 3:35 PM.

Details

Summary

After the staack is unwound due to a thrown exxception,
__stack_pointer global can point to an invalid address. So
a global.set to restore __stack_pointer should be inserted right
after catch instruction.

But after D57134 the global.set instruction is inserted not right
after catch but after block - br-on-exn - end_block -
extract_exception sequence. This CL fixes it.

While doing that, we can actually move ReplacePhysRegs pass after
LateEHPrepare and merge EHRestoreStackPointer pass into LateEHPrepare,
and now placing global.set to __stack_pointer right after catch is
much easier. Otherwise it is hard to guarantee that global.set is
still right after catch and not touched with other transformations, in
which case we have to do something to hoist it.

Diff Detail

Repository
rL LLVM

Event Timeline

aheejin created this revision.Jan 29 2019, 3:35 PM
aheejin edited the summary of this revision. (Show Details)Jan 29 2019, 3:51 PM
dschuff accepted this revision.Jan 30 2019, 1:40 PM
dschuff added inline comments.
lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
353 ↗(On Diff #184195)

Is this comment still accurate? We don't need so many catch_all instructions now, right?

This revision is now accepted and ready to land.Jan 30 2019, 1:40 PM
aheejin updated this revision to Diff 184366.Jan 30 2019, 2:14 PM
aheejin marked an inline comment as done.
  • Fix outdated comments
This revision was automatically updated to reflect the committed changes.
llvm/trunk/lib/Target/WebAssembly/WebAssembly.h