1 ; RUN: not llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory 2>&1 | FileCheck %s --check-prefix=ERROR
2 ; RUN: not 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
3 ; 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
4 ; 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
5 ; 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
6 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
7 target triple = "wasm32-unknown-unknown"
9 ; ERROR: LLVM ERROR: only -ftls-model=local-exec is supported for now on non-Emscripten OSes: variable tls
11 ; CHECK-LABEL: address_of_tls:
12 ; CHECK-NEXT: .functype address_of_tls () -> (i32)
13 define i32 @address_of_tls() {
14 ; TLS-DAG: global.get __tls_base
15 ; TLS-DAG: i32.const tls
19 ; NO-TLS-NEXT: i32.const tls
21 ret i32 ptrtoint(i32* @tls to i32)
24 ; CHECK-LABEL: ptr_to_tls:
25 ; CHECK-NEXT: .functype ptr_to_tls () -> (i32)
26 define i32* @ptr_to_tls() {
27 ; TLS-DAG: global.get __tls_base
28 ; TLS-DAG: i32.const tls
32 ; NO-TLS-NEXT: i32.const tls
37 ; CHECK-LABEL: tls_load:
38 ; CHECK-NEXT: .functype tls_load () -> (i32)
39 define i32 @tls_load() {
40 ; TLS-DAG: global.get __tls_base
41 ; TLS-DAG: i32.const tls
43 ; TLS-NEXT: i32.load 0
46 ; NO-TLS-NEXT: i32.const 0
47 ; NO-TLS-NEXT: i32.load tls
49 %tmp = load i32, i32* @tls, align 4
53 ; CHECK-LABEL: tls_store:
54 ; CHECK-NEXT: .functype tls_store (i32) -> ()
55 define void @tls_store(i32 %x) {
56 ; TLS-DAG: global.get __tls_base
57 ; TLS-DAG: i32.const tls
59 ; TLS-NEXT: i32.store 0
62 ; NO-TLS-NEXT: i32.const 0
63 ; NO-TLS-NEXT: i32.store tls
65 store i32 %x, i32* @tls, align 4
69 ; CHECK-LABEL: tls_size:
70 ; CHECK-NEXT: .functype tls_size () -> (i32)
71 define i32 @tls_size() {
72 ; CHECK-NEXT: global.get __tls_size
74 %1 = call i32 @llvm.wasm.tls.size.i32()
78 ; CHECK-LABEL: tls_align:
79 ; CHECK-NEXT: .functype tls_align () -> (i32)
80 define i32 @tls_align() {
81 ; CHECK-NEXT: global.get __tls_align
83 %1 = call i32 @llvm.wasm.tls.align.i32()
87 ; CHECK-LABEL: tls_base:
88 ; CHECK-NEXT: .functype tls_base () -> (i32)
89 define i8* @tls_base() {
90 ; CHECK-NEXT: global.get __tls_base
92 %1 = call i8* @llvm.wasm.tls.base()
96 ; CHECK-LABEL: tls_base_write:
97 ; CHECK-NEXT: .functype tls_base_write (i32) -> ()
98 define void @tls_base_write(i8** %output) {
99 ; CHECK-NEXT: global.get __tls_base
100 ; CHECK-NEXT: i32.store 0
102 %1 = call i8* @llvm.wasm.tls.base()
103 store i8* %1, i8** %output
107 ; CHECK: .type tls,@object
108 ; TLS-NEXT: .section .tbss.tls,"",@
109 ; NO-TLS-NEXT: .section .bss.tls,"",@
110 ; CHECK-NEXT: .p2align 2
112 ; CHECK-NEXT: .int32 0
113 @tls = internal thread_local global i32 0
115 declare i32 @llvm.wasm.tls.size.i32()
116 declare i32 @llvm.wasm.tls.align.i32()
117 declare i8* @llvm.wasm.tls.base()