anza-xyz / move

Move compiler targeting llvm supported backends
https://discord.gg/wFgfjG9J
Apache License 2.0
108 stars 34 forks source link

WIP]] Dwarf struct #394

Closed jcivlin closed 10 months ago

jcivlin commented 1 year ago

Added dwarf info for struct. For simple struct like

module 0x100::M {

    struct MyStruct {
        field1: u32,
        field2: bool,
        field3: EmptyStruct
    }

    struct EmptyStruct {}

    public fun boofun(): 0x100::M::MyStruct {
        MyStruct { field1: 32, field2: true, field3: EmptyStruct {} }
    }
}

expected:

; ModuleID = '0x100__M.dbg_info'
source_filename = "/home/sol/work/git/move-100623/language/tools/move-mv-llvm-compiler/tests/move-to-llvm-tests/struct01.move"

!llvm.dbg.cu = !{!0}
!struct.M__EmptyStruct = !{!2}
!struct.M__MyStruct = !{!8}

!0 = distinct !DICompileUnit(language: DW_LANG_Rust, file: !1, producer: "move-mv-llvm-compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, sysroot: "/")
!1 = !DIFile(filename: "struct01.move", directory: "/home/sol/work/git/move-100623/language/tools/move-mv-llvm-compiler/tests/move-to-llvm-tests")
!2 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.M__EmptyStruct__ptr", baseType: !3, size: 192, align: 192, dwarfAddressSpace: 0)
!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.M__EmptyStruct", scope: !4, file: !1, line: 9, flags: DIFlagObjcClassComplete, elements: !5)
!4 = !DINamespace(name: "struct.M__EmptyStruct", scope: !1)
!5 = !{!6}
!6 = !DIDerivedType(tag: DW_TAG_member, name: "dummy_field", scope: !4, file: !1, line: 10, baseType: !7)
!7 = !DIBasicType(name: "u32", size: 32)
!8 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.M__MyStruct__ptr", baseType: !9, size: 192, align: 192, dwarfAddressSpace: 0)
!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.M__MyStruct", scope: !10, file: !1, line: 3, flags: DIFlagObjcClassComplete, elements: !11)
!10 = !DINamespace(name: "struct.M__MyStruct", scope: !1)
!11 = !{!12, !13, !14}
!12 = !DIDerivedType(tag: DW_TAG_member, name: "field1", scope: !10, file: !1, line: 4, baseType: !7)
!13 = !DIDerivedType(tag: DW_TAG_member, name: "field2", scope: !10, file: !1, line: 5, baseType: !7)
!14 = !DIDerivedType(tag: DW_TAG_member, name: "field3", scope: !10, file: !1, line: 6, baseType: !7)
ksolana commented 10 months ago

is this patch still required or is getting superseded by #395?

jcivlin commented 10 months ago

no, you can skip all of them and go straight to https://github.com/solana-labs/move/pull/402, which encompasses all dwarf work at the moment.

jcivlin commented 10 months ago

Close due to #402