1 ; RUN: llc -march=bpfel -mattr=+alu32 < %s | FileCheck %s
7 ; extern int work(struct env_t *skb, unsigned offset);
8 ; int test(struct env_t *skb)
10 ; ptr cursor, *data_end;
11 ; struct env_t *srh, *ip;
13 ; data_end = (ptr)(long)skb->data_end;
14 ; cursor = (ptr)(long)skb->data;
16 ; ip = cursor; cursor += sizeof(*ip);
17 ; if ((ptr)ip + sizeof(*ip) > data_end)
20 ; srh = cursor; cursor += sizeof(*srh);
21 ; if ((ptr)srh + sizeof(*srh) > data_end)
24 ; return work(skb, (char *)srh - (char *)(long)skb->data);
27 ; clang -target bpf -O2 -emit-llvm -S test.c
29 %struct.env_t = type { i32, i32 }
31 ; Function Attrs: nounwind
32 define dso_local i32 @test(ptr %skb) local_unnamed_addr #0 {
34 %data_end1 = getelementptr inbounds %struct.env_t, ptr %skb, i64 0, i32 1
35 %0 = load i32, ptr %data_end1, align 4, !tbaa !2
36 %conv = zext i32 %0 to i64
37 %1 = inttoptr i64 %conv to ptr
38 %2 = load i32, ptr %skb, align 4, !tbaa !7
39 %conv2 = zext i32 %2 to i64
40 %3 = inttoptr i64 %conv2 to ptr
41 %add.ptr = getelementptr i8, ptr %3, i64 8
42 %cmp = icmp ugt ptr %add.ptr, %1
43 %add.ptr6 = getelementptr i8, ptr %3, i64 16
44 %cmp7 = icmp ugt ptr %add.ptr6, %1
45 %or.cond = or i1 %cmp, %cmp7
46 br i1 %or.cond, label %cleanup, label %if.end10
48 if.end10: ; preds = %entry
49 %sub.ptr.lhs.cast = ptrtoint ptr %add.ptr to i64
50 %4 = trunc i64 %sub.ptr.lhs.cast to i32
51 %conv13 = sub i32 %4, %2
52 %call = tail call i32 @work(ptr nonnull %skb, i32 %conv13) #2
55 cleanup: ; preds = %entry, %if.end10
56 %retval.0 = phi i32 [ %call, %if.end10 ], [ 0, %entry ]
60 ; CHECK: w{{[0-9]+}} = *(u32 *)(r{{[0-9]+}} + 0)
61 ; CHECK-NOT: w{{[0-9]+}} = w{{[0-9]+}}
63 declare dso_local i32 @work(ptr, i32) local_unnamed_addr #1
65 attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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" }
66 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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" }
67 attributes #2 = { nounwind }
69 !llvm.module.flags = !{!0}
72 !0 = !{i32 1, !"wchar_size", i32 4}
73 !1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 016d3ce1f4b07ee3056f7c10fedb24c441c4870f)"}
75 !3 = !{!"env_t", !4, i64 0, !4, i64 4}
76 !4 = !{!"int", !5, i64 0}
77 !5 = !{!"omnipotent char", !6, i64 0}
78 !6 = !{!"Simple C/C++ TBAA"}