63 lines · plain
1; RUN: opt --bpf-check-and-opt-ir -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check that getelementptr.and.store unroll restores alignment spec.4;5; Source:6; #define __ctx __attribute__((preserve_static_offset))7; 8; typedef int aligned_int __attribute__((aligned(128)));9; 10; struct foo {11; int _;12; aligned_int a;13; } __ctx;14; 15; void bar(struct foo *p) {16; p->a = 42;17; }18;19; Compilation flag:20; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \21; | opt -passes=sroa,bpf-preserve-static-offset -S -o -22 23%struct.foo = type { i32, [124 x i8], i32, [124 x i8] }24 25; Function Attrs: nounwind26define dso_local void @bar(ptr noundef %p) #0 {27entry:28 call void (i32, ptr, i1, i8, i8, i8, i1, ...)29 @llvm.bpf.getelementptr.and.store.i3230 (i32 42,31 ptr writeonly elementtype(%struct.foo) %p,32 i1 false, i8 0, i8 1, i8 7, i1 true, i32 immarg 0, i32 immarg 2)33 #3, !tbaa !234 ret void35}36 37; CHECK: define dso_local void @bar(ptr noundef %[[p:.*]])38; CHECK: %[[v2:.*]] = getelementptr inbounds %struct.foo, ptr %[[p]], i32 0, i32 239; CHECK: store i32 42, ptr %[[v2]], align 12840; CHECK: ret void41 42; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)43declare ptr @llvm.preserve.static.offset(ptr readnone) #144 45; Function Attrs: nocallback nofree nounwind willreturn46declare void @llvm.bpf.getelementptr.and.store.i32(i32, ptr nocapture, i1 immarg, i8 immarg, i8 immarg, i8 immarg, i1 immarg, ...) #247 48attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }49attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }50attributes #2 = { nocallback nofree nounwind willreturn }51attributes #3 = { memory(argmem: write) }52 53!llvm.module.flags = !{!0}54!llvm.ident = !{!1}55 56!0 = !{i32 1, !"wchar_size", i32 4}57!1 = !{!"clang"}58!2 = !{!3, !4, i64 128}59!3 = !{!"foo", !4, i64 0, !4, i64 128}60!4 = !{!"int", !5, i64 0}61!5 = !{!"omnipotent char", !6, i64 0}62!6 = !{!"Simple C/C++ TBAA"}63