Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Dwarf vector test (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcivlin authored Jan 10, 2024
1 parent 305727f commit 76dc797
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ target-out-docker
**/move-mv-llvm-compiler/**/dwarf-tests/dwarf-struct-build/stored_results/*
**/move-mv-llvm-compiler/**/dwarf-tests/dwarf-struct-2-modules-build/stored_results/*
**/move-mv-llvm-compiler/**/dwarf-tests/dwarf-functions-build/stored_results/*
**/move-mv-llvm-compiler/**/dwarf-tests/dwarf-vector-build/stored_results/*
**/move-mv-llvm-compiler/**/rbpf-tests/**/*.mv
**/move-mv-llvm-compiler/**/rbpf-tests/**/*.o
**/move-mv-llvm-compiler/**/rbpf-tests/**/*.so
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
; ModuleID = '0x101__vector.dbg_info'
source_filename = "/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector.move"

!llvm.dbg.cu = !{!0}
!unspecified\20type = !{!2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2, !2}
!struct.vector__Foo = !{!6}
!struct.vector__Bar = !{!14}
!test_singleton_contains = !{!19}
!singleton = !{!23, !28}

!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: "dwarf-vector.move", directory: "/language/tools/move-mv-llvm-compiler/tests/dwarf-tests")
!2 = !DICompositeType(tag: DW_TAG_array_type, baseType: !3, size: 192, align: 8, flags: DIFlagVector, elements: !4)
!3 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "unspecified type")
!4 = !{!5}
!5 = !DISubrange(count: 1, lowerBound: 0)
!6 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.vector__Foo__ptr", baseType: !7, size: 64, align: 64, dwarfAddressSpace: 0)
!7 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.vector__Foo", scope: !8, file: !1, line: 2, size: 128, align: 8, flags: DIFlagObjcClassComplete, elements: !9)
!8 = !DINamespace(name: "struct.vector__Foo", scope: !1)
!9 = !{!10, !12}
!10 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !8, file: !1, line: 2, baseType: !11, size: 64, align: 64)
!11 = !DIBasicType(name: "u64", size: 64)
!12 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !8, file: !1, line: 3, baseType: !13, size: 1, align: 8, offset: 64)
!13 = !DIBasicType(name: "bool", size: 8)
!14 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.vector__Bar__ptr", baseType: !15, size: 64, align: 64, dwarfAddressSpace: 0)
!15 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.vector__Bar", scope: !16, file: !1, line: 3, size: 128, align: 8, flags: DIFlagObjcClassComplete, elements: !17)
!16 = !DINamespace(name: "struct.vector__Bar", scope: !1)
!17 = !{!18}
!18 = !DIDerivedType(tag: DW_TAG_member, name: "foo", scope: !16, file: !1, line: 3, baseType: !7, size: 128, align: 64)
!19 = distinct !DISubprogram(name: "test_singleton_contains", linkageName: "test_singleton_contains", scope: !20, file: !1, line: 17, type: !21, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !22)
!20 = !DINamespace(name: "test_singleton_contains", scope: !1)
!21 = !DISubroutineType(types: !22)
!22 = !{}
!23 = distinct !DISubprogram(name: "singleton", linkageName: "singleton", scope: !24, file: !1, line: 11, type: !25, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !22)
!24 = !DINamespace(name: "singleton", scope: !1)
!25 = !DISubroutineType(types: !26)
!26 = !{!27}
!27 = !DILocalVariable(name: "e", scope: !24, file: !1, type: !7)
!28 = distinct !DISubprogram(name: "singleton", linkageName: "singleton", scope: !24, file: !1, line: 11, type: !29, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !22)
!29 = !DISubroutineType(types: !30)
!30 = !{!31}
!31 = !DILocalVariable(name: "e", scope: !24, file: !1, type: !15)
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module 0x101::vector {

struct Foo has copy, drop { x: u64, y: bool }
struct Bar has copy, drop { foo: Foo }

native public fun empty<Element>(): vector<Element>;

native public fun borrow<Element>(v: &vector<Element>, i: u64): &Element;

native public fun push_back<Element>(v: &mut vector<Element>, e: Element);

public fun singleton<Element>(e: Element): vector<Element> {
let v = empty();
push_back(&mut v, e);
v
}

public fun test_singleton_contains() {
let foo1 = Foo { x: 0, y: false };
assert!(*borrow(&singleton(foo1), 0) == foo1, 0);

let bar1 = Bar { foo: foo1 };
assert!(*borrow(&singleton(bar1), 0) == bar1, 0);
}
}

0 comments on commit 76dc797

Please sign in to comment.