xref: /llvm-project/lld/test/wasm/lto/tls.ll (revision f01fdd17b4d202727023da23bdd120eb0bd94f9f)
1; Test that LTO objects build with TLS and threading support can be linked into
2; a single threaded binary.  Specifically the references to `__tls_base` that
3; can be generated at LTO-time need to trigger the creation of the internal/fake
4; `__tls_base` symbol in the linker.
5
6; RUN: llvm-as %s -o %t1.o
7; RUN: wasm-ld --export=tls_int --export=get_tls %t1.o -o %t
8; RUN: obj2yaml %t | FileCheck %s
9
10target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20"
11target triple = "wasm32-unknown-emscripten"
12
13@tls_int = dso_local thread_local global i32 99
14
15define i32 @get_tls() #0 {
16  %val = load i32, ptr @tls_int
17  ret i32 %val
18}
19
20define void @_start() #0 {
21  ret void
22}
23
24attributes #0 = { noinline nounwind optnone "target-features"="+atomics,+bulk-memory,+mutable-globals,+sign-ext" }
25
26;      CHECK:   - Type:            GLOBAL
27; CHECK-NEXT:     Globals:
28; CHECK-NEXT:       - Index:           0
29; CHECK-NEXT:         Type:            I32
30; CHECK-NEXT:         Mutable:         true
31; CHECK-NEXT:         InitExpr:
32; CHECK-NEXT:           Opcode:          I32_CONST
33; CHECK-NEXT:           Value:           66576
34; CHECK-NEXT:       - Index:           1
35; CHECK-NEXT:         Type:            I32
36; CHECK-NEXT:         Mutable:         false
37; CHECK-NEXT:         InitExpr:
38; CHECK-NEXT:           Opcode:          I32_CONST
39; CHECK-NEXT:           Value:           1024
40
41;      CHECK:     GlobalNames:
42; CHECK-NEXT:       - Index:           0
43; CHECK-NEXT:         Name:            __stack_pointer
44; CHECK-NEXT:       - Index:           1
45; CHECK-NEXT:         Name:            __tls_base
46