22
22
define void @call_test_byval_1Byte () {
23
23
entry:
24
24
%s0 = alloca %struct.S0 , align 8
25
- call void @test_byval_1Byte (%struct.S0* byval (%struct.S0 ) align 1 %s0 , %struct.S1* byval (%struct.S1 ) align 1 @gS1 )
25
+ % call = call zeroext i8 @test_byval_1Byte (%struct.S0* byval (%struct.S0 ) align 1 %s0 , %struct.S1* byval (%struct.S1 ) align 1 @gS1 )
26
26
ret void
27
27
}
28
28
29
- declare void @test_byval_1Byte (%struct.S0* byval (%struct.S0 ) align 1 , %struct.S1* byval (%struct.S1 ) align 1 )
30
29
31
30
; CHECK-LABEL: name: call_test_byval_1Byte{{.*}}
32
31
@@ -63,18 +62,59 @@ declare void @test_byval_1Byte(%struct.S0* byval(%struct.S0) align 1, %struct.S1
63
62
; ASM64-NEXT: nop
64
63
; ASM64-NEXT: addi 1, 1, 128
65
64
65
+
66
+ define zeroext i8 @test_byval_1Byte (%struct.S0* byval (%struct.S0 ) align 1 %s0 , %struct.S1* byval (%struct.S1 ) align 1 %s ) {
67
+ entry:
68
+ %arrayidx = getelementptr inbounds %struct.S1 , %struct.S1* %s , i32 0 , i32 0 , i32 0
69
+ %0 = load i8 , i8* %arrayidx , align 1
70
+ ret i8 %0
71
+ }
72
+
73
+ ; CHECK-LABEL: name: test_byval_1Byte
74
+
75
+ ; 32BIT: fixedStack:
76
+ ; 32BIT-NEXT: - { id: 0, type: default, offset: 24, size: 4, alignment: 8, stack-id: default,
77
+ ; 32BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
78
+ ; 32BIT: - { id: 1, type: default, offset: 24, size: 4, alignment: 8, stack-id: default,
79
+ ; 32BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
80
+
81
+ ; 32BIT: bb.0.entry:
82
+ ; 32BIT-NEXT: liveins: $r3
83
+ ; 32BIT: STW killed renamable $r3, 0, %fixed-stack.0 :: (store 4 into %fixed-stack.0, align 8)
84
+ ; 32BIT-NEXT: renamable $r3 = LBZ 0, %fixed-stack.0 :: (dereferenceable load 1
85
+ ; 32BIT-NEXT: BLR
86
+
87
+ ; 64BIT: fixedStack:
88
+ ; 64BIT-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16, stack-id: default,
89
+ ; 64BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
90
+ ; 64BIT: - { id: 1, type: default, offset: 48, size: 8, alignment: 16, stack-id: default,
91
+ ; 64BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
92
+
93
+ ; 64BIT: bb.0.entry:
94
+ ; 64BIT-NEXT: liveins: $x3
95
+ ; 64BIT: STD killed renamable $x3, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0, align 16)
96
+ ; 64BIT-NEXT: renamable $x3 = LBZ8 0, %fixed-stack.0 :: (dereferenceable load 1
97
+
98
+ ; CHECKASM-LABEL: .test_byval_1Byte:
99
+
100
+ ; ASM32: stw 3, 24(1)
101
+ ; ASM32-NEXT: lbz 3, 24(1)
102
+ ; ASM32-NEXT: blr
103
+
104
+ ; ASM64: std 3, 48(1)
105
+ ; ASM64-NEXT: lbz 3, 48(1)
106
+ ; ASM64-NEXT: blr
107
+
66
108
%struct.S2 = type { [2 x i8 ] }
67
109
68
110
@gS2 = external global %struct.S2 , align 1
69
111
70
112
define void @call_test_byval_2Byte () {
71
113
entry:
72
- call void @test_byval_2Byte (%struct.S2* byval (%struct.S2 ) align 1 @gS2 )
114
+ % call = call zeroext i8 @test_byval_2Byte (%struct.S2* byval (%struct.S2 ) align 1 @gS2 )
73
115
ret void
74
116
}
75
117
76
- declare void @test_byval_2Byte (%struct.S2* byval (%struct.S2 ) align 1 )
77
-
78
118
; CHECK-LABEL: name: call_test_byval_2Byte{{.*}}
79
119
80
120
; 32BIT: ADJCALLSTACKDOWN 56, 0, implicit-def dead $r1, implicit $r1
@@ -110,18 +150,51 @@ declare void @test_byval_2Byte(%struct.S2* byval(%struct.S2) align 1)
110
150
; ASM64-NEXT: nop
111
151
; ASM64-NEXT: addi 1, 1, 112
112
152
113
- %struct.S3 = type <{ i8 , i16 }>
114
153
154
+ define zeroext i8 @test_byval_2Byte (%struct.S2* byval (%struct.S2 ) align 1 %s ) {
155
+ entry:
156
+ %arrayidx = getelementptr inbounds %struct.S2 , %struct.S2* %s , i32 0 , i32 0 , i32 1
157
+ %0 = load i8 , i8* %arrayidx , align 1
158
+ ret i8 %0
159
+ }
160
+
161
+ ; CHECK-LABEL: name: test_byval_2Byte
162
+ ; 32BIT: fixedStack:
163
+ ; 32BIT-NEXT: - { id: 0, type: default, offset: 24, size: 4, alignment: 8, stack-id: default,
164
+
165
+ ; 32BIT: bb.0.entry:
166
+ ; 32BIT-NEXT: liveins: $r3
167
+ ; 32BIT: STW killed renamable $r3, 0, %fixed-stack.0 :: (store 4 into %fixed-stack.0, align 8)
168
+ ; 32BIT-NEXT: renamable $r3 = LBZ 1, %fixed-stack.0 :: (dereferenceable load 1
169
+
170
+ ; 64BIT: fixedStack:
171
+ ; 64BIT-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16, stack-id: default,
172
+
173
+ ; 64BIT: bb.0.entry:
174
+ ; 64BIT-NEXT: liveins: $x3
175
+ ; 64BIT: STD killed renamable $x3, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0, align 16)
176
+ ; 64BIT-NEXT: renamable $x3 = LBZ8 1, %fixed-stack.0 :: (dereferenceable load 1
177
+
178
+ ; CHECKASM-LABEL: .test_byval_2Byte:
179
+
180
+ ; ASM32: stw 3, 24(1)
181
+ ; ASM32-NEXT: lbz 3, 25(1)
182
+ ; ASM32-NEXT: blr
183
+
184
+ ; ASM64: std 3, 48(1)
185
+ ; ASM64-NEXT: lbz 3, 49(1)
186
+ ; ASM64-NEXT: blr
187
+
188
+
189
+ %struct.S3 = type <{ i8 , i16 }>
115
190
@gS3 = external global %struct.S3 , align 1
116
191
117
192
define void @call_test_byval_3Byte () {
118
193
entry:
119
- call void @test_byval_3Byte (%struct.S3* byval (%struct.S3 ) align 1 @gS3 )
194
+ % call = call zeroext i16 @test_byval_3Byte (%struct.S3* byval (%struct.S3 ) align 1 @gS3 )
120
195
ret void
121
196
}
122
197
123
- declare void @test_byval_3Byte (%struct.S3* byval (%struct.S3 ) align 1 )
124
-
125
198
; CHECK-LABEL: name: call_test_byval_3Byte{{.*}}
126
199
127
200
; The DAG block permits some invalid inputs for the benefit of allowing more valid orderings.
@@ -166,6 +239,44 @@ declare void @test_byval_3Byte(%struct.S3* byval(%struct.S3) align 1)
166
239
; ASM64-NEXT: bl .test_byval_3Byte
167
240
; ASM64-NEXT: nop
168
241
242
+
243
+ define zeroext i16 @test_byval_3Byte (%struct.S3* byval (%struct.S3 ) align 1 %s ) {
244
+ entry:
245
+ %gep = getelementptr inbounds %struct.S3 , %struct.S3* %s , i32 0 , i32 1
246
+ %0 = load i16 , i16* %gep , align 1
247
+ ret i16 %0
248
+ }
249
+
250
+ ; CHECK-LABEL: name: test_byval_3Byte
251
+
252
+ ; 32BIT: fixedStack:
253
+ ; 32BIT-NEXT: - { id: 0, type: default, offset: 24, size: 4, alignment: 8, stack-id: default,
254
+
255
+ ; 32BIT: bb.0.entry:
256
+ ; 32BIT-NEXT: liveins: $r3
257
+ ; 32BIT: STW killed renamable $r3, 0, %fixed-stack.0 :: (store 4 into %fixed-stack.0, align 8)
258
+ ; 32BIT-NEXT: renamable $r3 = LHZ 1, %fixed-stack.0 :: (dereferenceable load 2
259
+
260
+ ; 64BIT: fixedStack:
261
+ ; 64BIT-NEXT: - { id: 0, type: default, offset: 48, size: 8, alignment: 16, stack-id: default,
262
+
263
+ ; 64BIT: bb.0.entry:
264
+ ; 64BIT-NEXT: liveins: $x3
265
+ ; 64BIT: STD killed renamable $x3, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0, align 16)
266
+ ; 64BIT-NEXT: renamable $x3 = LHZ8 1, %fixed-stack.0 :: (dereferenceable load 2
267
+
268
+
269
+ ; CHECKASM-LABEL: .test_byval_3Byte:
270
+
271
+ ; ASM32: stw 3, 24(1)
272
+ ; ASM32-NEXT: lhz 3, 25(1)
273
+ ; ASM32-NEXT: blr
274
+
275
+ ; ASM64: std 3, 48(1)
276
+ ; ASM64-NEXT: lhz 3, 49(1)
277
+ ; ASM64-NEXT: blr
278
+
279
+
169
280
%struct.S4 = type { [4 x i8 ] }
170
281
%struct.S4A = type { i32 }
171
282
@@ -175,12 +286,10 @@ define void @call_test_byval_4Byte() {
175
286
entry:
176
287
%s0 = alloca %struct.S0 , align 8
177
288
%s4a = alloca %struct.S4A , align 4
178
- call void @test_byval_4Byte (%struct.S4* byval (%struct.S4 ) align 1 @gS4 , %struct.S0* byval (%struct.S0 ) align 1 %s0 , %struct.S4A* byval (%struct.S4A ) align 4 %s4a )
289
+ % call = call signext i32 @test_byval_4Byte (%struct.S4* byval (%struct.S4 ) align 1 @gS4 , %struct.S0* byval (%struct.S0 ) align 1 %s0 , %struct.S4A* byval (%struct.S4A ) align 4 %s4a )
179
290
ret void
180
291
}
181
292
182
- declare void @test_byval_4Byte (%struct.S4* byval (%struct.S4 ) align 1 , %struct.S0* byval (%struct.S0 ) align 1 , %struct.S4A* byval (%struct.S4A ) align 4 )
183
-
184
293
; CHECK-LABEL: name: call_test_byval_4Byte{{.*}}
185
294
186
295
; 32BIT: ADJCALLSTACKDOWN 56, 0, implicit-def dead $r1, implicit $r1
@@ -219,3 +328,66 @@ declare void @test_byval_4Byte(%struct.S4* byval(%struct.S4) align 1, %struct.S0
219
328
; ASM64-NEXT: nop
220
329
; ASM64-NEXT: addi 1, 1, 128
221
330
331
+
332
+ define signext i32 @test_byval_4Byte (%struct.S4* byval (%struct.S4 ) align 1 %s , %struct.S0* byval (%struct.S0 ) align 1 , %struct.S4A* byval (%struct.S4A ) align 4 %s4a ) {
333
+ entry:
334
+ %arrayidx = getelementptr inbounds %struct.S4 , %struct.S4* %s , i32 0 , i32 0 , i32 3
335
+ %gep = getelementptr inbounds %struct.S4A , %struct.S4A* %s4a , i32 0 , i32 0
336
+ %1 = load i8 , i8* %arrayidx , align 1
337
+ %2 = load i32 , i32* %gep , align 4
338
+ %conv = zext i8 %1 to i32
339
+ %add = add nsw i32 %2 , %conv
340
+ ret i32 %add
341
+ }
342
+
343
+ ; CHECK-LABEL: name: test_byval_4Byte
344
+
345
+ ; 32BIT: fixedStack:
346
+ ; 32BIT-NEXT: - { id: 0, type: default, offset: 28, size: 4, alignment: 4, stack-id: default,
347
+ ; 32BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
348
+ ; 32BIT: - { id: 1, type: default, offset: 28, size: 4, alignment: 4, stack-id: default,
349
+ ; 32BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
350
+ ; 32BIT: - { id: 2, type: default, offset: 24, size: 4, alignment: 8, stack-id: default,
351
+ ; 32BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
352
+
353
+ ; 32BIT: bb.0.entry:
354
+ ; 32BIT-NEXT: liveins: $r3
355
+ ; 32BIT: STW renamable $r3, 0, %fixed-stack.2 :: (store 4 into %fixed-stack.2, align 8)
356
+ ; 32BIT-DAG: STW killed renamable $r4, 0, %fixed-stack.0 :: (store 4 into %fixed-stack.0)
357
+ ; 32BIT-DAG: renamable $r[[SCRATCH:[0-9]+]] = RLWINM killed renamable $r3, 0, 24, 31
358
+ ; 32BIT-DAG: renamable $r3 = nsw ADD4 renamable $r4, killed renamable $r[[SCRATCH]]
359
+ ; 32BIT: BLR
360
+
361
+ ; 64BIT: fixedStack:
362
+ ; 64BIT-NEXT: - { id: 0, type: default, offset: 56, size: 8, alignment: 8, stack-id: default,
363
+ ; 64BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
364
+ ; 64BIT: - { id: 1, type: default, offset: 56, size: 8, alignment: 8, stack-id: default,
365
+ ; 64BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
366
+ ; 64BIT: - { id: 2, type: default, offset: 48, size: 8, alignment: 16, stack-id: default,
367
+ ; 64BIT-NEXT: isImmutable: false, isAliased: true, callee-saved-register: '', callee-saved-restored: true,
368
+
369
+ ; 64BIT: bb.0.entry:
370
+ ; 64BIT-NEXT: liveins: $x3
371
+ ; 64BIT: STD killed renamable $x3, 0, %fixed-stack.2 :: (store 8 into %fixed-stack.2, align 16)
372
+ ; 64BIT-NEXT: STD killed renamable $x4, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0)
373
+ ; 64BIT-DAG: renamable $r[[SCRATCH1:[0-9]+]] = LBZ 3, %fixed-stack.2 :: (dereferenceable load 1
374
+ ; 64BIT-DAG: renamable $r[[SCRATCH2:[0-9]+]] = LWZ 0, %fixed-stack.0 :: (dereferenceable load 4
375
+ ; 64BIT-NEXT: renamable $r[[SCRATCH3:[0-9]+]] = nsw ADD4 killed renamable $r[[SCRATCH2]], killed renamable $r[[SCRATCH1]]
376
+ ; 64BIT-NEXT: renamable $x3 = EXTSW_32_64 killed renamable $r[[SCRATCH3]]
377
+ ; 64BIT-NEXT: BLR8
378
+
379
+ ; CHECKASM-LABEL: .test_byval_4Byte:
380
+
381
+ ; ASM32: stw 3, 24(1)
382
+ ; ASM32-DAG: stw 4, 28(1)
383
+ ; ASM32-DAG: clrlwi [[SCRATCH:[0-9]+]], 3, 24
384
+ ; ASM32-DAG: add 3, 4, [[SCRATCH]]
385
+ ; ASM32-NEXT: blr
386
+
387
+ ; ASM64: std 3, 48(1)
388
+ ; ASM64-NEXT: std 4, 56(1)
389
+ ; ASM64-DAG: lbz [[SCRATCH1:[0-9]+]], 51(1)
390
+ ; ASM64-DAG: lwz [[SCRATCH2:[0-9]+]], 56(1)
391
+ ; ASM64-NEXT: add [[SCRATCH3:[0-9]+]], [[SCRATCH2]], [[SCRATCH1]]
392
+ ; ASM64-NEXT: extsw 3, [[SCRATCH3]]
393
+ ; ASM64-NEXT: blr
0 commit comments