1; RUN: llc < %s -march=bpf | FileCheck %s
2
3%struct.bpf_map_def = type { i32, i32, i32, i32 }
4%struct.__sk_buff = type opaque
5%struct.routing_key_2 = type { [6 x i8] }
6
7@routing = global %struct.bpf_map_def { i32 1, i32 6, i32 12, i32 1024 }, section "maps", align 4
8@routing_miss_0 = global %struct.bpf_map_def { i32 1, i32 1, i32 12, i32 1 }, section "maps", align 4
9@test1 = global %struct.bpf_map_def { i32 2, i32 4, i32 8, i32 1024 }, section "maps", align 4
10@test1_miss_4 = global %struct.bpf_map_def { i32 2, i32 1, i32 8, i32 1 }, section "maps", align 4
11@_license = global [4 x i8] c"GPL\00", section "license", align 1
12@llvm.used = appending global [6 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @_license, i32 0, i32 0), i8* bitcast (i32 (%struct.__sk_buff*)* @ebpf_filter to i8*), i8* bitcast (%struct.bpf_map_def* @routing to i8*), i8* bitcast (%struct.bpf_map_def* @routing_miss_0 to i8*), i8* bitcast (%struct.bpf_map_def* @test1 to i8*), i8* bitcast (%struct.bpf_map_def* @test1_miss_4 to i8*)], section "llvm.metadata"
13
14; Function Attrs: nounwind uwtable
15define i32 @ebpf_filter(%struct.__sk_buff* nocapture readnone %ebpf_packet) #0 section "socket1" {
16  %key = alloca %struct.routing_key_2, align 1
17  %1 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 0
18; CHECK: r1 = 5
19; CHECK: *(u8 *)(r10 - 8) = r1
20  store i8 5, i8* %1, align 1
21  %2 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 1
22; CHECK: r1 = 6
23; CHECK: *(u8 *)(r10 - 7) = r1
24  store i8 6, i8* %2, align 1
25  %3 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 2
26; CHECK: r1 = 7
27; CHECK: *(u8 *)(r10 - 6) = r1
28  store i8 7, i8* %3, align 1
29  %4 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 3
30; CHECK: r1 = 8
31; CHECK: *(u8 *)(r10 - 5) = r1
32  store i8 8, i8* %4, align 1
33  %5 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 4
34; CHECK: r1 = 9
35; CHECK: *(u8 *)(r10 - 4) = r1
36  store i8 9, i8* %5, align 1
37  %6 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 0, i32 0, i64 5
38; CHECK: r1 = 10
39; CHECK: *(u8 *)(r10 - 3) = r1
40  store i8 10, i8* %6, align 1
41  %7 = getelementptr inbounds %struct.routing_key_2, %struct.routing_key_2* %key, i64 1, i32 0, i64 0
42; CHECK: r1 = r10
43; CHECK: r1 += -2
44; CHECK: r2 = 0
45; CHECK: *(u16 *)(r1 + 6) = r2
46; CHECK: *(u16 *)(r1 + 4) = r2
47; CHECK: *(u16 *)(r1 + 2) = r2
48; CHECK: *(u16 *)(r10 + 24) = r2
49; CHECK: *(u16 *)(r10 + 22) = r2
50; CHECK: *(u16 *)(r10 + 20) = r2
51; CHECK: *(u16 *)(r10 + 18) = r2
52; CHECK: *(u16 *)(r10 + 16) = r2
53; CHECK: *(u16 *)(r10 + 14) = r2
54; CHECK: *(u16 *)(r10 + 12) = r2
55; CHECK: *(u16 *)(r10 + 10) = r2
56; CHECK: *(u16 *)(r10 + 8) = r2
57; CHECK: *(u16 *)(r10 + 6) = r2
58; CHECK: *(u16 *)(r10 - 2) = r2
59; CHECK: *(u16 *)(r10 + 26) = r2
60  call void @llvm.memset.p0i8.i64(i8* %7, i8 0, i64 30, i32 1, i1 false)
61  %8 = call i32 (%struct.bpf_map_def*, %struct.routing_key_2*, ...) bitcast (i32 (...)* @bpf_map_lookup_elem to i32 (%struct.bpf_map_def*, %struct.routing_key_2*, ...)*)(%struct.bpf_map_def* nonnull @routing, %struct.routing_key_2* nonnull %key) #3
62  ret i32 undef
63}
64
65; Function Attrs: nounwind argmemonly
66declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #1
67
68declare i32 @bpf_map_lookup_elem(...) #2
69