xref: /llvm-project/llvm/test/CodeGen/BPF/struct-arg-inline.ll (revision 481d67d310a7a4213da72f838d6bafaa52ed01d3)
1*481d67d3SYonghong Song; RUN: opt -O2 -mtriple=bpf-pc-linux %s | llvm-dis > %t1
2*481d67d3SYonghong Song; RUN: llc %t1 -o - | FileCheck %s
3*481d67d3SYonghong Song; Source:
4*481d67d3SYonghong Song;   struct t1 {
5*481d67d3SYonghong Song;     long a;
6*481d67d3SYonghong Song;   };
7*481d67d3SYonghong Song;   struct t2 {
8*481d67d3SYonghong Song;     long a;
9*481d67d3SYonghong Song;     long b;
10*481d67d3SYonghong Song;   };
11*481d67d3SYonghong Song;   __attribute__((always_inline))
12*481d67d3SYonghong Song;   static long foo1(struct t2 a1, struct t1 a2, struct t1 a3, struct t1 a4,
13*481d67d3SYonghong Song;                    struct t1 a5, struct t2 a6) {
14*481d67d3SYonghong Song;     return a1.a + a2.a + a3.a + a4.a + a5.a + a6.a;
15*481d67d3SYonghong Song;   }
16*481d67d3SYonghong Song;   long foo2(struct t2 a1, struct t2 a2, struct t1 a3) {
17*481d67d3SYonghong Song;     return foo1(a1, a3, a3, a3, a3, a2);
18*481d67d3SYonghong Song;   }
19*481d67d3SYonghong Song; Compilation flags:
20*481d67d3SYonghong Song;   clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes t.c
21*481d67d3SYonghong Song
22*481d67d3SYonghong Song%struct.t2 = type { i64, i64 }
23*481d67d3SYonghong Song%struct.t1 = type { i64 }
24*481d67d3SYonghong Song
25*481d67d3SYonghong Song; Function Attrs: nounwind
26*481d67d3SYonghong Songdefine dso_local i64 @foo2([2 x i64] %a1.coerce, [2 x i64] %a2.coerce, i64 %a3.coerce) #0 {
27*481d67d3SYonghong Songentry:
28*481d67d3SYonghong Song  %a1 = alloca %struct.t2, align 8
29*481d67d3SYonghong Song  %a2 = alloca %struct.t2, align 8
30*481d67d3SYonghong Song  %a3 = alloca %struct.t1, align 8
31*481d67d3SYonghong Song  store [2 x i64] %a1.coerce, ptr %a1, align 8
32*481d67d3SYonghong Song  store [2 x i64] %a2.coerce, ptr %a2, align 8
33*481d67d3SYonghong Song  %coerce.dive = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
34*481d67d3SYonghong Song  store i64 %a3.coerce, ptr %coerce.dive, align 8
35*481d67d3SYonghong Song  %0 = load [2 x i64], ptr %a1, align 8
36*481d67d3SYonghong Song  %coerce.dive1 = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
37*481d67d3SYonghong Song  %1 = load i64, ptr %coerce.dive1, align 8
38*481d67d3SYonghong Song  %coerce.dive2 = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
39*481d67d3SYonghong Song  %2 = load i64, ptr %coerce.dive2, align 8
40*481d67d3SYonghong Song  %coerce.dive3 = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
41*481d67d3SYonghong Song  %3 = load i64, ptr %coerce.dive3, align 8
42*481d67d3SYonghong Song  %coerce.dive4 = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
43*481d67d3SYonghong Song  %4 = load i64, ptr %coerce.dive4, align 8
44*481d67d3SYonghong Song  %5 = load [2 x i64], ptr %a2, align 8
45*481d67d3SYonghong Song  %call = call i64 @foo1([2 x i64] %0, i64 %1, i64 %2, i64 %3, i64 %4, [2 x i64] %5)
46*481d67d3SYonghong Song  ret i64 %call
47*481d67d3SYonghong Song; CHECK:             r0 = r3
48*481d67d3SYonghong Song; CHECK-NEXT:        r0 += r1
49*481d67d3SYonghong Song; CHECK-NEXT:        r5 <<= 2
50*481d67d3SYonghong Song; CHECK-NEXT:        r0 += r5
51*481d67d3SYonghong Song; CHECK-NEXT:        exit
52*481d67d3SYonghong Song}
53*481d67d3SYonghong Song
54*481d67d3SYonghong Song; Function Attrs: alwaysinline nounwind
55*481d67d3SYonghong Songdefine internal i64 @foo1([2 x i64] %a1.coerce, i64 %a2.coerce, i64 %a3.coerce, i64 %a4.coerce, i64 %a5.coerce, [2 x i64] %a6.coerce) #1 {
56*481d67d3SYonghong Songentry:
57*481d67d3SYonghong Song  %a1 = alloca %struct.t2, align 8
58*481d67d3SYonghong Song  %a2 = alloca %struct.t1, align 8
59*481d67d3SYonghong Song  %a3 = alloca %struct.t1, align 8
60*481d67d3SYonghong Song  %a4 = alloca %struct.t1, align 8
61*481d67d3SYonghong Song  %a5 = alloca %struct.t1, align 8
62*481d67d3SYonghong Song  %a6 = alloca %struct.t2, align 8
63*481d67d3SYonghong Song  store [2 x i64] %a1.coerce, ptr %a1, align 8
64*481d67d3SYonghong Song  %coerce.dive = getelementptr inbounds %struct.t1, ptr %a2, i32 0, i32 0
65*481d67d3SYonghong Song  store i64 %a2.coerce, ptr %coerce.dive, align 8
66*481d67d3SYonghong Song  %coerce.dive1 = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
67*481d67d3SYonghong Song  store i64 %a3.coerce, ptr %coerce.dive1, align 8
68*481d67d3SYonghong Song  %coerce.dive2 = getelementptr inbounds %struct.t1, ptr %a4, i32 0, i32 0
69*481d67d3SYonghong Song  store i64 %a4.coerce, ptr %coerce.dive2, align 8
70*481d67d3SYonghong Song  %coerce.dive3 = getelementptr inbounds %struct.t1, ptr %a5, i32 0, i32 0
71*481d67d3SYonghong Song  store i64 %a5.coerce, ptr %coerce.dive3, align 8
72*481d67d3SYonghong Song  store [2 x i64] %a6.coerce, ptr %a6, align 8
73*481d67d3SYonghong Song  %a = getelementptr inbounds %struct.t2, ptr %a1, i32 0, i32 0
74*481d67d3SYonghong Song  %0 = load i64, ptr %a, align 8, !tbaa !3
75*481d67d3SYonghong Song  %a7 = getelementptr inbounds %struct.t1, ptr %a2, i32 0, i32 0
76*481d67d3SYonghong Song  %1 = load i64, ptr %a7, align 8, !tbaa !8
77*481d67d3SYonghong Song  %add = add nsw i64 %0, %1
78*481d67d3SYonghong Song  %a8 = getelementptr inbounds %struct.t1, ptr %a3, i32 0, i32 0
79*481d67d3SYonghong Song  %2 = load i64, ptr %a8, align 8, !tbaa !8
80*481d67d3SYonghong Song  %add9 = add nsw i64 %add, %2
81*481d67d3SYonghong Song  %a10 = getelementptr inbounds %struct.t1, ptr %a4, i32 0, i32 0
82*481d67d3SYonghong Song  %3 = load i64, ptr %a10, align 8, !tbaa !8
83*481d67d3SYonghong Song  %add11 = add nsw i64 %add9, %3
84*481d67d3SYonghong Song  %a12 = getelementptr inbounds %struct.t1, ptr %a5, i32 0, i32 0
85*481d67d3SYonghong Song  %4 = load i64, ptr %a12, align 8, !tbaa !8
86*481d67d3SYonghong Song  %add13 = add nsw i64 %add11, %4
87*481d67d3SYonghong Song  %a14 = getelementptr inbounds %struct.t2, ptr %a6, i32 0, i32 0
88*481d67d3SYonghong Song  %5 = load i64, ptr %a14, align 8, !tbaa !3
89*481d67d3SYonghong Song  %add15 = add nsw i64 %add13, %5
90*481d67d3SYonghong Song  ret i64 %add15
91*481d67d3SYonghong Song}
92*481d67d3SYonghong Song
93*481d67d3SYonghong Songattributes #0 = { nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
94*481d67d3SYonghong Songattributes #1 = { alwaysinline nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
95*481d67d3SYonghong Song
96*481d67d3SYonghong Song!llvm.module.flags = !{!0, !1}
97*481d67d3SYonghong Song!llvm.ident = !{!2}
98*481d67d3SYonghong Song
99*481d67d3SYonghong Song!0 = !{i32 1, !"wchar_size", i32 4}
100*481d67d3SYonghong Song!1 = !{i32 7, !"frame-pointer", i32 2}
101*481d67d3SYonghong Song!2 = !{!"clang version 16.0.0 (https://github.com/llvm/llvm-project.git 9385660f4ca87d074410a84df89faca313afcb5a)"}
102*481d67d3SYonghong Song!3 = !{!4, !5, i64 0}
103*481d67d3SYonghong Song!4 = !{!"t2", !5, i64 0, !5, i64 8}
104*481d67d3SYonghong Song!5 = !{!"long", !6, i64 0}
105*481d67d3SYonghong Song!6 = !{!"omnipotent char", !7, i64 0}
106*481d67d3SYonghong Song!7 = !{!"Simple C/C++ TBAA"}
107*481d67d3SYonghong Song!8 = !{!9, !5, i64 0}
108*481d67d3SYonghong Song!9 = !{!"t1", !5, i64 0}
109