1 | // RUN: %clang -c -o %t %s |
2 | // RUN: %llvm_jitlink %t |
3 | // |
4 | // Test that basic ELF TLS work by adding together TLSs with values |
5 | // 0, 1, and -1, and returning the result (0 for success). This setup |
6 | // tests both zero-initialized (.tbss) and non-zero-initialized |
7 | // (.tdata) sections. |
8 | |
9 | .text |
10 | .abiversion 2 |
11 | .file "tlstest.cpp" |
12 | .globl main # -- Begin function main |
13 | .p2align 4 |
14 | .type main,@function |
15 | main: # @main |
16 | .Lfunc_begin0: |
17 | .Lfunc_gep0: |
18 | addis 2, 12, .TOC.-.Lfunc_gep0@ha |
19 | addi 2, 2, .TOC.-.Lfunc_gep0@l |
20 | .Lfunc_lep0: |
21 | .localentry main, .Lfunc_lep0-.Lfunc_gep0 |
22 | # %bb.0: # %entry |
23 | mflr 0 |
24 | std 30, -16(1) # 8-byte Folded Spill |
25 | stdu 1, -48(1) |
26 | addis 3, 2, x@got@tlsgd@ha |
27 | std 0, 64(1) |
28 | addi 3, 3, x@got@tlsgd@l |
29 | bl __tls_get_addr(x@tlsgd) |
30 | nop |
31 | lwz 30, 0(3) |
32 | addis 3, 2, y@got@tlsgd@ha |
33 | addi 3, 3, y@got@tlsgd@l |
34 | bl __tls_get_addr(y@tlsgd) |
35 | nop |
36 | lwz 3, 0(3) |
37 | addis 4, 2, z@got@tlsgd@ha |
38 | add 30, 3, 30 |
39 | addi 3, 4, z@got@tlsgd@l |
40 | bl __tls_get_addr(z@tlsgd) |
41 | nop |
42 | lwz 3, 0(3) |
43 | add 3, 30, 3 |
44 | extsw 3, 3 |
45 | addi 1, 1, 48 |
46 | ld 0, 16(1) |
47 | ld 30, -16(1) # 8-byte Folded Reload |
48 | mtlr 0 |
49 | blr |
50 | .long 0 |
51 | .quad 0 |
52 | .Lfunc_end0: |
53 | .size main, .Lfunc_end0-.Lfunc_begin0 |
54 | # -- End function |
55 | .type x,@object # @x |
56 | .section .tbss,"awT" ,@nobits |
57 | .globl x |
58 | .p2align 2, 0x0 |
59 | x: |
60 | .long 0 # 0x0 |
61 | .size x, 4 |
62 | |
63 | .type y,@object # @y |
64 | .section .tdata,"awT" ,@progbits |
65 | .globl y |
66 | .p2align 2, 0x0 |
67 | y: |
68 | .long 1 # 0x1 |
69 | .size y, 4 |
70 | |
71 | .type z,@object # @z |
72 | .globl z |
73 | .p2align 2, 0x0 |
74 | z: |
75 | .long 4294967295 # 0xffffffff |
76 | .size z, 4 |
77 | |