]> granicus.if.org Git - llvm/commit
[WebAssembly] Restore stack pointer right after catch instruction
authorHeejin Ahn <aheejin@gmail.com>
Wed, 30 Jan 2019 22:44:45 +0000 (22:44 +0000)
committerHeejin Ahn <aheejin@gmail.com>
Wed, 30 Jan 2019 22:44:45 +0000 (22:44 +0000)
commitdd854ba81b01b3f377a63e1aef2585c79ca7ee47
treee9aa54450ac5344ae19caaedcd9d40e23af25c5c
parentb880916519c95ba5b9e4bb702cd315e51f8251b0
[WebAssembly] Restore stack pointer right after catch instruction

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 r352598 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.

Reviewers: dschuff

Subscribers: mgorny, sbc100, jgravelle-google, sunfish, llvm-commits

Differential Revision: https://reviews.llvm.org/D57421

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352681 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/WebAssembly/CMakeLists.txt
lib/Target/WebAssembly/WebAssembly.h
lib/Target/WebAssembly/WebAssemblyEHRestoreStackPointer.cpp [deleted file]
lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
test/CodeGen/WebAssembly/exception.ll