diff options
author | Heejin Ahn <aheejin@gmail.com> | 2016-09-01 21:05:15 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2016-09-01 21:05:15 +0000 |
commit | c0f18172f56ad349f56fefc15131cef2782bec8a (patch) | |
tree | 3a6cb93d770c4ae800194de111d700ee170d57b8 /llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | |
parent | 06d466a9bc4996a915cda13274aaccaf4323f9c5 (diff) | |
download | bcm5719-llvm-c0f18172f56ad349f56fefc15131cef2782bec8a.tar.gz bcm5719-llvm-c0f18172f56ad349f56fefc15131cef2782bec8a.zip |
[WebAssembly] Add asm.js-style setjmp/longjmp handling for wasm (reland r280302)
Summary: This patch adds asm.js-style setjmp/longjmp handling support for WebAssembly. It also uses JavaScript's try and catch mechanism.
Reviewers: jpp, dschuff
Subscribers: jfb, dschuff
Differential Revision: https://reviews.llvm.org/D24121
llvm-svn: 280415
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 3aa25932f84..ee60cf3cd1f 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -165,7 +165,19 @@ void WebAssemblyPassConfig::addIRPasses() { if (getOptLevel() != CodeGenOpt::None) addPass(createWebAssemblyOptimizeReturned()); - // Handle exceptions. + // If exception handling is not enabled and setjmp/longjmp handling is + // enabled, we lower invokes into calls and delete unreachable landingpad + // blocks. Lowering invokes when there is no EH support is done in + // TargetPassConfig::addPassesToHandleExceptions, but this runs after this + // function and SjLj handling expects all invokes to be lowered before. + if (!EnableEmException) { + addPass(createLowerInvokePass()); + // The lower invoke pass may create unreachable code. Remove it in order not + // to process dead blocks in setjmp/longjmp handling. + addPass(createUnreachableBlockEliminationPass()); + } + + // Handle exceptions and setjmp/longjmp if enabled. if (EnableEmException || EnableEmSjLj) addPass(createWebAssemblyLowerEmscriptenEHSjLj(EnableEmException, EnableEmSjLj)); |