Skip to content

Commit 8d6d2f5

Browse files
committed
Test files for memcpy and ControlBarrier instruction
1 parent 37edd2c commit 8d6d2f5

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2+
3+
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
4+
target triple = "spir"
5+
6+
%struct.B = type { [2 x i32] }
7+
%struct.A = type { i64, %struct.B }
8+
9+
@__const.foo.b = private unnamed_addr addrspace(2) constant %struct.B { [2 x i32] [i32 1, i32 2] }, align 4
10+
@__const.bar.a = private unnamed_addr addrspace(2) constant %struct.A { i64 0, %struct.B { [2 x i32] [i32 1, i32 2] } }, align 8
11+
12+
; Function Attrs: convergent nounwind
13+
define spir_func void @foo(%struct.A* noalias sret(%struct.A) %agg.result) #0 {
14+
entry:
15+
%b = alloca %struct.B, align 4
16+
%0 = bitcast %struct.B* %b to i8*
17+
call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #2
18+
%1 = bitcast %struct.B* %b to i8*
19+
call void @llvm.memcpy.p0i8.p2i8.i32(i8* align 4 %1, i8 addrspace(2)* align 4 bitcast (%struct.B addrspace(2)* @__const.foo.b to i8 addrspace(2)*), i32 8, i1 false)
20+
; CHECK: OpCopyMemorySized %[[#]] %[[#]] %[[#]] Aligned 4
21+
%b1 = getelementptr inbounds %struct.A, %struct.A* %agg.result, i32 0, i32 1
22+
%2 = bitcast %struct.B* %b1 to i8*
23+
%3 = bitcast %struct.B* %b to i8*
24+
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %2, i8* align 4 %3, i32 8, i1 false), !tbaa.struct !4
25+
; CHECK: %[[#PTR1:]] = OpInBoundsPtrAccessChain %[[#]] %[[#]] %[[#]] %[[#]]
26+
; CHECK: OpCopyMemorySized %[[#PTR1]] %[[#]] %[[#]] Aligned 8
27+
%4 = bitcast %struct.B* %b to i8*
28+
call void @llvm.lifetime.end.p0i8(i64 8, i8* %4) #2
29+
ret void
30+
}
31+
32+
; Function Attrs: argmemonly nounwind
33+
declare void @llvm.lifetime.start.p0i8(i64, i8* captures(none)) #1
34+
35+
; Function Attrs: argmemonly nounwind
36+
declare void @llvm.memcpy.p0i8.p2i8.i32(i8* captures(none) writeonly, i8 addrspace(2)* captures(none) readonly, i32, i1) #1
37+
38+
; Function Attrs: argmemonly nounwind
39+
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* captures(none) writeonly, i8* captures(none) readonly, i32, i1) #1
40+
41+
; Function Attrs: argmemonly nounwind
42+
declare void @llvm.lifetime.end.p0i8(i64, i8* captures(none)) #1
43+
44+
; Function Attrs: convergent nounwind
45+
define spir_func void @bar(%struct.B* noalias sret(%struct.B) %agg.result) #0 {
46+
entry:
47+
%a = alloca %struct.A, align 8
48+
%0 = bitcast %struct.A* %a to i8*
49+
call void @llvm.lifetime.start.p0i8(i64 16, i8* %0) #2
50+
%1 = bitcast %struct.A* %a to i8*
51+
call void @llvm.memcpy.p0i8.p2i8.i32(i8* align 8 %1, i8 addrspace(2)* align 8 bitcast (%struct.A addrspace(2)* @__const.bar.a to i8 addrspace(2)*), i32 16, i1 false)
52+
; CHECK: OpCopyMemorySized %[[#]] %[[#]] %[[#]] Aligned 8
53+
%b = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 1
54+
%2 = bitcast %struct.B* %agg.result to i8*
55+
%3 = bitcast %struct.B* %b to i8*
56+
call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 8 %3, i32 8, i1 false), !tbaa.struct !4
57+
; CHECK: %[[#PTR2:]] = OpInBoundsPtrAccessChain %[[#]] %[[#]] %[[#]] %[[#]]
58+
; CHECK: OpCopyMemorySized %[[#]] %[[#PTR2]] %[[#]] Aligned 4
59+
%4 = bitcast %struct.A* %a to i8*
60+
call void @llvm.lifetime.end.p0i8(i64 16, i8* %4) #2
61+
ret void
62+
}
63+
64+
attributes #0 = { convergent nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "denorms-are-zero"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
65+
attributes #1 = { argmemonly nounwind }
66+
attributes #2 = { nounwind }
67+
68+
!llvm.module.flags = !{!0}
69+
!opencl.ocl.version = !{!1}
70+
!opencl.spir.version = !{!2}
71+
!llvm.ident = !{!3}
72+
73+
!0 = !{i32 1, !"wchar_size", i32 4}
74+
!1 = !{i32 1, i32 0}
75+
!2 = !{i32 1, i32 2}
76+
!3 = !{!"clang version 9.0.0"}
77+
!4 = !{i64 0, i64 8, !5}
78+
!5 = !{!6, !6, i64 0}
79+
!6 = !{!"omnipotent char", !7, i64 0}
80+
!7 = !{!"Simple C/C++ TBAA"}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
4+
; CHECK: %[[#SCOPE:]] = OpFunctionCall %[[#]] %[[#]]
5+
; CHECK: OpControlBarrier %[[#]] %[[#SCOPE]] %[[#]]
6+
7+
define spir_func void @_Z3foov() {
8+
%1 = call noundef i32 @_Z8getScopev()
9+
call void @_Z22__spirv_ControlBarrieriii(i32 noundef 3, i32 noundef %1, i32 noundef 912)
10+
ret void
11+
}
12+
13+
declare spir_func void @_Z22__spirv_ControlBarrieriii(i32 noundef, i32 noundef, i32 noundef)
14+
15+
declare spir_func i32 @_Z8getScopev()

0 commit comments

Comments
 (0)