brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · ae19dd7 Raw
66 lines · plain
1; RUN: opt --bpf-check-and-opt-ir -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check unroll of getelementptr.and.load.4;5; Source:6;    #define __ctx __attribute__((preserve_static_offset))7;    8;    struct foo {9;      int a;10;      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 readonly elementtype(%struct.foo) %p,31       i1 false, i8 0, i8 1, i8 2, i1 true, i32 immarg 0, i32 immarg 1)32    #4, !tbaa !233  call void @consume(i32 noundef %b1)34  ret void35}36 37; CHECK:      define dso_local void @bar(ptr noundef %[[p:.*]]) #[[v1:.*]] {38; CHECK:        %[[b11:.*]] = getelementptr inbounds %struct.foo, ptr %[[p]], i32 0, i32 139; CHECK-NEXT:   %[[v2:.*]] = load i32, ptr %[[b11]], align 440; CHECK-NEXT:   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 }54attributes #4 = { memory(argmem: read) }55 56!llvm.module.flags = !{!0}57!llvm.ident = !{!1}58 59!0 = !{i32 1, !"wchar_size", i32 4}60!1 = !{!"clang"}61!2 = !{!3, !4, i64 4}62!3 = !{!"foo", !4, i64 0, !4, i64 4}63!4 = !{!"int", !5, i64 0}64!5 = !{!"omnipotent char", !6, i64 0}65!6 = !{!"Simple C/C++ TBAA"}66