OLD | NEW |
1 ; RUN: opt < %s -nacl-expand-tls -S | FileCheck %s | 1 ; RUN: opt < %s -nacl-expand-tls -S | FileCheck %s |
2 | 2 |
3 ; All thread-local variables should be removed | 3 ; All thread-local variables should be removed |
4 ; RUN: opt < %s -nacl-expand-tls -S | FileCheck %s -check-prefix=NO_TLS | 4 ; RUN: opt < %s -nacl-expand-tls -S | FileCheck %s -check-prefix=NO_TLS |
5 | 5 |
6 ; NO_TLS-NOT: thread_local | 6 ; NO_TLS-NOT: thread_local |
7 | 7 |
8 @tvar1 = thread_local global i64 123 | 8 @tvar1 = thread_local global i64 123 |
9 @tvar2 = thread_local global i32 456 | 9 @tvar2 = thread_local global i32 456 |
10 | 10 |
11 | 11 |
12 ; CHECK: %tls_init_template = type <{ i64, i32 }> | 12 ; CHECK: %tls_init_template = type <{ i64, i32 }> |
13 ; CHECK: %tls_struct = type <{ %tls_init_template, %tls_bss_template }> | 13 ; CHECK: %tls_struct = type <{ %tls_init_template, %tls_bss_template }> |
14 ; CHECK: %tls_bss_template = type <{ [4 x i8] }> | 14 ; CHECK: %tls_bss_template = type <{ [4 x i8] }> |
15 | 15 |
16 | 16 |
17 ; CHECK: @__tls_template_start = internal constant %tls_init_template <{ i64 123
, i32 456 }> | 17 ; CHECK: @__tls_template_start = internal constant %tls_init_template <{ i64 123
, i32 456 }> |
18 | 18 |
19 ; CHECK: @__tls_template_alignment = internal constant i32 8 | 19 ; CHECK: @__tls_template_alignment = internal constant i32 8 |
20 | 20 |
21 | 21 |
22 define i64* @get_tvar1() { | 22 define i64* @get_tvar1() { |
23 ret i64* @tvar1 | 23 ret i64* @tvar1 |
24 } | 24 } |
25 ; CHECK: define i64* @get_tvar1() | 25 ; CHECK: define i64* @get_tvar1() |
26 ; CHECK: %tls_raw = call i8* @llvm.nacl.read.tp() | 26 ; CHECK: %tls_raw = call i8* @llvm.nacl.read.tp() |
27 ; CHECK: %tls_struct = bitcast i8* %tls_raw to %tls_struct* | 27 ; CHECK: %tls_struct = bitcast i8* %tls_raw to %tls_struct* |
28 ; CHECK: %field = getelementptr %tls_struct* %tls_struct, i32 -1, i32 0, i32 0 | 28 ; CHECK: %field = getelementptr %tls_struct, %tls_struct* %tls_struct, i32 -1, i
32 0, i32 0 |
29 ; CHECK: ret i64* %field | 29 ; CHECK: ret i64* %field |
30 | 30 |
31 | 31 |
32 define i32* @get_tvar2() { | 32 define i32* @get_tvar2() { |
33 ret i32* @tvar2 | 33 ret i32* @tvar2 |
34 } | 34 } |
35 ; Much the same as for get_tvar1. | 35 ; Much the same as for get_tvar1. |
36 ; CHECK: define i32* @get_tvar2() | 36 ; CHECK: define i32* @get_tvar2() |
37 ; CHECK: %field = getelementptr %tls_struct* %tls_struct, i32 -1, i32 0, i32 1 | 37 ; CHECK: %field = getelementptr %tls_struct, %tls_struct* %tls_struct, i32 -1, i
32 0, i32 1 |
38 | 38 |
39 | 39 |
40 ; Check that we define global variables for TLS templates | 40 ; Check that we define global variables for TLS templates |
41 | 41 |
42 @__tls_template_start = external global i8 | 42 @__tls_template_start = external global i8 |
43 @__tls_template_tdata_end = external global i8 | 43 @__tls_template_tdata_end = external global i8 |
44 @__tls_template_end = external global i8 | 44 @__tls_template_end = external global i8 |
45 | 45 |
46 define i8* @get_tls_template_start() { | 46 define i8* @get_tls_template_start() { |
47 ret i8* @__tls_template_start | 47 ret i8* @__tls_template_start |
48 } | 48 } |
49 ; CHECK: define i8* @get_tls_template_start() | 49 ; CHECK: define i8* @get_tls_template_start() |
50 ; CHECK: ret i8* bitcast (%tls_init_template* @__tls_template_start to i8*) | 50 ; CHECK: ret i8* bitcast (%tls_init_template* @__tls_template_start to i8*) |
51 | 51 |
52 define i8* @get_tls_template_tdata_end() { | 52 define i8* @get_tls_template_tdata_end() { |
53 ret i8* @__tls_template_tdata_end | 53 ret i8* @__tls_template_tdata_end |
54 } | 54 } |
55 ; CHECK: define i8* @get_tls_template_tdata_end() | 55 ; CHECK: define i8* @get_tls_template_tdata_end() |
56 ; CHECK: ret i8* bitcast (%tls_init_template* getelementptr inbounds (%tls_init_
template* @__tls_template_start, i32 1) to i8*) | 56 ; CHECK: ret i8* bitcast (%tls_init_template* getelementptr inbounds (%tls_init_
template, %tls_init_template* @__tls_template_start, i32 1) to i8*) |
57 | 57 |
58 define i8* @get_tls_template_end() { | 58 define i8* @get_tls_template_end() { |
59 ret i8* @__tls_template_end | 59 ret i8* @__tls_template_end |
60 } | 60 } |
61 ; CHECK: define i8* @get_tls_template_end() | 61 ; CHECK: define i8* @get_tls_template_end() |
62 ; CHECK: ret i8* bitcast (%tls_struct* getelementptr (%tls_struct* bitcast (%tls
_init_template* @__tls_template_start to %tls_struct*), i32 1) to i8*) | 62 ; CHECK: ret i8* bitcast (%tls_struct* getelementptr (%tls_struct, %tls_struct*
bitcast (%tls_init_template* @__tls_template_start to %tls_struct*), i32 1) to i
8*) |
63 | 63 |
64 | 64 |
65 ; Check that we define the TLS layout functions | 65 ; Check that we define the TLS layout functions |
66 | 66 |
67 declare i32 @__nacl_tp_tls_offset(i32) | 67 declare i32 @__nacl_tp_tls_offset(i32) |
68 declare i32 @__nacl_tp_tdb_offset(i32) | 68 declare i32 @__nacl_tp_tdb_offset(i32) |
69 | 69 |
70 define i32 @test_get_tp_tls_offset(i32 %tls_size) { | 70 define i32 @test_get_tp_tls_offset(i32 %tls_size) { |
71 %offset = call i32 @__nacl_tp_tls_offset(i32 %tls_size) | 71 %offset = call i32 @__nacl_tp_tls_offset(i32 %tls_size) |
72 ret i32 %offset | 72 ret i32 %offset |
73 } | 73 } |
74 ; Uses of the intrinsic are replaced with uses of a regular function. | 74 ; Uses of the intrinsic are replaced with uses of a regular function. |
75 ; CHECK: define i32 @test_get_tp_tls_offset | 75 ; CHECK: define i32 @test_get_tp_tls_offset |
76 ; CHECK: call i32 @nacl_tp_tls_offset | 76 ; CHECK: call i32 @nacl_tp_tls_offset |
77 ; NO_TLS-NOT: __nacl_tp_tls_offset | 77 ; NO_TLS-NOT: __nacl_tp_tls_offset |
78 | 78 |
79 define i32 @test_get_tp_tdb_offset(i32 %tdb_size) { | 79 define i32 @test_get_tp_tdb_offset(i32 %tdb_size) { |
80 %offset = call i32 @__nacl_tp_tdb_offset(i32 %tdb_size) | 80 %offset = call i32 @__nacl_tp_tdb_offset(i32 %tdb_size) |
81 ret i32 %offset | 81 ret i32 %offset |
82 } | 82 } |
83 ; Uses of the intrinsic are replaced with uses of a regular function. | 83 ; Uses of the intrinsic are replaced with uses of a regular function. |
84 ; CHECK: define i32 @test_get_tp_tdb_offset | 84 ; CHECK: define i32 @test_get_tp_tdb_offset |
85 ; CHECK: call i32 @nacl_tp_tdb_offset | 85 ; CHECK: call i32 @nacl_tp_tdb_offset |
86 ; NO_TLS-NOT: __nacl_tp_tdb_offset | 86 ; NO_TLS-NOT: __nacl_tp_tdb_offset |
OLD | NEW |