diff options
author | Heejin Ahn <aheejin@gmail.com> | 2018-05-31 22:18:13 +0000 |
---|---|---|
committer | Heejin Ahn <aheejin@gmail.com> | 2018-05-31 22:18:13 +0000 |
commit | 23b1d1526478c1b1a3167b28cfc1cd31695a2bf7 (patch) | |
tree | 7b28f886923335d8b42f93b51c7d9589e10da3d3 /lib/CodeGen/CGCXXABI.h | |
parent | 5498e63d06e8760e5d1d73754a919f4d6d19886c (diff) | |
download | clang-23b1d1526478c1b1a3167b28cfc1cd31695a2bf7.tar.gz |
[WebAssembly] Use Windows EH instructions for Wasm EH
Summary:
Because wasm control flow needs to be structured, using WinEH
instructions to support wasm EH brings several benefits. This patch
makes wasm EH uses Windows EH instructions, with some changes:
1. Because wasm uses a single catch block to catch all C++ exceptions,
this merges all catch clauses into a single catchpad, within which we
test the EH selector as in Itanium EH.
2. Generates a call to `__clang_call_terminate` in case a cleanup
throws. Wasm does not have a runtime to handle this.
3. In case there is no catch-all clause, inserts a call to
`__cxa_rethrow` at the end of a catchpad in order to unwind to an
enclosing EH scope.
Reviewers: majnemer, dschuff
Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits
Differential Revision: https://reviews.llvm.org/D44931
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@333703 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGCXXABI.h')
-rw-r--r-- | lib/CodeGen/CGCXXABI.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/CodeGen/CGCXXABI.h b/lib/CodeGen/CGCXXABI.h index a1158d926c..65b50e14f4 100644 --- a/lib/CodeGen/CGCXXABI.h +++ b/lib/CodeGen/CGCXXABI.h @@ -607,6 +607,17 @@ CGCXXABI *CreateItaniumCXXABI(CodeGenModule &CGM); /// Creates a Microsoft-family ABI. CGCXXABI *CreateMicrosoftCXXABI(CodeGenModule &CGM); +struct CatchRetScope final : EHScopeStack::Cleanup { + llvm::CatchPadInst *CPI; + + CatchRetScope(llvm::CatchPadInst *CPI) : CPI(CPI) {} + + void Emit(CodeGenFunction &CGF, Flags flags) override { + llvm::BasicBlock *BB = CGF.createBasicBlock("catchret.dest"); + CGF.Builder.CreateCatchRet(CPI, BB); + CGF.EmitBlock(BB); + } +}; } } |