brintos

brintos / llvm-project-archived public Read only

0
0
Text · 6.8 KiB · ac4d9d6 Raw
157 lines · plain
1; RUN: llc -mtriple=bpfel -mcpu=v4 < %s | FileCheck %s2 3; Make sure that CO-RE relocations had been generated correctly for4; BPF_ST (store immediate) instructions and that5; BPFMISimplifyPatchable optimizations had been applied.6;7; Generated from the following source code:8;9;   #define __pai __attribute__((preserve_access_index))10;11;   struct foo {12;     unsigned char  b;13;     unsigned short h;14;     unsigned int   w;15;     unsigned long  d;16;   } __pai;17;18;   void bar(volatile struct foo *p) {19;     p->b = 1;20;     p->h = 2;21;     p->w = 3;22;     p->d = 4;23;   }24;25; Using the following command:26;27;   clang -g -O2 -S -emit-llvm -mcpu=v4 --target=bpfel test.c28 29target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"30 31@"llvm.foo:0:0$0:0" = external global i64, !llvm.preserve.access.index !0 #032@"llvm.foo:0:2$0:1" = external global i64, !llvm.preserve.access.index !0 #033@"llvm.foo:0:4$0:2" = external global i64, !llvm.preserve.access.index !0 #034@"llvm.foo:0:8$0:3" = external global i64, !llvm.preserve.access.index !0 #035 36; Function Attrs: nofree nounwind37define dso_local void @bar(ptr noundef %p) local_unnamed_addr #1 !dbg !18 {38entry:39  call void @llvm.dbg.value(metadata ptr %p, metadata !24, metadata !DIExpression()), !dbg !2540  %0 = load i64, ptr @"llvm.foo:0:0$0:0", align 841  %1 = getelementptr i8, ptr %p, i64 %042  %2 = tail call ptr @llvm.bpf.passthrough.p0.p0(i32 0, ptr %1)43  store volatile i8 1, ptr %2, align 8, !dbg !26, !tbaa !2744  %3 = load i64, ptr @"llvm.foo:0:2$0:1", align 845  %4 = getelementptr i8, ptr %p, i64 %346  %5 = tail call ptr @llvm.bpf.passthrough.p0.p0(i32 1, ptr %4)47  store volatile i16 2, ptr %5, align 2, !dbg !34, !tbaa !3548  %6 = load i64, ptr @"llvm.foo:0:4$0:2", align 849  %7 = getelementptr i8, ptr %p, i64 %650  %8 = tail call ptr @llvm.bpf.passthrough.p0.p0(i32 2, ptr %7)51  store volatile i32 3, ptr %8, align 4, !dbg !36, !tbaa !3752  %9 = load i64, ptr @"llvm.foo:0:8$0:3", align 853  %10 = getelementptr i8, ptr %p, i64 %954  %11 = tail call ptr @llvm.bpf.passthrough.p0.p0(i32 3, ptr %10)55  store volatile i64 4, ptr %11, align 8, !dbg !38, !tbaa !3956  ret void, !dbg !4057}58 59; CHECK: [[L0:.Ltmp.*]]:60; CHECK:       *(u8 *)(r1 + 0) = 161; CHECK: [[L2:.Ltmp.*]]:62; CHECK:       *(u16 *)(r1 + 2) = 263; CHECK: [[L4:.Ltmp.*]]:64; CHECK:       *(u32 *)(r1 + 4) = 365; CHECK: [[L6:.Ltmp.*]]:66; CHECK:       *(u64 *)(r1 + 8) = 467 68; CHECK:       .section        .BTF69; ...70; CHECK:       .long   [[FOO:.*]]           # BTF_KIND_STRUCT(id = [[FOO_ID:.*]])71; ...72; CHECK:       .ascii  "foo"                # string offset=[[FOO]]73; CHECK:       .ascii  ".text"              # string offset=[[TEXT:.*]]74; CHECK:       .ascii  "0:0"                # string offset=[[S1:.*]]75; CHECK:       .ascii  "0:1"                # string offset=[[S2:.*]]76; CHECK:       .ascii  "0:2"                # string offset=[[S3:.*]]77; CHECK:       .ascii  "0:3"                # string offset=[[S4:.*]]78 79; CHECK:       .section        .BTF.ext80; ...81; CHECK:       .long   [[#]]                # FieldReloc82; CHECK-NEXT:  .long   [[TEXT]]             # Field reloc section string offset=[[TEXT]]83; CHECK-NEXT:  .long   [[#]]84; CHECK-NEXT:  .long   [[L0]]85; CHECK-NEXT:  .long   [[FOO_ID]]86; CHECK-NEXT:  .long   [[S1]]87; CHECK-NEXT:  .long   088; CHECK-NEXT:  .long   [[L2]]89; CHECK-NEXT:  .long   [[FOO_ID]]90; CHECK-NEXT:  .long   [[S2]]91; CHECK-NEXT:  .long   092; CHECK-NEXT:  .long   [[L4]]93; CHECK-NEXT:  .long   [[FOO_ID]]94; CHECK-NEXT:  .long   [[S3]]95; CHECK-NEXT:  .long   096; CHECK-NEXT:  .long   [[L6]]97; CHECK-NEXT:  .long   [[FOO_ID]]98; CHECK-NEXT:  .long   [[S4]]99; CHECK-NEXT:  .long   0100 101; Function Attrs: nofree nosync nounwind memory(none)102declare ptr @llvm.bpf.passthrough.p0.p0(i32, ptr) #2103 104; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)105declare void @llvm.dbg.value(metadata, metadata, metadata) #3106 107attributes #0 = { "btf_ama" }108attributes #1 = { nofree nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="v4" }109attributes #2 = { nofree nosync nounwind memory(none) }110attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }111 112!llvm.dbg.cu = !{!11}113!llvm.module.flags = !{!12, !13, !14, !15, !16}114!llvm.ident = !{!17}115 116!0 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !1, line: 3, size: 128, elements: !2)117!1 = !DIFile(filename: "some-file.c", directory: "/some/dir", checksumkind: CSK_MD5, checksum: "e5d03b4d39dfffadc6c607e956c37996")118!2 = !{!3, !5, !7, !9}119!3 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !0, file: !1, line: 4, baseType: !4, size: 8)120!4 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)121!5 = !DIDerivedType(tag: DW_TAG_member, name: "h", scope: !0, file: !1, line: 5, baseType: !6, size: 16, offset: 16)122!6 = !DIBasicType(name: "unsigned short", size: 16, encoding: DW_ATE_unsigned)123!7 = !DIDerivedType(tag: DW_TAG_member, name: "w", scope: !0, file: !1, line: 6, baseType: !8, size: 32, offset: 32)124!8 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)125!9 = !DIDerivedType(tag: DW_TAG_member, name: "d", scope: !0, file: !1, line: 7, baseType: !10, size: 64, offset: 64)126!10 = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned)127!11 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 18.0.0 ...", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)128!12 = !{i32 7, !"Dwarf Version", i32 5}129!13 = !{i32 2, !"Debug Info Version", i32 3}130!14 = !{i32 1, !"wchar_size", i32 4}131!15 = !{i32 7, !"frame-pointer", i32 2}132!16 = !{i32 7, !"debug-info-assignment-tracking", i1 true}133!17 = !{!"clang version 18.0.0 ..."}134!18 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 10, type: !19, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !11, retainedNodes: !23)135!19 = !DISubroutineType(types: !20)136!20 = !{null, !21}137!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64)138!22 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !0)139!23 = !{!24}140!24 = !DILocalVariable(name: "p", arg: 1, scope: !18, file: !1, line: 10, type: !21)141!25 = !DILocation(line: 0, scope: !18)142!26 = !DILocation(line: 11, column: 8, scope: !18)143!27 = !{!28, !29, i64 0}144!28 = !{!"foo", !29, i64 0, !31, i64 2, !32, i64 4, !33, i64 8}145!29 = !{!"omnipotent char", !30, i64 0}146!30 = !{!"Simple C/C++ TBAA"}147!31 = !{!"short", !29, i64 0}148!32 = !{!"int", !29, i64 0}149!33 = !{!"long", !29, i64 0}150!34 = !DILocation(line: 12, column: 8, scope: !18)151!35 = !{!28, !31, i64 2}152!36 = !DILocation(line: 13, column: 8, scope: !18)153!37 = !{!28, !32, i64 4}154!38 = !DILocation(line: 14, column: 8, scope: !18)155!39 = !{!28, !33, i64 8}156!40 = !DILocation(line: 15, column: 1, scope: !18)157