diff options
author | Sam Clegg <sbc@chromium.org> | 2019-04-04 01:43:21 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2019-04-04 01:43:21 +0000 |
commit | 12011fae17f1b8112ff5b8ea38e036874e9976fa (patch) | |
tree | 040c45a6ebdb6ad1e1d97bbb2e77f21076fe08f1 /llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp | |
parent | b8c6effacfff6409cefe78d549626e55a98453f9 (diff) | |
download | bcm5719-llvm-12011fae17f1b8112ff5b8ea38e036874e9976fa.tar.gz bcm5719-llvm-12011fae17f1b8112ff5b8ea38e036874e9976fa.zip |
[WebAssembly] EmscriptenEHSjLj: Don't abort if __THREW__ is defined
This allows __THREW__ to be defined in the current module, although
it is still required to be a GlobalVariable.
In emscripten we want to be able to compile the source code that
defines this symbols.
Previously we were avoid this by not running this pass when building
that compiler-rt library, but I have change out to build it using the
normal compiler path:
https://github.com/emscripten-core/emscripten/pull/8391
Differential Revision: https://reviews.llvm.org/D60232
llvm-svn: 357665
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp')
-rw-r--r-- | llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp index 9c33508a3df..7ab8e361a8b 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -334,11 +334,12 @@ static bool canThrow(const Value *V) { // which will generate an import and asssumes that it will exist at link time. static GlobalVariable *getGlobalVariableI32(Module &M, IRBuilder<> &IRB, const char *Name) { - if (M.getNamedGlobal(Name)) - report_fatal_error(Twine("variable name is reserved: ") + Name); - return new GlobalVariable(M, IRB.getInt32Ty(), false, - GlobalValue::ExternalLinkage, nullptr, Name); + auto* GV = dyn_cast<GlobalVariable>(M.getOrInsertGlobal(Name, IRB.getInt32Ty())); + if (!GV) + report_fatal_error(Twine("unable to create global: ") + Name); + + return GV; } // Simple function name mangler. |