aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/WasmEHPrepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/WasmEHPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/WasmEHPrepare.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp
index c04a7b28eff9..aa6645227edb 100644
--- a/llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -77,8 +77,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/CodeGen/TargetLowering.h"
-#include "llvm/CodeGen/TargetSubtargetInfo.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
+#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/WasmEHFuncInfo.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicsWebAssembly.h"
@@ -212,9 +212,15 @@ bool WasmEHPrepare::prepareEHPads(Function &F) {
assert(F.hasPersonalityFn() && "Personality function not found");
- // __wasm_lpad_context global variable
+ // __wasm_lpad_context global variable.
+ // This variable should be thread local. If the target does not support TLS,
+ // we depend on CoalesceFeaturesAndStripAtomics to downgrade it to
+ // non-thread-local ones, in which case we don't allow this object to be
+ // linked with other objects using shared memory.
LPadContextGV = cast<GlobalVariable>(
M.getOrInsertGlobal("__wasm_lpad_context", LPadContextTy));
+ LPadContextGV->setThreadLocalMode(GlobalValue::GeneralDynamicTLSModel);
+
LPadIndexField = IRB.CreateConstGEP2_32(LPadContextTy, LPadContextGV, 0, 0,
"lpad_index_gep");
LSDAField =