[PATCH] D130053: [WebAssembly] Use `localexec` as default TLS model for non-Emscripten targets
Andrew Brown via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 18 16:47:14 PDT 2022
abrown created this revision.
abrown added reviewers: sbc100, sunfish.
Herald added subscribers: pmatos, asb, ecnelises, hiraditya, jgravelle-google, dschuff.
Herald added a project: All.
abrown published this revision for review.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Only Emscripten supports dynamic linking with threads. To use thread-local
storage for other targets, this change defaults to the `localexec` model.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130053
Files:
llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -577,8 +577,9 @@
CallParams.removeOperand(0);
// For funcrefs, call_indirect is done through __funcref_call_table and the
- // funcref is always installed in slot 0 of the table, therefore instead of having
- // the function pointer added at the end of the params list, a zero (the index in
+ // funcref is always installed in slot 0 of the table, therefore instead of
+ // having the function pointer added at the end of the params list, a zero
+ // (the index in
// __funcref_call_table is added).
if (IsFuncrefCall) {
Register RegZero =
@@ -1156,7 +1157,7 @@
// If the callee is a GlobalAddress node (quite common, every direct call
// is) turn it into a TargetGlobalAddress node so that LowerGlobalAddress
// doesn't at MO_GOT which is not needed for direct calls.
- GlobalAddressSDNode* GA = cast<GlobalAddressSDNode>(Callee);
+ GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Callee);
Callee = DAG.getTargetGlobalAddress(GA->getGlobal(), DL,
getPointerTy(DAG.getDataLayout()),
GA->getOffset());
@@ -1719,20 +1720,12 @@
const GlobalValue *GV = GA->getGlobal();
- // Currently Emscripten does not support dynamic linking with threads.
- // Therefore, if we have thread-local storage, only the local-exec model
- // is possible.
- // TODO: remove this and implement proper TLS models once Emscripten
- // supports dynamic linking with threads.
- if (GV->getThreadLocalMode() != GlobalValue::LocalExecTLSModel &&
- !Subtarget->getTargetTriple().isOSEmscripten()) {
- report_fatal_error("only -ftls-model=local-exec is supported for now on "
- "non-Emscripten OSes: variable " +
- GV->getName(),
- false);
- }
-
- auto model = GV->getThreadLocalMode();
+ // Currently only Emscripten supports dynamic linking with threads. Therefore,
+ // on other targets, if we have thread-local storage, only the local-exec
+ // model is possible.
+ auto model = Subtarget->getTargetTriple().isOSEmscripten()
+ ? GV->getThreadLocalMode()
+ : GlobalValue::LocalExecTLSModel;
// Unsupported TLS modes
assert(model != GlobalValue::NotThreadLocal);
@@ -1791,8 +1784,7 @@
if (GV->getValueType()->isFunctionTy()) {
BaseName = MF.createExternalSymbolName("__table_base");
OperandFlags = WebAssemblyII::MO_TABLE_BASE_REL;
- }
- else {
+ } else {
BaseName = MF.createExternalSymbolName("__memory_base");
OperandFlags = WebAssemblyII::MO_MEMORY_BASE_REL;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130053.445656.patch
Type: text/x-patch
Size: 2948 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220718/1624ec37/attachment.bin>
More information about the llvm-commits
mailing list