Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/llvm-intrinsics/memcpy.align.ll

raw
1 ;
2 ;struct B {
3 ; int b[2];
4 ;};
5 ;
6 ;struct A {
7 ; long l;
8 ; struct B b;
9 ;};
10 ;
11 ;struct A foo()
12 ;{
13 ; struct B b = { 1,2 };
14 ; struct A a;
15 ; a.b = b;
16 ; return a;
17 ;}
18 ;
19 ;struct B bar()
20 ;{
21 ; struct A a = {0,{ 1,2 }};
22 ; struct B b = a.b;
23 ; return b;
24 ;}
25 ; clang -cc1 -triple spir -disable-llvm-passes t.cl -emit-llvm -o t.ll
26
27 ; RUN: llvm-as %s -o %t.bc
28 ; RUN: llvm-spirv %t.bc --spirv-max-version=1.3 -spirv-text -o %t.txt
29 ; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
30 ; RUN: llvm-spirv %t.bc --spirv-max-version=1.3 -o %t.spv
31 ; RUN: spirv-val %t.spv
32 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
33 ; RUN: llvm-dis %t.rev.bc
34 ; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
35
36 ; RUN: llvm-spirv %t.bc --spirv-max-version=1.4 -spirv-text -o %t.txt
37 ; RUN: FileCheck < %t.txt %s --check-prefix=ALIGN-MATCH-SPIRV
38 ; RUN: llvm-spirv %t.bc --spirv-max-version=1.4 -o %t.spv
39 ; RUN: spirv-val %t.spv
40 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
41 ; RUN: llvm-dis %t.rev.bc
42 ; RUN: FileCheck < %t.rev.ll %s --check-prefix=ALIGN-MATCH-LLVM
43
44 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"
45 target triple = "spir"
46
47 %struct.B = type { [2 x i32] }
48 %struct.A = type { i64, %struct.B }
49
50 @__const.foo.b = private unnamed_addr addrspace(2) constant %struct.B { [2 x i32] [i32 1, i32 2] }, align 4
51 @__const.bar.a = private unnamed_addr addrspace(2) constant %struct.A { i64 0, %struct.B { [2 x i32] [i32 1, i32 2] } }, align 8
52
53 ; Function Attrs: convergent nounwind
54 define spir_func void @foo(%struct.A* noalias sret(%struct.A) %agg.result) #0 {
55 entry:
56 %b = alloca %struct.B, align 4
57 %0 = bitcast %struct.B* %b to i8*
58 call void @llvm.lifetime.start.p0i8(i64 8, i8* %0) #2
59 %1 = bitcast %struct.B* %b to i8*
60 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)
61 ; CHECK-SPIRV: InBoundsPtrAccessChain
62 %b1 = getelementptr inbounds %struct.A, %struct.A* %agg.result, i32 0, i32 1
63 %2 = bitcast %struct.B* %b1 to i8*
64 %3 = bitcast %struct.B* %b to i8*
65 ; CHECK-SPIRV: CopyMemorySized {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} 2 4
66 ; CHECK-LLVM: call void @llvm.memcpy.p0.p0.i32(ptr align 4 {{%[0-9]+}}, ptr align 4 {{%[0-9]+}}, i32 8, i1 false)
67 ; ALIGN-MATCH-SPIRV: CopyMemorySized {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} 2 8 2 4
68 ; ALIGN-MATCH-LLVM: call void @llvm.memcpy.p0.p0.i32(ptr align 8 {{%[0-9]+}}, ptr align 4 {{%[0-9]+}}, i32 8, i1 false)
69 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %2, i8* align 4 %3, i32 8, i1 false), !tbaa.struct !4
70 %4 = bitcast %struct.B* %b to i8*
71 call void @llvm.lifetime.end.p0i8(i64 8, i8* %4) #2
72 ret void
73 }
74
75 ; Function Attrs: argmemonly nounwind
76 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
77
78 ; Function Attrs: argmemonly nounwind
79 declare void @llvm.memcpy.p0i8.p2i8.i32(i8* nocapture writeonly, i8 addrspace(2)* nocapture readonly, i32, i1) #1
80
81 ; Function Attrs: argmemonly nounwind
82 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1) #1
83
84 ; Function Attrs: argmemonly nounwind
85 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
86
87 ; Function Attrs: convergent nounwind
88 define spir_func void @bar(%struct.B* noalias sret(%struct.B) %agg.result) #0 {
89 entry:
90 %a = alloca %struct.A, align 8
91 %0 = bitcast %struct.A* %a to i8*
92 call void @llvm.lifetime.start.p0i8(i64 16, i8* %0) #2
93 %1 = bitcast %struct.A* %a to i8*
94 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)
95 ; CHECK-SPIRV: InBoundsPtrAccessChain
96 %b = getelementptr inbounds %struct.A, %struct.A* %a, i32 0, i32 1
97 %2 = bitcast %struct.B* %agg.result to i8*
98 %3 = bitcast %struct.B* %b to i8*
99 ; CHECK-SPIRV: CopyMemorySized {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} 2 4
100 ; CHECK-LLVM: call void @llvm.memcpy.p0.p0.i32(ptr align 4 {{%[0-9]+}}, ptr align 4 {{%[0-9]+}}, i32 8, i1 false)
101 ; ALIGN-MATCH-SPIRV: CopyMemorySized {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} 2 4 2 8
102 ; ALIGN-MATCH-LLVM: call void @llvm.memcpy.p0.p0.i32(ptr align 4 {{%[0-9]+}}, ptr align 8 {{%[0-9]+}}, i32 8, i1 false)
103 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %2, i8* align 8 %3, i32 8, i1 false), !tbaa.struct !4
104 %4 = bitcast %struct.A* %a to i8*
105 call void @llvm.lifetime.end.p0i8(i64 16, i8* %4) #2
106 ret void
107 }
108
109 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" }
110 attributes #1 = { argmemonly nounwind }
111 attributes #2 = { nounwind }
112
113 !llvm.module.flags = !{!0}
114 !opencl.ocl.version = !{!1}
115 !opencl.spir.version = !{!2}
116 !llvm.ident = !{!3}
117
118 !0 = !{i32 1, !"wchar_size", i32 4}
119 !1 = !{i32 1, i32 0}
120 !2 = !{i32 1, i32 2}
121 !3 = !{!"clang version 9.0.0"}
122 !4 = !{i64 0, i64 8, !5}
123 !5 = !{!6, !6, i64 0}
124 !6 = !{!"omnipotent char", !7, i64 0}
125 !7 = !{!"Simple C/C++ TBAA"}