1 ; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS
2 ; 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
3 ; 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
4 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
5 target triple = "wasm32-unknown-unknown"
7 ; CHECK-LABEL: address_of_tls:
8 ; CHECK-NEXT: .functype address_of_tls () -> (i32)
9 define i32 @address_of_tls() {
10 ; TLS-DAG: global.get __tls_base
11 ; TLS-DAG: i32.const tls
15 ; NO-TLS-NEXT: i32.const tls
17 ret i32 ptrtoint(i32* @tls to i32)
20 ; CHECK-LABEL: ptr_to_tls:
21 ; CHECK-NEXT: .functype ptr_to_tls () -> (i32)
22 define i32* @ptr_to_tls() {
23 ; TLS-DAG: global.get __tls_base
24 ; TLS-DAG: i32.const tls
28 ; NO-TLS-NEXT: i32.const tls
33 ; CHECK-LABEL: tls_load:
34 ; CHECK-NEXT: .functype tls_load () -> (i32)
35 define i32 @tls_load() {
36 ; TLS-DAG: global.get __tls_base
37 ; TLS-DAG: i32.const tls
39 ; TLS-NEXT: i32.load 0
42 ; NO-TLS-NEXT: i32.const 0
43 ; NO-TLS-NEXT: i32.load tls
45 %tmp = load i32, i32* @tls, align 4
49 ; CHECK-LABEL: tls_store:
50 ; CHECK-NEXT: .functype tls_store (i32) -> ()
51 define void @tls_store(i32 %x) {
52 ; TLS-DAG: global.get __tls_base
53 ; TLS-DAG: i32.const tls
55 ; TLS-NEXT: i32.store 0
58 ; NO-TLS-NEXT: i32.const 0
59 ; NO-TLS-NEXT: i32.store tls
61 store i32 %x, i32* @tls, align 4
65 ; CHECK-LABEL: tls_size:
66 ; CHECK-NEXT: .functype tls_size () -> (i32)
67 define i32 @tls_size() {
68 ; CHECK-NEXT: global.get __tls_size
70 %1 = call i32 @llvm.wasm.tls.size.i32()
74 ; CHECK: .type tls,@object
75 ; TLS-NEXT: .section .tbss.tls,"",@
76 ; NO-TLS-NEXT: .section .bss.tls,"",@
77 ; CHECK-NEXT: .p2align 2
79 ; CHECK-NEXT: .int32 0
80 @tls = internal thread_local(localexec) global i32 0
82 declare i32 @llvm.wasm.tls.size.i32()