Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / wasm / tls-relocations.s
blobebe83227631f470b3a5504248b40a6f7a24a4dd5
1 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
3 .section data,"",@
4 .int32 41
5 data_sym:
6 .int32 42
7 .size data_sym, 4
9 # TLS data section of size 16 with as relocations at offset 8 and 12
10 .section tls_sec,"T",@
11 .globl tls_sym
12 .p2align 2
13 .int32 0x50
14 tls_sym:
15 .int32 0x51
16 .int32 data_sym
17 .int32 tls_sym
18 .size tls_sym, 4
20 .section .custom_section.target_features,"",@
21 .int8 2
22 .int8 43
23 .int8 7
24 .ascii "atomics"
25 .int8 43
26 .int8 11
27 .ascii "bulk-memory"
29 # RUN: wasm-ld --experimental-pic -pie -no-gc-sections --shared-memory --no-entry -o %t.wasm %t.o
30 # RUN: obj2yaml %t.wasm | FileCheck %s
31 # RUN: llvm-objdump -d --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck --check-prefix=ASM %s --
33 # CHECK: - Type: GLOBAL
35 # __tls_base
36 # CHECK-NEXT: Globals:
37 # CHECK-NEXT: - Index: 3
38 # CHECK-NEXT: Type: I32
39 # CHECK-NEXT: Mutable: true
40 # CHECK-NEXT: InitExpr:
41 # CHECK-NEXT: Opcode: I32_CONST
42 # CHECK-NEXT: Value: 0
44 # __tls_size
45 # CHECK-NEXT: - Index: 4
46 # CHECK-NEXT: Type: I32
47 # CHECK-NEXT: Mutable: false
48 # CHECK-NEXT: InitExpr:
49 # CHECK-NEXT: Opcode: I32_CONST
50 # CHECK-NEXT: Value: 16
52 # __tls_align
53 # CHECK-NEXT: - Index: 5
54 # CHECK-NEXT: Type: I32
55 # CHECK-NEXT: Mutable: false
56 # CHECK-NEXT: InitExpr:
57 # CHECK-NEXT: Opcode: I32_CONST
58 # CHECK-NEXT: Value: 4
60 # ASM: <__wasm_init_tls>:
61 # ASM-EMPTY:
62 # ASM-NEXT: local.get 0
63 # ASM-NEXT: global.set 3
64 # ASM-NEXT: local.get 0
65 # ASM-NEXT: i32.const 0
66 # ASM-NEXT: i32.const 16
67 # ASM-NEXT: memory.init 0, 0
68 # call to __wasm_apply_tls_relocs
69 # ASM-NEXT: call 4
70 # ASM-NEXT: end
72 # ASM: <__wasm_apply_tls_relocs>:
73 # ASM-EMPTY:
74 # ASM-NEXT: i32.const 8
75 # ASM-NEXT: global.get 3
76 # ASM-NEXT: i32.add
77 # ASM-NEXT: global.get 1
78 # ASM-NEXT: i32.const 20
79 # ASM-NEXT: i32.add
80 # ASM-NEXT: i32.store 0
81 # ASM-NEXT: i32.const 12
82 # ASM-NEXT: global.get 3
83 # ASM-NEXT: i32.add
84 # ASM-NEXT: global.get 3
85 # ASM-NEXT: i32.const 4
86 # ASM-NEXT: i32.add
87 # ASM-NEXT: i32.store 0
88 # ASM-NEXT: end