1 ; RUN: opt -O2 -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s
3 ; Check that stores from zero offset are not modified by bpf-preserve-static-offset.
6 ; #define __ctx __attribute__((preserve_static_offset))
12 ; void bar(struct foo *p) {
17 ; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \
18 ; | opt -passes=function(sroa) -S -o -
20 %struct.foo = type { i32 }
22 ; Function Attrs: nounwind
23 define dso_local void @bar(ptr noundef %p) #0 {
25 %0 = call ptr @llvm.preserve.static.offset(ptr %p)
26 %a = getelementptr inbounds %struct.foo, ptr %0, i32 0, i32 0
27 store i32 0, ptr %a, align 4, !tbaa !2
31 ; CHECK: define dso_local void @bar(ptr nocapture noundef writeonly %[[p:.*]])
33 ; CHECK-NEXT: store i32 0, ptr %[[p]], align 4, !tbaa
34 ; CHECK-NEXT: ret void
36 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
37 declare ptr @llvm.preserve.static.offset(ptr readnone) #1
39 attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
40 attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
42 !llvm.module.flags = !{!0}
45 !0 = !{i32 1, !"wchar_size", i32 4}
48 !3 = !{!"foo", !4, i64 0}
49 !4 = !{!"int", !5, i64 0}
50 !5 = !{!"omnipotent char", !6, i64 0}
51 !6 = !{!"Simple C/C++ TBAA"}