brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · d9634a3 Raw
65 lines · plain
1; RUN: opt --bpf-check-and-opt-ir -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check that unroll of getelementptr.and.load restores volatile.4;5; Source:6;    #define __ctx __attribute__((preserve_static_offset))7;    8;    struct foo {9;      int a;10;      volatile int b;11;    } __ctx;12;    13;    extern void consume(int);14;    15;    void bar(struct foo *p){16;      consume(p->b);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, i32 }24 25; Function Attrs: nounwind26define dso_local void @bar(ptr noundef %p) #0 {27entry:28  %b1 = call i32 (ptr, i1, i8, i8, i8, i1, ...)29    @llvm.bpf.getelementptr.and.load.i3230      (ptr elementtype(%struct.foo) %p,31       i1 true, i8 0, i8 1, i8 2, i1 true, i32 immarg 0, i32 immarg 1),32    !tbaa !233  call void @consume(i32 noundef %b1)34  ret void35}36 37; CHECK: define dso_local void @bar(ptr noundef %[[p:.*]])38; CHECK:   %[[b11:.*]] = getelementptr inbounds %struct.foo, ptr %[[p]], i32 0, i32 139; CHECK:   %[[v2:.*]] = load volatile i32, ptr %[[b11]], align 440; CHECK:   call void @consume(i32 noundef %[[v2]])41 42declare void @consume(i32 noundef) #143 44; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)45declare ptr @llvm.preserve.static.offset(ptr readnone) #246 47; Function Attrs: nocallback nofree nounwind willreturn48declare i32 @llvm.bpf.getelementptr.and.load.i32(ptr nocapture, i1 immarg, i8 immarg, i8 immarg, i8 immarg, i1 immarg, ...) #349 50attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }51attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" }52attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }53attributes #3 = { nocallback nofree nounwind willreturn }54 55!llvm.module.flags = !{!0}56!llvm.ident = !{!1}57 58!0 = !{i32 1, !"wchar_size", i32 4}59!1 = !{!"clang"}60!2 = !{!3, !4, i64 4}61!3 = !{!"foo", !4, i64 0, !4, i64 4}62!4 = !{!"int", !5, i64 0}63!5 = !{!"omnipotent char", !6, i64 0}64!6 = !{!"Simple C/C++ TBAA"}65