88 lines · plain
1; RUN: llc -mtriple=bpfel -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; RUN: llc -mtriple=bpfeb -filetype=obj -o %t1 %s5; RUN: llvm-objcopy --dump-section='.BTF'=%t2 %t16; RUN: %python %p/print_btf.py %t2 | FileCheck -check-prefixes=CHECK-BTF %s7;8; Source:9; #![no_std]10; #![no_main]11;12; pub enum MyEnum {13; First { a: u32, b: i32 },14; Second(u32),15; }16;17; #[unsafe(no_mangle)]18; pub static X: MyEnum = MyEnum::First { a: 54, b: -23 };19;20; #[cfg(not(test))]21; #[panic_handler]22; fn panic(_info: &core::panic::PanicInfo) -> ! {23; loop {}24; }25; Compilation flag:26; cargo +nightly rustc -Zbuild-std=core --target=bpfel-unknown-none -- --emit=llvm-bc27; llvm-extract --glob=X $(find target/ -name "*.bc" | head -n 1) -o variant-part.bc28; llvm-dis variant-part.bc -o variant-part.ll29 30; ModuleID = 'variant-part.bc'31source_filename = "c0znihgkvro8hs0n88fgrtg6x"32target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128"33target triple = "bpfel"34 35@X = constant [12 x i8] c"\00\00\00\006\00\00\00\E9\FF\FF\FF", align 4, !dbg !036 37!llvm.module.flags = !{!22, !23, !24, !25}38!llvm.ident = !{!26}39!llvm.dbg.cu = !{!27}40 41; CHECK-BTF: [1] STRUCT 'MyEnum' size=12 vlen=142; CHECK-BTF-NEXT: '(anon)' type_id=3 bits_offset=043; CHECK-BTF-NEXT: [2] INT 'u32' size=4 bits_offset=0 nr_bits=32 encoding=(none)44; CHECK-BTF-NEXT: [3] UNION '(anon)' size=12 vlen=345; CHECK-BTF-NEXT: '(anon)' type_id=2 bits_offset=046; CHECK-BTF-NEXT: 'First' type_id=4 bits_offset=047; CHECK-BTF-NEXT: 'Second' type_id=6 bits_offset=048; CHECK-BTF-NEXT: [4] STRUCT 'First' size=12 vlen=249; CHECK-BTF-NEXT: 'a' type_id=2 bits_offset=3250; CHECK-BTF-NEXT: 'b' type_id=5 bits_offset=6451; CHECK-BTF-NEXT: [5] INT 'i32' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED52; CHECK-BTF-NEXT: [6] STRUCT 'Second' size=12 vlen=153; CHECK-BTF-NEXT: '__0' type_id=2 bits_offset=3254; CHECK-BTF-NEXT: [7] VAR 'X' type_id=1, linkage=global55; CHECK-BTF-NEXT: [8] DATASEC '.rodata' size=0 vlen=156; CHECK-BTF-NEXT: type_id=7 offset=0 size=1257 58!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())59!1 = distinct !DIGlobalVariable(name: "X", scope: !2, file: !3, line: 10, type: !4, isLocal: false, isDefinition: true, align: 32)60!2 = !DINamespace(name: "variant_part", scope: null)61!3 = !DIFile(filename: "variant-part/src/main.rs", directory: "/tmp/variant-part", checksumkind: CSK_MD5, checksum: "b94cd53886ea8f14cbc116b36bc7dd36")62!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyEnum", scope: !2, file: !5, size: 96, align: 32, flags: DIFlagPublic, elements: !6, templateParams: !16, identifier: "faba668fd9f71e9b7cf3b9ac5e8b93cb")63!5 = !DIFile(filename: "<unknown>", directory: "")64!6 = !{!7}65!7 = !DICompositeType(tag: DW_TAG_variant_part, scope: !4, file: !5, size: 96, align: 32, elements: !8, templateParams: !16, identifier: "e4aee046fc86d111657622fdcb8c42f7", discriminator: !21)66!8 = !{!9, !17}67!9 = !DIDerivedType(tag: DW_TAG_member, name: "First", scope: !7, file: !5, baseType: !10, size: 96, align: 32, extraData: i32 0)68!10 = !DICompositeType(tag: DW_TAG_structure_type, name: "First", scope: !4, file: !5, size: 96, align: 32, flags: DIFlagPublic, elements: !11, templateParams: !16, identifier: "cc7748c842e275452db4205b190c8ff7")69!11 = !{!12, !14}70!12 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !10, file: !5, baseType: !13, size: 32, align: 32, offset: 32, flags: DIFlagPublic)71!13 = !DIBasicType(name: "u32", size: 32, encoding: DW_ATE_unsigned)72!14 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !10, file: !5, baseType: !15, size: 32, align: 32, offset: 64, flags: DIFlagPublic)73!15 = !DIBasicType(name: "i32", size: 32, encoding: DW_ATE_signed)74!16 = !{}75!17 = !DIDerivedType(tag: DW_TAG_member, name: "Second", scope: !7, file: !5, baseType: !18, size: 96, align: 32, extraData: i32 1)76!18 = !DICompositeType(tag: DW_TAG_structure_type, name: "Second", scope: !4, file: !5, size: 96, align: 32, flags: DIFlagPublic, elements: !19, templateParams: !16, identifier: "a2094b1381f3082d504fbd0903aa7c06")77!19 = !{!20}78!20 = !DIDerivedType(tag: DW_TAG_member, name: "__0", scope: !18, file: !5, baseType: !13, size: 32, align: 32, offset: 32, flags: DIFlagPublic)79!21 = !DIDerivedType(tag: DW_TAG_member, scope: !4, file: !5, baseType: !13, size: 32, align: 32, flags: DIFlagArtificial)80!22 = !{i32 8, !"PIC Level", i32 2}81!23 = !{i32 7, !"PIE Level", i32 2}82!24 = !{i32 7, !"Dwarf Version", i32 4}83!25 = !{i32 2, !"Debug Info Version", i32 3}84!26 = !{!"rustc version 1.91.0-nightly (160e7623e 2025-08-26)"}85!27 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !28, producer: "clang LLVM (rustc version 1.91.0-nightly (160e7623e 2025-08-26))", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !29, splitDebugInlining: false, nameTableKind: None)86!28 = !DIFile(filename: "variant-part/src/main.rs/@/c0znihgkvro8hs0n88fgrtg6x", directory: "/tmp/variant-part")87!29 = !{!0}88