diff options
author | Heejin Ahn <aheejin@gmail.com> | 2018-08-22 21:13:49 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2018-08-22 21:13:49 +0000 |
commit | 972fc3588bdb52724c8c8b3b2125a95e9cd2e299 (patch) | |
tree | b7cac11780407755328a47cd502155c2b4d82a3d /llvm/test/CodeGen/WebAssembly/exception.ll | |
parent | 6b6d2e010593e499b24048188e91c993c6692407 (diff) | |
download | bcm5719-llvm-972fc3588bdb52724c8c8b3b2125a95e9cd2e299.tar.gz bcm5719-llvm-972fc3588bdb52724c8c8b3b2125a95e9cd2e299.zip |
[WebAssembly] Don't write SP back when prolog is generated only for EH
Summary:
When we don't actually have stack-allocated variables but need SP only
to support EH, we don't need to write SP back in the epilog, because we
don't bump down the stack pointer.
Reviewers: dschuff
Subscribers: jgravelle-google, sbc100, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D51114
llvm-svn: 340454
Diffstat (limited to 'llvm/test/CodeGen/WebAssembly/exception.ll')
-rw-r--r-- | llvm/test/CodeGen/WebAssembly/exception.ll | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/exception.ll b/llvm/test/CodeGen/WebAssembly/exception.ll index a0256d23891..0757f9769bd 100644 --- a/llvm/test/CodeGen/WebAssembly/exception.ll +++ b/llvm/test/CodeGen/WebAssembly/exception.ll @@ -217,6 +217,35 @@ ehcleanup: ; preds = %catch cleanupret from %8 unwind to caller } +; When a function does not have stack-allocated objects, it does not need to +; store SP back to __stack_pointer global at the epilog. + +; CHECK-LABEL: no_sp_writeback +; CHECK: try +; CHECK: call foo@FUNCTION +; CHECK: end_try +; CHECK-NOT: set_global __stack_pointer@GLOBAL +; CHECK: return +define void @no_sp_writeback() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) { +entry: + invoke void @foo() + to label %try.cont unwind label %catch.dispatch + +catch.dispatch: ; preds = %entry + %0 = catchswitch within none [label %catch.start] unwind to caller + +catch.start: ; preds = %catch.dispatch + %1 = catchpad within %0 [i8* null] + %2 = call i8* @llvm.wasm.get.exception(token %1) + %3 = call i32 @llvm.wasm.get.ehselector(token %1) + %4 = call i8* @__cxa_begin_catch(i8* %2) #2 [ "funclet"(token %1) ] + call void @__cxa_end_catch() [ "funclet"(token %1) ] + catchret from %1 to label %try.cont + +try.cont: ; preds = %entry, %catch.start + ret void +} + declare void @foo() declare void @bar(i32*) declare i32 @__gxx_wasm_personality_v0(...) |