68 lines · plain
1; RUN: opt --bpf-check-and-opt-ir -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check that getelementptr.and.load 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; extern void consume(int);16; 17; void bar(struct foo *p) {18; consume(p->a);19; }20;21; Compilation flag:22; clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \23; | opt -passes=sroa,bpf-preserve-static-offset -S -o -24 25%struct.foo = type { i32, [124 x i8], i32, [124 x i8] }26 27; Function Attrs: nounwind28define dso_local void @bar(ptr noundef %p) #0 {29entry:30 %a1 = call i32 (ptr, i1, i8, i8, i8, i1, ...)31 @llvm.bpf.getelementptr.and.load.i3232 (ptr readonly elementtype(%struct.foo) %p,33 i1 false, i8 0, i8 1, i8 7, i1 true, i32 immarg 0, i32 immarg 2)34 #4, !tbaa !235 call void @consume(i32 noundef %a1)36 ret void37}38 39; CHECK: define dso_local void @bar(ptr noundef %[[p:.*]])40; CHECK: %[[a11:.*]] = getelementptr inbounds %struct.foo, ptr %[[p]], i32 0, i32 241; CHECK: %[[v2:.*]] = load i32, ptr %[[a11]], align 12842; CHECK: call void @consume(i32 noundef %[[v2]])43 44declare void @consume(i32 noundef) #145 46; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)47declare ptr @llvm.preserve.static.offset(ptr readnone) #248 49; Function Attrs: nocallback nofree nounwind willreturn50declare i32 @llvm.bpf.getelementptr.and.load.i32(ptr nocapture, i1 immarg, i8 immarg, i8 immarg, i8 immarg, i1 immarg, ...) #351 52attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }53attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" }54attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }55attributes #3 = { nocallback nofree nounwind willreturn }56attributes #4 = { memory(argmem: read) }57 58!llvm.module.flags = !{!0}59!llvm.ident = !{!1}60 61!0 = !{i32 1, !"wchar_size", i32 4}62!1 = !{!"clang"}63!2 = !{!3, !4, i64 128}64!3 = !{!"foo", !4, i64 0, !4, i64 128}65!4 = !{!"int", !5, i64 0}66!5 = !{!"omnipotent char", !6, i64 0}67!6 = !{!"Simple C/C++ TBAA"}68