brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 48fe1f5 Raw
86 lines · plain
1; RUN: opt -O2 -mtriple=bpf-pc-linux -S -o - %s | FileCheck %s2;3; Check position of bpf-preserve-static-offset pass in the pipeline:4; - preserve.static.offset call is preserved if address is passed as5;   a parameter to an inline-able function;6; - second bpf-preserve-static-offset pass (after inlining) should introduce7;   getelementptr.and.load call using the preserved marker.8;9; Source:10;    #define __ctx __attribute__((preserve_static_offset))11;    12;    struct bar {13;      int aa;14;      int bb;15;    };16;    17;    struct foo {18;      int a;19;      struct bar b;20;    } __ctx;21;    22;    extern void consume(int);23;    24;    static inline void bar(struct bar *p){25;      consume(p->bb);26;    }27;    28;    void quux(struct foo *p) {29;      bar(&p->b);30;    }31;32; Compilation flag:33;   clang -cc1 -O2 -triple bpf -S -emit-llvm -disable-llvm-passes -o - \34;       | opt -passes=function(sroa) -S -o -35 36%struct.foo = type { i32, %struct.bar }37%struct.bar = type { i32, i32 }38 39; Function Attrs: nounwind40define dso_local void @quux(ptr noundef %p) #0 {41entry:42  %0 = call ptr @llvm.preserve.static.offset(ptr %p)43  %b = getelementptr inbounds %struct.foo, ptr %0, i32 0, i32 144  call void @bar(ptr noundef %b)45  ret void46}47 48; Function Attrs: inlinehint nounwind49define internal void @bar(ptr noundef %p) #1 {50entry:51  %bb = getelementptr inbounds %struct.bar, ptr %p, i32 0, i32 152  %0 = load i32, ptr %bb, align 4, !tbaa !253  call void @consume(i32 noundef %0)54  ret void55}56 57; CHECK:      define dso_local void @quux(ptr noundef readonly captures(none) %[[p:.*]])58; CHECK:        %[[bb_i1:.*]] = tail call i32 (ptr, i1, i8, i8, i8, i1, ...)59; CHECK-SAME:     @llvm.bpf.getelementptr.and.load.i3260; CHECK-SAME:       (ptr readonly elementtype(i8) %[[p]],61; CHECK-SAME:        i1 false, i8 0, i8 1, i8 2, i1 true, i64 immarg 8)62; CHECK-SAME:      #[[v2:.*]], !tbaa63; CHECK-NEXT:   tail call void @consume(i32 noundef %[[bb_i1]])64; CHECK:      attributes #[[v2]] = { memory(argmem: read) }65 66; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)67declare ptr @llvm.preserve.static.offset(ptr readnone) #268 69declare void @consume(i32 noundef) #370 71attributes #0 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }72attributes #1 = { inlinehint nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" }73attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }74attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" }75 76!llvm.module.flags = !{!0}77!llvm.ident = !{!1}78 79!0 = !{i32 1, !"wchar_size", i32 4}80!1 = !{!"clang"}81!2 = !{!3, !4, i64 4}82!3 = !{!"bar", !4, i64 0, !4, i64 4}83!4 = !{!"int", !5, i64 0}84!5 = !{!"omnipotent char", !6, i64 0}85!6 = !{!"Simple C/C++ TBAA"}86