1; RUN: opt -O2 -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s 2; 3; Check handling of atomic store instruction by bpf-preserve-static-offset. 4; 5; Source: 6; #define __ctx __attribute__((preserve_static_offset)) 7; 8; struct foo { 9; int _; 10; int a; 11; } __ctx; 12; 13; void bar(struct foo *p) { 14; int r; 15; r = 7; 16; __atomic_store(&p->a, &r, 3); 17; } 18; 19; Compilation flag: 20; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \ 21; | opt -passes=function(sroa) -S -o - 22 23%struct.foo = type { i32, i32 } 24 25; Function Attrs: nounwind 26define dso_local void @bar(ptr noundef %p) #0 { 27entry: 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 31 ret void 32} 33 34; CHECK: define dso_local void @bar(ptr noundef captures(none) %[[p:.*]]) 35; CHECK: tail call void (i32, ptr, i1, i8, i8, i8, i1, ...) 36; CHECK-SAME: @llvm.bpf.getelementptr.and.store.i32 37; CHECK-SAME: (i32 7, 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 42 43; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) 44declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1 45 46; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 47declare ptr @llvm.preserve.static.offset(ptr readnone) #2 48 49; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) 50declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1 51 52attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" } 53attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) } 54attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } 55 56!llvm.module.flags = !{!0} 57!llvm.ident = !{!1} 58 59!0 = !{i32 1, !"wchar_size", i32 4} 60!1 = !{!"clang"} 61