• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt | FileCheck %s
2
3; Test that globals assemble as expected.
4
5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8; CHECK-NOT: llvm.used
9; CHECK-NOT: llvm.metadata
10@llvm.used = appending global [1 x i32*] [i32* @g], section "llvm.metadata"
11
12; CHECK: foo:
13; CHECK: i32.const $push0=, 0{{$}}
14; CHECK-NEXT: i32.load $push1=, answer($pop0){{$}}
15; CHECK-NEXT: return $pop1{{$}}
16define i32 @foo() {
17  %a = load i32, i32* @answer
18  ret i32 %a
19}
20
21; CHECK-LABEL: call_memcpy:
22; CHECK-NEXT: .param          i32, i32, i32{{$}}
23; CHECK-NEXT: .result         i32{{$}}
24; CHECK-NEXT: i32.call        $push0=, memcpy@FUNCTION, $0, $1, $2{{$}}
25; CHECK-NEXT: return          $pop0{{$}}
26declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1)
27define i8* @call_memcpy(i8* %p, i8* nocapture readonly %q, i32 %n) {
28  tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %p, i8* %q, i32 %n, i32 1, i1 false)
29  ret i8* %p
30}
31
32; CHECK: .type   .Lg,@object
33; CHECK: .p2align  2{{$}}
34; CHECK-NEXT: .Lg:
35; CHECK-NEXT: .int32 1337{{$}}
36; CHECK-NEXT: .size .Lg, 4{{$}}
37@g = private global i32 1337
38
39; CHECK-LABEL: ud:
40; CHECK-NEXT: .skip 4{{$}}
41; CHECK-NEXT: .size ud, 4{{$}}
42@ud = internal global i32 undef
43
44; CHECK: .type nil,@object
45; CHECK-NEXT: .lcomm nil,4,2{{$}}
46@nil = internal global i32 zeroinitializer
47
48; CHECK: .type z,@object
49; CHECK-NEXT: .lcomm z,4,2{{$}}
50@z = internal global i32 0
51
52; CHECK-NEXT: .type one,@object
53; CHECK-NEXT: .p2align 2{{$}}
54; CHECK-NEXT: one:
55; CHECK-NEXT: .int32 1{{$}}
56; CHECK-NEXT: .size one, 4{{$}}
57@one = internal global i32 1
58
59; CHECK: .type answer,@object
60; CHECK: .p2align 2{{$}}
61; CHECK-NEXT: answer:
62; CHECK-NEXT: .int32 42{{$}}
63; CHECK-NEXT: .size answer, 4{{$}}
64@answer = internal global i32 42
65
66; CHECK: .type u32max,@object
67; CHECK: .p2align 2{{$}}
68; CHECK-NEXT: u32max:
69; CHECK-NEXT: .int32 4294967295{{$}}
70; CHECK-NEXT: .size u32max, 4{{$}}
71@u32max = internal global i32 -1
72
73; CHECK: .type ud64,@object
74; CHECK: .p2align 3{{$}}
75; CHECK-NEXT: ud64:
76; CHECK-NEXT: .skip 8{{$}}
77; CHECK-NEXT: .size ud64, 8{{$}}
78@ud64 = internal global i64 undef
79
80; CHECK: .type nil64,@object
81; CHECK: .lcomm nil64,8,3{{$}}
82@nil64 = internal global i64 zeroinitializer
83
84; CHECK: .type z64,@object
85; CHECK: .lcomm z64,8,3{{$}}
86@z64 = internal global i64 0
87
88; CHECK: .type twoP32,@object
89; CHECK: .p2align 3{{$}}
90; CHECK-NEXT: twoP32:
91; CHECK-NEXT: .int64 4294967296{{$}}
92; CHECK-NEXT: .size twoP32, 8{{$}}
93@twoP32 = internal global i64 4294967296
94
95; CHECK: .type u64max,@object
96; CHECK: .p2align 3{{$}}
97; CHECK-NEXT: u64max:
98; CHECK-NEXT: .int64 -1{{$}}
99; CHECK-NEXT: .size u64max, 8{{$}}
100@u64max = internal global i64 -1
101
102; CHECK: .type f32ud,@object
103; CHECK: .p2align 2{{$}}
104; CHECK-NEXT: f32ud:
105; CHECK-NEXT: .skip 4{{$}}
106; CHECK-NEXT: .size f32ud, 4{{$}}
107@f32ud = internal global float undef
108
109; CHECK: .type f32nil,@object
110; CHECK: .lcomm f32nil,4,2{{$}}
111@f32nil = internal global float zeroinitializer
112
113; CHECK: .type f32z,@object
114; CHECK: .lcomm f32z,4,2{{$}}
115@f32z = internal global float 0.0
116
117; CHECK: .type f32nz,@object
118; CHECK: .p2align 2{{$}}
119; CHECK: f32nz:
120; CHECK: .int32 2147483648{{$}}
121; CHECK: .size f32nz, 4{{$}}
122@f32nz = internal global float -0.0
123
124; CHECK: .type f32two,@object
125; CHECK: .p2align 2{{$}}
126; CHECK-NEXT: f32two:
127; CHECK-NEXT: .int32 1073741824{{$}}
128; CHECK-NEXT: .size f32two, 4{{$}}
129@f32two = internal global float 2.0
130
131; CHECK: .type f64ud,@object
132; CHECK: .p2align 3{{$}}
133; CHECK-NEXT: f64ud:
134; CHECK-NEXT: .skip 8{{$}}
135; CHECK-NEXT: .size f64ud, 8{{$}}
136@f64ud = internal global double undef
137
138; CHECK: .type f64nil,@object
139; CHECK: .lcomm f64nil,8,3{{$}}
140@f64nil = internal global double zeroinitializer
141
142; CHECK: .type f64z,@object
143; CHECK: .lcomm f64z,8,3{{$}}
144@f64z = internal global double 0.0
145
146; CHECK: .type f64nz,@object
147; CHECK: .p2align 3{{$}}
148; CHECK-NEXT: f64nz:
149; CHECK-NEXT: .int64 -9223372036854775808{{$}}
150; CHECK-NEXT: .size f64nz, 8{{$}}
151@f64nz = internal global double -0.0
152
153; CHECK: .type f64two,@object
154; CHECK: .p2align 3{{$}}
155; CHECK-NEXT: f64two:
156; CHECK-NEXT: .int64 4611686018427387904{{$}}
157; CHECK-NEXT: .size f64two, 8{{$}}
158@f64two = internal global double 2.0
159
160; Indexing into a global array produces a relocation.
161; CHECK:      .type arr,@object
162; CHECK:      .type ptr,@object
163; CHECK:      ptr:
164; CHECK-NEXT: .int32 arr+80
165; CHECK-NEXT: .size ptr, 4
166@arr = global [128 x i32] zeroinitializer, align 16
167@ptr = global i32* getelementptr inbounds ([128 x i32], [128 x i32]* @arr, i32 0, i32 20), align 4
168
169; Constant global.
170; CHECK: .type    rom,@object{{$}}
171; CHECK: .section .rodata,"a",@progbits{{$}}
172; CHECK: .globl   rom{{$}}
173; CHECK: .p2align   4{{$}}
174; CHECK: rom:
175; CHECK: .skip    512{{$}}
176; CHECK: .size    rom, 512{{$}}
177@rom = constant [128 x i32] zeroinitializer, align 16
178
179; CHECK: .type       array,@object
180; CHECK-NEXT: array:
181; CHECK-NEXT: .skip       8
182; CHECK-NEXT: .size       array, 8
183; CHECK: .type       pointer_to_array,@object
184; CHECK-NEXT: .section    .data.rel.ro,"aw",@progbits
185; CHECK-NEXT: .globl      pointer_to_array
186; CHECK-NEXT: .p2align      2
187; CHECK-NEXT: pointer_to_array:
188; CHECK-NEXT: .int32      array+4
189; CHECK-NEXT: .size       pointer_to_array, 4
190@array = internal constant [8 x i8] zeroinitializer, align 1
191@pointer_to_array = constant i8* getelementptr inbounds ([8 x i8], [8 x i8]* @array, i32 0, i32 4), align 4
192