1 ; RUN: opt --bpf-check-and-opt-ir -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s
3 ; Check that getelementptr.and.load unroll can skip 'inbounds' flag.
6 ; #define __ctx __attribute__((preserve_static_offset))
18 ; void buz(struct foo *p) {
23 ; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \
24 ; | opt -passes=sroa,bpf-preserve-static-offset -S -o -
26 %struct.foo = type { i32, %struct.bar }
27 %struct.bar = type { i32, i32 }
29 ; Function Attrs: nounwind
30 define dso_local void @buz(ptr noundef %p) #0 {
32 call void (i32, ptr, i1, i8, i8, i8, i1, ...)
33 @llvm.bpf.getelementptr.and.store.i32
35 ptr writeonly elementtype(%struct.foo) %p,
36 i1 false, i8 0, i8 1, i8 2, i1 false, i32 immarg 0, i32 immarg 1, i32 immarg 1)
41 ; CHECK: define dso_local void @buz(ptr noundef %[[p:.*]])
42 ; CHECK: %[[v2:.*]] = getelementptr %struct.foo, ptr %[[p]], i32 0, i32 1, i32 1
43 ; CHECK: store i32 42, ptr %[[v2]], align 4
46 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
47 declare ptr @llvm.preserve.static.offset(ptr readnone) #1
49 ; Function Attrs: nocallback nofree nounwind willreturn
50 declare void @llvm.bpf.getelementptr.and.store.i32(i32, ptr nocapture, i1 immarg, i8 immarg, i8 immarg, i8 immarg, i1 immarg, ...) #2
52 attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
53 attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
54 attributes #2 = { nocallback nofree nounwind willreturn }
55 attributes #3 = { memory(argmem: write) }
57 !llvm.module.flags = !{!0}
60 !0 = !{i32 1, !"wchar_size", i32 4}
63 !3 = !{!"foo", !4, i64 0, !7, i64 4}
64 !4 = !{!"int", !5, i64 0}
65 !5 = !{!"omnipotent char", !6, i64 0}
66 !6 = !{!"Simple C/C++ TBAA"}
67 !7 = !{!"bar", !4, i64 0, !4, i64 4}