[PATCH] D57421: [WebAssembly] Restore stack pointer right after catch instruction

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 29 15:35:28 PST 2019


aheejin created this revision.
aheejin added a reviewer: dschuff.
Herald added subscribers: llvm-commits, sunfish, jgravelle-google, sbc100, mgorny.

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 <https://reviews.llvm.org/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 `global.set` to `__stack_pointer` to be placed right after
`catch` 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.


Repository:
  rL LLVM

https://reviews.llvm.org/D57421

Files:
  lib/Target/WebAssembly/CMakeLists.txt
  lib/Target/WebAssembly/WebAssembly.h
  lib/Target/WebAssembly/WebAssemblyEHRestoreStackPointer.cpp
  lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  test/CodeGen/WebAssembly/exception.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57421.184195.patch
Type: text/x-patch
Size: 9800 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190129/64a701e5/attachment.bin>


More information about the llvm-commits mailing list