diff options
| author | Derek Schuff <dschuff@google.com> | 2016-08-09 22:37:00 +0000 |
|---|---|---|
| committer | Derek Schuff <dschuff@google.com> | 2016-08-09 22:37:00 +0000 |
| commit | 66641322ce93bbfad35bf4136da6ffd266a4f82f (patch) | |
| tree | ab4f38dae74ed609d007112a50614640ce68688c /llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp | |
| parent | e7c2875dc312a1146e5bfa3ae065a62c89b9e7cf (diff) | |
| download | bcm5719-llvm-66641322ce93bbfad35bf4136da6ffd266a4f82f.tar.gz bcm5719-llvm-66641322ce93bbfad35bf4136da6ffd266a4f82f.zip | |
[WebAssembly] Add -emscripten-cxx-exceptions-whitelist option
This patch adds -emscripten-cxx-exceptions-whitelist option to
WebAssemblyLowerEmscriptenExceptions pass. This options is the list of
function names in which Emscripten-style exception handling is enabled.
This is to support emscripten's EXCEPTION_CATCHING_WHITELIST which
exists because of the performance impact of emscripten's non-zero-cost
EH method.
Patch by Heejin Ahn
Differential Revision: https://reviews.llvm.org/D23292
llvm-svn: 278171
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp')
| -rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp index c906767458b..7a7587b02db 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenExceptions.cpp @@ -109,6 +109,13 @@ using namespace llvm; #define DEBUG_TYPE "wasm-lower-em-exceptions" +static cl::list<std::string> + Whitelist("emscripten-cxx-exceptions-whitelist", + cl::desc("The list of function names in which Emscripten-style " + "exception handling is enabled (see emscripten " + "EMSCRIPTEN_CATCHING_WHITELIST options)"), + cl::CommaSeparated); + namespace { class WebAssemblyLowerEmscriptenExceptions final : public ModulePass { const char *getPassName() const override { @@ -124,6 +131,7 @@ class WebAssemblyLowerEmscriptenExceptions final : public ModulePass { Function *getFindMatchingCatch(Module &M, unsigned NumClauses); Function *getInvokeWrapper(Module &M, InvokeInst *II); + bool areAllExceptionsAllowed() const { return WhitelistSet.empty(); } GlobalVariable *ThrewGV; // __THREW__ GlobalVariable *ThrewValueGV; // threwValue @@ -135,13 +143,17 @@ class WebAssemblyLowerEmscriptenExceptions final : public ModulePass { DenseMap<int, Function *> FindMatchingCatches; // Map of <function signature string, invoke_ wrappers> StringMap<Function *> InvokeWrappers; + // Set of whitelisted function names + std::set<std::string> WhitelistSet; public: static char ID; WebAssemblyLowerEmscriptenExceptions() : ModulePass(ID), ThrewGV(nullptr), ThrewValueGV(nullptr), - TempRet0GV(nullptr) {} + TempRet0GV(nullptr) { + WhitelistSet.insert(Whitelist.begin(), Whitelist.end()); + } bool runOnModule(Module &M) override; }; } // End anonymous namespace @@ -332,7 +344,8 @@ bool WebAssemblyLowerEmscriptenExceptions::runOnFunction(Function &F) { bool Changed = false; SmallVector<Instruction *, 64> ToErase; SmallPtrSet<LandingPadInst *, 32> LandingPads; - bool AllowExceptions = true; // will later change based on whitelist option + bool AllowExceptions = + areAllExceptionsAllowed() || WhitelistSet.count(F.getName()); for (BasicBlock &BB : F) { auto *II = dyn_cast<InvokeInst>(BB.getTerminator()); |

