1 ; RUN: opt -O2 -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s
3 ; Check handling of atomic store instruction by bpf-preserve-static-offset.
6 ; #define __ctx __attribute__((preserve_static_offset))
13 ; void bar(struct foo *p) {
16 ; __atomic_store(&p->a, &r, 3);
20 ; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \
21 ; | opt -passes=function(sroa) -S -o -
23 %struct.foo = type { i32, i32 }
25 ; Function Attrs: nounwind
26 define dso_local void @bar(ptr noundef %p) #0 {
28 %0 = call ptr @llvm.preserve.static.offset(ptr %p)
29 %a = getelementptr inbounds %struct.foo, ptr %0, i32 0, i32 1
30 store atomic i32 7, ptr %a release, align 4
34 ; CHECK: define dso_local void @bar(ptr nocapture noundef %[[p:.*]])
35 ; CHECK: tail call void (i32, ptr, i1, i8, i8, i8, i1, ...)
36 ; CHECK-SAME: @llvm.bpf.getelementptr.and.store.i32
38 ; CHECK-SAME: ptr elementtype(%struct.foo) %[[p]],
39 ; CHECK-SAME: i1 false, i8 5, i8 1, i8 2, i1 true, i32 immarg 0, i32 immarg 1)
40 ; CHECK-NOT: #{{[0-9]+}}
41 ; CHECK-NEXT: ret void
43 ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
44 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1
46 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
47 declare ptr @llvm.preserve.static.offset(ptr readnone) #2
49 ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
50 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1
52 attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
53 attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
54 attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
56 !llvm.module.flags = !{!0}
59 !0 = !{i32 1, !"wchar_size", i32 4}