xref: /llvm-project/clang/test/CodeGen/bpf-struct-argument.c (revision 481d67d310a7a4213da72f838d6bafaa52ed01d3)
1*481d67d3SYonghong Song // REQUIRES: bpf-registered-target
2*481d67d3SYonghong Song // RUN: %clang_cc1 -triple bpf -O2 -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
3*481d67d3SYonghong Song 
4*481d67d3SYonghong Song struct t1 {};
5*481d67d3SYonghong Song struct t2 {
6*481d67d3SYonghong Song   int a;
7*481d67d3SYonghong Song };
8*481d67d3SYonghong Song struct t3 {
9*481d67d3SYonghong Song   int a;
10*481d67d3SYonghong Song   long b;
11*481d67d3SYonghong Song };
12*481d67d3SYonghong Song struct t4 {
13*481d67d3SYonghong Song   long a;
14*481d67d3SYonghong Song   long b;
15*481d67d3SYonghong Song   long c;
16*481d67d3SYonghong Song };
17*481d67d3SYonghong Song 
foo1(struct t1 arg1,struct t2 arg2)18*481d67d3SYonghong Song int foo1(struct t1 arg1, struct t2 arg2) {
19*481d67d3SYonghong Song // CHECK: define dso_local i32 @foo1(i32 %arg2.coerce)
20*481d67d3SYonghong Song   return arg2.a;
21*481d67d3SYonghong Song }
22*481d67d3SYonghong Song 
foo2(struct t3 arg1,struct t4 arg2)23*481d67d3SYonghong Song int foo2(struct t3 arg1, struct t4 arg2) {
24*481d67d3SYonghong Song // CHECK: define dso_local i32 @foo2([2 x i64] %arg1.coerce, ptr noundef byval(%struct.t4) align 8 %arg2)
25*481d67d3SYonghong Song   return arg1.a + arg2.a;
26*481d67d3SYonghong Song }
27*481d67d3SYonghong Song 
foo3(void)28*481d67d3SYonghong Song int foo3(void) {
29*481d67d3SYonghong Song   struct t1 tmp1 = {};
30*481d67d3SYonghong Song   struct t2 tmp2 = {};
31*481d67d3SYonghong Song   struct t3 tmp3 = {};
32*481d67d3SYonghong Song   struct t4 tmp4 = {};
33*481d67d3SYonghong Song   return foo1(tmp1, tmp2) + foo2(tmp3, tmp4);
34*481d67d3SYonghong Song // CHECK: call i32 @foo1(i32 %{{[a-zA-Z0-9]+}})
35*481d67d3SYonghong Song // CHECK: call i32 @foo2([2 x i64] %{{[a-zA-Z0-9]+}}, ptr noundef byval(%struct.t4) align 8 %tmp4)
36*481d67d3SYonghong Song }
37