xref: /llvm-project/llvm/test/CodeGen/BPF/bpf-fastcall-1.ll (revision c5037db4acd95790a0ca5061c8fa79c5c291607e)
1; RUN: llc -O2 --mtriple=bpfel %s -o - | FileCheck %s
2
3; Generated from the following C code:
4;
5;   #define __bpf_fastcall __attribute__((bpf_fastcall))
6;
7;   void bar(void) __bpf_fastcall;
8;   void buz(long i, long j, long k);
9;
10;   void foo(long i, long j, long k) {
11;     bar();
12;     buz(i, j, k);
13;   }
14;
15; Using the following command:
16;
17;   clang --target=bpf -emit-llvm -O2 -S -o - t.c
18;
19; (unnecessary attrs removed maually)
20
21; Check that function marked with bpf_fastcall does not clobber R1-R5.
22
23define dso_local void @foo(i64 noundef %i, i64 noundef %j, i64 noundef %k) {
24entry:
25  tail call void @bar() #1
26  tail call void @buz(i64 noundef %i, i64 noundef %j, i64 noundef %k)
27  ret void
28}
29
30; CHECK:      foo:
31; CHECK:      # %bb.0:
32; CHECK-NEXT:   *(u64 *)(r10 - 8) = r1
33; CHECK-NEXT:   *(u64 *)(r10 - 16) = r2
34; CHECK-NEXT:   *(u64 *)(r10 - 24) = r3
35; CHECK-NEXT:   call bar
36; CHECK-NEXT:   r3 = *(u64 *)(r10 - 24)
37; CHECK-NEXT:   r2 = *(u64 *)(r10 - 16)
38; CHECK-NEXT:   r1 = *(u64 *)(r10 - 8)
39; CHECK-NEXT:   call buz
40; CHECK-NEXT:   exit
41
42declare dso_local void @bar() #0
43declare dso_local void @buz(i64 noundef, i64 noundef, i64 noundef)
44
45attributes #0 = { "bpf_fastcall" }
46attributes #1 = { nounwind "bpf_fastcall" }
47