OLD | NEW |
1 ; Test of global initializers. | 1 ; Test of global initializers. |
2 | 2 |
3 ; Check that we generate proper global initializers. | 3 ; Check that we generate proper global initializers. |
4 ; RUN: %p2i -i %s --args -verbose inst | FileCheck %s | 4 ; RUN: %l2i -i %s --insts | FileCheck %s |
5 | 5 ; RUN: %p2i -i %s --insts | FileCheck %s |
6 ; Check that what we generate is valid assembly | |
7 ; RUN: %p2i -i %s --args -verbose none \ | |
8 ; RUN: | llvm-mc -triple=i686-none-nacl -x86-asm-syntax=intel -filetype=obj | |
9 | |
10 ; Check that we don't generate errors | |
11 ; RUN: %p2i -i %s --args -verbose none | FileCheck --check-prefix=ERRORS %s | |
12 | 6 |
13 @PrimitiveInit = internal global [4 x i8] c"\1B\00\00\00", align 4 | 7 @PrimitiveInit = internal global [4 x i8] c"\1B\00\00\00", align 4 |
14 ; CHECK: .type PrimitiveInit,@object | 8 ; CHECK: @PrimitiveInit = internal global [4 x i8] c"\1B\00\00\00", align 4 |
15 ; CHECK-NEXT: .section .data,"aw",@progbits | |
16 ; CHECK-NEXT: .align 4 | |
17 ; CHECK-NEXT: PrimitiveInit: | |
18 ; CHECK-NEXT: .byte | |
19 ; CHECK: .size PrimitiveInit, 4 | |
20 | 9 |
21 @PrimitiveInitConst = internal constant [4 x i8] c"\0D\00\00\00", align 4 | 10 @PrimitiveInitConst = internal constant [4 x i8] c"\0D\00\00\00", align 4 |
22 ; CHECK: .type PrimitiveInitConst,@object | 11 ; CHECK-NEXT: @PrimitiveInitConst = internal constant [4 x i8] c"\0D\00\00\00",
align 4 |
23 ; CHECK-NEXT: .section .rodata,"a",@progbits | |
24 ; CHECK-NEXT: .align 4 | |
25 ; CHECK-NEXT: PrimitiveInitConst: | |
26 ; CHECK-NEXT: .byte | |
27 ; CHECK: .size PrimitiveInitConst, 4 | |
28 | 12 |
29 @ArrayInit = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\1E\00\00\00(\0
0\00\002\00\00\00", align 4 | 13 @ArrayInit = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\1E\00\00\00(\0
0\00\002\00\00\00", align 4 |
30 ; CHECK: .type ArrayInit,@object | 14 ; CHECK-NEXT: @ArrayInit = internal global [20 x i8] c"\0A\00\00\00\14\00\00\00\
1E\00\00\00(\00\00\002\00\00\00", align 4 |
31 ; CHECK-NEXT: .section .data,"aw",@progbits | |
32 ; CHECK-NEXT: .align 4 | |
33 ; CHECK-NEXT: ArrayInit: | |
34 ; CHECK-NEXT: .byte | |
35 ; CHECK: .size ArrayInit, 20 | |
36 | 15 |
37 @ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\00P\00\00\00Z\
00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00",
align 4 | 16 @ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\00P\00\00\00Z\
00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00",
align 4 |
38 ; CHECK: .type ArrayInitPartial,@object | 17 ; CHECK-NEXT: @ArrayInitPartial = internal global [40 x i8] c"<\00\00\00F\00\00\
00P\00\00\00Z\00\00\00d\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00
\00\00\00\00", align 4 |
39 ; CHECK-NEXT: .section .data,"aw",@progbits | |
40 ; CHECK-NEXT: .align 4 | |
41 ; CHECK-NEXT: ArrayInitPartial: | |
42 ; CHECK-NEXT: .byte | |
43 ; CHECK: .size ArrayInitPartial, 40 | |
44 | 18 |
45 @PrimitiveInitStatic = internal global [4 x i8] zeroinitializer, align 4 | 19 @PrimitiveInitStatic = internal global [4 x i8] zeroinitializer, align 4 |
46 ; CHECK: .type PrimitiveInitStatic,@object | 20 ; CHECK-NEXT: @PrimitiveInitStatic = internal global [4 x i8] zeroinitializer, a
lign 4 |
47 ; CHECK-NEXT: .local PrimitiveInitStatic | |
48 ; CHECK-NEXT: .comm PrimitiveInitStatic,4,4 | |
49 | 21 |
50 @PrimitiveUninit = internal global [4 x i8] zeroinitializer, align 4 | 22 @PrimitiveUninit = internal global [4 x i8] zeroinitializer, align 4 |
51 ; CHECK: .type PrimitiveUninit,@object | 23 ; CHECK-NEXT: @PrimitiveUninit = internal global [4 x i8] zeroinitializer, align
4 |
52 ; CHECK-NEXT: .local PrimitiveUninit | |
53 ; CHECK-NEXT: .comm PrimitiveUninit,4,4 | |
54 | 24 |
55 @ArrayUninit = internal global [20 x i8] zeroinitializer, align 4 | 25 @ArrayUninit = internal global [20 x i8] zeroinitializer, align 4 |
56 ; CHECK: .type ArrayUninit,@object | 26 ; CHECK-NEXT: @ArrayUninit = internal global [20 x i8] zeroinitializer, align 4 |
57 ; CHECK-NEXT: .local ArrayUninit | |
58 ; CHECK-NEXT: .comm ArrayUninit,20,4 | |
59 | 27 |
60 @ArrayUninitConstDouble = internal constant [200 x i8] zeroinitializer, align 8 | 28 @ArrayUninitConstDouble = internal constant [200 x i8] zeroinitializer, align 8 |
61 ; CHECK: .type ArrayUninitConstDouble,@object | 29 ; CHECK-NEXT: @ArrayUninitConstDouble = internal constant [200 x i8] zeroinitial
izer, align 8 |
62 ; CHECK-NEXT: .section .rodata,"a",@progbits | |
63 ; CHECK-NEXT: .align 8 | |
64 ; CHECK-NEXT: ArrayUninitConstDouble: | |
65 ; CHECK-NEXT: .zero 200 | |
66 ; CHECK-NEXT: .size ArrayUninitConstDouble, 200 | |
67 | 30 |
68 @ArrayUninitConstInt = internal constant [20 x i8] zeroinitializer, align 4 | 31 @ArrayUninitConstInt = internal constant [20 x i8] zeroinitializer, align 4 |
69 ; CHECK: .type ArrayUninitConstInt,@object | 32 ; CHECK-NEXT: @ArrayUninitConstInt = internal constant [20 x i8] zeroinitializer
, align 4 |
70 ; CHECK: .section .rodata,"a",@progbits | |
71 ; CHECK-NEXT: .align 4 | |
72 ; CHECK-NEXT: ArrayUninitConstInt: | |
73 ; CHECK-NEXT: .zero 20 | |
74 ; CHECK-NEXT: .size ArrayUninitConstInt, 20 | |
75 | 33 |
76 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 34 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 35 ; CHECK-NEXT: @__init_array_start = internal constant [0 x i8] zeroinitializer,
align 4 |
| 36 |
77 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 | 37 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4 |
| 38 ; CHECK: @__fini_array_start = internal constant [0 x i8] zeroinitializer, align
4 |
| 39 |
78 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 | 40 @__tls_template_start = internal constant [0 x i8] zeroinitializer, align 8 |
| 41 ; CHECK: @__tls_template_start = internal constant [0 x i8] zeroinitializer, ali
gn 8 |
| 42 |
79 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 | 43 @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00", align 4 |
| 44 ; CHECK: @__tls_template_alignment = internal constant [4 x i8] c"\01\00\00\00",
align 4 |
80 | 45 |
81 define internal i32 @main(i32 %argc, i32 %argv) { | 46 define internal i32 @main(i32 %argc, i32 %argv) { |
82 entry: | 47 entry: |
83 %expanded1 = ptrtoint [4 x i8]* @PrimitiveInit to i32 | 48 %expanded1 = ptrtoint [4 x i8]* @PrimitiveInit to i32 |
84 call void @use(i32 %expanded1) | 49 call void @use(i32 %expanded1) |
85 %expanded3 = ptrtoint [4 x i8]* @PrimitiveInitConst to i32 | 50 %expanded3 = ptrtoint [4 x i8]* @PrimitiveInitConst to i32 |
86 call void @use(i32 %expanded3) | 51 call void @use(i32 %expanded3) |
87 %expanded5 = ptrtoint [4 x i8]* @PrimitiveInitStatic to i32 | 52 %expanded5 = ptrtoint [4 x i8]* @PrimitiveInitStatic to i32 |
88 call void @use(i32 %expanded5) | 53 call void @use(i32 %expanded5) |
89 %expanded7 = ptrtoint [4 x i8]* @PrimitiveUninit to i32 | 54 %expanded7 = ptrtoint [4 x i8]* @PrimitiveUninit to i32 |
90 call void @use(i32 %expanded7) | 55 call void @use(i32 %expanded7) |
91 %expanded9 = ptrtoint [20 x i8]* @ArrayInit to i32 | 56 %expanded9 = ptrtoint [20 x i8]* @ArrayInit to i32 |
92 call void @use(i32 %expanded9) | 57 call void @use(i32 %expanded9) |
93 %expanded11 = ptrtoint [40 x i8]* @ArrayInitPartial to i32 | 58 %expanded11 = ptrtoint [40 x i8]* @ArrayInitPartial to i32 |
94 call void @use(i32 %expanded11) | 59 call void @use(i32 %expanded11) |
95 %expanded13 = ptrtoint [20 x i8]* @ArrayUninit to i32 | 60 %expanded13 = ptrtoint [20 x i8]* @ArrayUninit to i32 |
96 call void @use(i32 %expanded13) | 61 call void @use(i32 %expanded13) |
97 ret i32 0 | 62 ret i32 0 |
98 } | 63 } |
99 ; CHECK-LABEL: main | |
100 ; CHECK: .att_syntax | |
101 ; CHECK: leal PrimitiveInit, | |
102 ; CHECK: .intel_syntax | |
103 ; CHECK: .att_syntax | |
104 ; CHECK: leal PrimitiveInitConst, | |
105 ; CHECK: .intel_syntax | |
106 ; CHECK: .att_syntax | |
107 ; CHECK: leal PrimitiveInitStatic, | |
108 ; CHECK: .intel_syntax | |
109 ; CHECK: .att_syntax | |
110 ; CHECK: leal PrimitiveUninit, | |
111 ; CHECK: .intel_syntax | |
112 ; CHECK: .att_syntax | |
113 ; CHECK: leal ArrayInit, | |
114 ; CHECK: .intel_syntax | |
115 ; CHECK: .att_syntax | |
116 ; CHECK: leal ArrayInitPartial, | |
117 ; CHECK: .intel_syntax | |
118 ; CHECK: .att_syntax | |
119 ; CHECK: leal ArrayUninit, | |
120 ; CHECK: .intel_syntax | |
121 | 64 |
122 declare void @use(i32) | 65 declare void @use(i32) |
123 | 66 |
124 define internal i32 @nacl_tp_tdb_offset(i32 %__0) { | 67 define internal i32 @nacl_tp_tdb_offset(i32 %__0) { |
125 entry: | 68 entry: |
126 ret i32 0 | 69 ret i32 0 |
127 } | 70 } |
128 | 71 |
129 define internal i32 @nacl_tp_tls_offset(i32 %size) { | 72 define internal i32 @nacl_tp_tls_offset(i32 %size) { |
130 entry: | 73 entry: |
131 %result = sub i32 0, %size | 74 %result = sub i32 0, %size |
132 ret i32 %result | 75 ret i32 %result |
133 } | 76 } |
134 | 77 |
135 ; ERRORS-NOT: ICE translation error | 78 ; ERRORS-NOT: ICE translation error |
OLD | NEW |