76 lines · plain
1; RUN: llc -mtriple=bpfel -mcpu=v3 -filetype=obj -o %t1 %s2; RUN: llvm-objcopy --dump-section='.BTF'=%t2 %t13; RUN: %python %p/print_btf.py %t2 | FileCheck -check-prefixes=CHECK-BTF-SHORT %s4; RUN: %python %p/print_btf.py %t2 | FileCheck -check-prefixes=CHECK-BTF %s5; Source:6; struct nested_value_type {7; int a1;8; };9; struct map_type {10; struct {11; struct nested_value_type *value;12; } *values[];13; };14; Compilation flags:15; clang -target bpf -g -O2 -S -emit-llvm prog.c16 17; ModuleID = 'prog.c'18source_filename = "prog.c"19target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"20target triple = "bpf"21 22%struct.map_type = type { [0 x ptr] }23 24@array_of_maps = dso_local local_unnamed_addr global %struct.map_type zeroinitializer, section ".maps", align 8, !dbg !025 26; We expect no forward declarations.27;28; CHECK-BTF-SHORT-NOT: FWD29 30; Assert the whole BTF.31;32; CHECK-BTF: [1] PTR '(anon)' type_id=233; CHECK-BTF-NEXT: [2] STRUCT 'nested_value_type' size=4 vlen=134; CHECK-BTF-NEXT: 'a1' type_id=3 bits_offset=035; CHECK-BTF-NEXT: [3] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED36; CHECK-BTF-NEXT: [4] STRUCT '(anon)' size=8 vlen=137; CHECK-BTF-NEXT: 'value' type_id=1 bits_offset=038; CHECK-BTF-NEXT: [5] PTR '(anon)' type_id=439; CHECK-BTF-NEXT: [6] ARRAY '(anon)' type_id=5 index_type_id=7 nr_elems=040; CHECK-BTF-NEXT: [7] INT '__ARRAY_SIZE_TYPE__' size=4 bits_offset=0 nr_bits=32 encoding=(none)41; CHECK-BTF-NEXT: [8] STRUCT 'map_type' size=0 vlen=142; CHECK-BTF-NEXT: 'values' type_id=6 bits_offset=043; CHECK-BTF-NEXT: [9] VAR 'array_of_maps' type_id=8, linkage=global44; CHECK-BTF-NEXT: [10] DATASEC '.maps' size=0 vlen=145; CHECK-BTF-NEXT: type_id=9 offset=0 size=046 47!llvm.dbg.cu = !{!2}48!llvm.module.flags = !{!20, !21, !22, !23}49!llvm.ident = !{!24}50 51!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())52!1 = distinct !DIGlobalVariable(name: "array_of_maps", scope: !2, file: !3, line: 9, type: !5, isLocal: false, isDefinition: true)53!2 = distinct !DICompileUnit(language: DW_LANG_C11, file: !3, producer: "clang version 22.0.0git (git@github.com:llvm/llvm-project.git ed93eaa421b714028b85cc887d80c45991d7207f)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)54!3 = !DIFile(filename: "prog.c", directory: "/home/mtardy/llvm-bug-repro", checksumkind: CSK_MD5, checksum: "9381d9e83e9c0b235a14704224815e96")55!4 = !{!0}56!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "map_type", file: !3, line: 4, elements: !6)57!6 = !{!7}58!7 = !DIDerivedType(tag: DW_TAG_member, name: "values", scope: !5, file: !3, line: 7, baseType: !8)59!8 = !DICompositeType(tag: DW_TAG_array_type, baseType: !9, elements: !18)60!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64)61!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !5, file: !3, line: 5, size: 64, elements: !11)62!11 = !{!12}63!12 = !DIDerivedType(tag: DW_TAG_member, name: "value", scope: !10, file: !3, line: 6, baseType: !13, size: 64)64!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)65!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "nested_value_type", file: !3, line: 1, size: 32, elements: !15)66!15 = !{!16}67!16 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !14, file: !3, line: 2, baseType: !17, size: 32)68!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)69!18 = !{!19}70!19 = !DISubrange(count: -1)71!20 = !{i32 7, !"Dwarf Version", i32 5}72!21 = !{i32 2, !"Debug Info Version", i32 3}73!22 = !{i32 1, !"wchar_size", i32 4}74!23 = !{i32 7, !"frame-pointer", i32 2}75!24 = !{!"clang version 22.0.0git (git@github.com:llvm/llvm-project.git ed93eaa421b714028b85cc887d80c45991d7207f)"}76