[PATCH] D91274: [WebAssembly] Ban all TLS on non-emscripten targets (even local-exec)
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 11 09:06:07 PST 2020
sbc100 updated this revision to Diff 304538.
sbc100 added a comment.
typo
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91274/new/
https://reviews.llvm.org/D91274
Files:
llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
llvm/test/CodeGen/WebAssembly/tls-local-exec.ll
Index: llvm/test/CodeGen/WebAssembly/tls-local-exec.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/tls-local-exec.ll
+++ llvm/test/CodeGen/WebAssembly/tls-local-exec.ll
@@ -1,6 +1,15 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel | FileCheck %s --check-prefixes=CHECK,TLS
+; Check that using TLS without emscripten OS causes an error
+; RUN: not --crash llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory 2>&1 | FileCheck %s --check-prefix=ERROR
+; RUN: not --crash llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel 2>&1 | FileCheck %s --check-prefix=ERROR
+
+; ERROR: LLVM ERROR: WebAssembly does not yet support TLS outside of emscripten: variable tls
+
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory --mtriple wasm32-unknown-emscripten | FileCheck %s --check-prefixes=CHECK,TLS
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory --mtriple wasm32-unknown-emscripten -fast-isel | FileCheck %s --check-prefixes=CHECK,TLS
+
+; Check that TLS operations are lowered away when bulk-memory is not enabled. Even on non-emscripten targets
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=-bulk-memory | FileCheck %s --check-prefixes=CHECK,NO-TLS
+
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
Index: llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
+++ llvm/test/CodeGen/WebAssembly/tls-general-dynamic.ll
@@ -1,12 +1,17 @@
+; Check that using TLS without emscripten OS causes an error
; RUN: not --crash llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory 2>&1 | FileCheck %s --check-prefix=ERROR
; RUN: not --crash llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel 2>&1 | FileCheck %s --check-prefix=ERROR
+
+; ERROR: LLVM ERROR: WebAssembly does not yet support TLS outside of emscripten: variable tls
+
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory --mtriple wasm32-unknown-emscripten | FileCheck %s --check-prefixes=CHECK,TLS
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory --mtriple wasm32-unknown-emscripten -fast-isel | FileCheck %s --check-prefixes=CHECK,TLS
+
+; Check that TLS operations are lowered away when bulk-memory is not enabled. Even on non-emscripten targets
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=-bulk-memory | FileCheck %s --check-prefixes=CHECK,NO-TLS
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
-; ERROR: LLVM ERROR: only -ftls-model=local-exec is supported for now on non-Emscripten OSes: variable tls
; CHECK-LABEL: address_of_tls:
; CHECK-NEXT: .functype address_of_tls () -> (i32)
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
@@ -133,16 +133,9 @@
report_fatal_error("cannot use thread-local storage without bulk memory",
false);
- // 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 (GA->getGlobal()->getThreadLocalMode() !=
- GlobalValue::LocalExecTLSModel &&
- !Subtarget->getTargetTriple().isOSEmscripten()) {
- report_fatal_error("only -ftls-model=local-exec is supported for now on "
- "non-Emscripten OSes: variable " +
+ if (!Subtarget->getTargetTriple().isOSEmscripten()) {
+ report_fatal_error("WebAssembly does not yet support TLS outside of "
+ "emscripten: variable " +
GA->getGlobal()->getName(),
false);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91274.304538.patch
Type: text/x-patch
Size: 4948 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201111/9894d0eb/attachment.bin>
More information about the llvm-commits
mailing list