87 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 %s4; Source:5; #define __tag1 __attribute__((btf_type_tag("tag1")))6;7; struct t1 {8; int a;9; };10; struct t2 {11; struct t1 *p1;12; struct t1 __tag1 *p2;13; int b;14; };15; int foo(struct t2 *arg) {16; return arg->b;17; }18; Compilation flags:19; clang -target bpf -O2 -g -S -emit-llvm t.c20 21; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read)22define dso_local i32 @foo(ptr nocapture noundef readonly %0) local_unnamed_addr #0 !dbg !8 {23 #dbg_value(ptr %0, !26, !DIExpression(), !27)24 %2 = getelementptr inbounds nuw i8, ptr %0, i64 16, !dbg !2825 %3 = load i32, ptr %2, align 8, !dbg !28, !tbaa !2926 ret i32 %3, !dbg !3627}28 29; CHECK-BTF: [1] PTR '(anon)' type_id=230; CHECK-BTF: [2] STRUCT 't2' size=24 vlen=331; CHECK-BTF: 'p1' type_id=3 bits_offset=032; CHECK-BTF: 'p2' type_id=5 bits_offset=6433; CHECK-BTF: 'b' type_id=7 bits_offset=12834; CHECK-BTF: [3] PTR '(anon)' type_id=635; CHECK-BTF: [4] TYPE_TAG 'tag1' type_id=636; CHECK-BTF: [5] PTR '(anon)' type_id=437; CHECK-BTF: [6] STRUCT 't1' size=4 vlen=138; CHECK-BTF: 'a' type_id=7 bits_offset=039; CHECK-BTF: [7] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED40; CHECK-BTF: [8] FUNC_PROTO '(anon)' ret_type_id=7 vlen=141; CHECK-BTF: 'arg' type_id=142; CHECK-BTF: [9] FUNC 'foo' type_id=8 linkage=global43 44attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }45 46!llvm.dbg.cu = !{!0}47!llvm.module.flags = !{!2, !3, !4, !5, !6}48!llvm.ident = !{!7}49 50!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.1.6 (https://github.com/llvm/llvm-project.git aa804fd3e624cb92c6e7665182504c6049387f35)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)51!1 = !DIFile(filename: "t.c", directory: "/tmp/home/yhs/tmp3/tests", checksumkind: CSK_MD5, checksum: "73ef5b93654cc4e2667f383d5c3a9cd3")52!2 = !{i32 7, !"Dwarf Version", i32 5}53!3 = !{i32 2, !"Debug Info Version", i32 3}54!4 = !{i32 1, !"wchar_size", i32 4}55!5 = !{i32 7, !"frame-pointer", i32 2}56!6 = !{i32 7, !"debug-info-assignment-tracking", i1 true}57!7 = !{!"clang version 20.1.6 (https://github.com/llvm/llvm-project.git aa804fd3e624cb92c6e7665182504c6049387f35)"}58!8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 11, type: !9, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !25)59!9 = !DISubroutineType(types: !10)60!10 = !{!11, !12}61!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)62!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)63!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t2", file: !1, line: 6, size: 192, elements: !14)64!14 = !{!15, !20, !24}65!15 = !DIDerivedType(tag: DW_TAG_member, name: "p1", scope: !13, file: !1, line: 7, baseType: !16, size: 64)66!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64)67!17 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !1, line: 3, size: 32, elements: !18)68!18 = !{!19}69!19 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !17, file: !1, line: 4, baseType: !11, size: 32)70!20 = !DIDerivedType(tag: DW_TAG_member, name: "p2", scope: !13, file: !1, line: 8, baseType: !21, size: 64, offset: 64)71!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !17, size: 64, annotations: !22)72!22 = !{!23}73!23 = !{!"btf_type_tag", !"tag1"}74!24 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !13, file: !1, line: 9, baseType: !11, size: 32, offset: 128)75!25 = !{!26}76!26 = !DILocalVariable(name: "arg", arg: 1, scope: !8, file: !1, line: 11, type: !12)77!27 = !DILocation(line: 0, scope: !8)78!28 = !DILocation(line: 12, column: 15, scope: !8)79!29 = !{!30, !35, i64 16}80!30 = !{!"t2", !31, i64 0, !31, i64 8, !35, i64 16}81!31 = !{!"p1 _ZTS2t1", !32, i64 0}82!32 = !{!"any pointer", !33, i64 0}83!33 = !{!"omnipotent char", !34, i64 0}84!34 = !{!"Simple C/C++ TBAA"}85!35 = !{!"int", !33, i64 0}86!36 = !DILocation(line: 12, column: 3, scope: !8)87