61 lines · plain
1; RUN: opt -O2 -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check handling of a simple store instruction by bpf-preserve-static-offset.4; Verify:5; - presence of gep.and.store intrinsic call6; - correct attributes for intrinsic call7; - presence of tbaa annotations8;9; Source:10; #define __ctx __attribute__((preserve_static_offset))11; 12; struct foo {13; int _;14; int a;15; } __ctx;16; 17; void bar(struct foo *p) { 18; p->a = 7;19; }20;21; Compilation flag:22; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \23; | opt -passes=function(sroa) -S -o -24 25%struct.foo = type { i32, i32 }26 27; Function Attrs: nounwind28define dso_local void @bar(ptr noundef %p) #0 {29entry:30 %0 = call ptr @llvm.preserve.static.offset(ptr %p)31 %a = getelementptr inbounds %struct.foo, ptr %0, i32 0, i32 132 store i32 7, ptr %a, align 4, !tbaa !233 ret void34}35 36; CHECK: define dso_local void @bar(ptr noundef writeonly captures(none) %[[p:.*]])37; CHECK: tail call void (i32, ptr, i1, i8, i8, i8, i1, ...)38; CHECK-SAME: @llvm.bpf.getelementptr.and.store.i3239; CHECK-SAME: (i32 7,40; CHECK-SAME: ptr writeonly elementtype(%struct.foo) %[[p]],41; CHECK-SAME: i1 false, i8 0, i8 1, i8 2, i1 true, i32 immarg 0, i32 immarg 1)42; CHECK-SAME: #[[v2:.*]], !tbaa43; CHECK: attributes #[[v2]] = { memory(argmem: write) }44 45; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)46declare ptr @llvm.preserve.static.offset(ptr readnone) #147 48attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }49attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }50 51!llvm.module.flags = !{!0}52!llvm.ident = !{!1}53 54!0 = !{i32 1, !"wchar_size", i32 4}55!1 = !{!"clang"}56!2 = !{!3, !4, i64 4}57!3 = !{!"foo", !4, i64 0, !4, i64 4}58!4 = !{!"int", !5, i64 0}59!5 = !{!"omnipotent char", !6, i64 0}60!6 = !{!"Simple C/C++ TBAA"}61