diff --git a/.gitignore b/.gitignore index dd0f36e7cf..ca3f798861 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector-build/0x101__vector.ll.debug_info.expected b/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector-build/0x101__vector.ll.debug_info.expected new file mode 100644 index 0000000000..deeac1ea8d --- /dev/null +++ b/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector-build/0x101__vector.ll.debug_info.expected @@ -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) diff --git a/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector.move b/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector.move new file mode 100644 index 0000000000..53307e482c --- /dev/null +++ b/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf-vector.move @@ -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(): vector; + + native public fun borrow(v: &vector, i: u64): ∈ + + native public fun push_back(v: &mut vector, e: Element); + + public fun singleton(e: Element): vector { + 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); + } +}