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

Dwarf: vector element type resolution #405

Merged
merged 4 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions language/solana/move-to-solana/src/stackless/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,16 +538,27 @@ impl<'up> DIBuilder<'up> {

pub fn create_vector(
&self,
mty: mty::Type,
mvec: &[mty::Type],
llvec: &Type,
llmod: &Module,
_parent: Option<LLVMMetadataRef>,
) {
if mvec.is_empty() {
return;
};

if let Some(_di_builder_core) = &self.0 {
let di_builder = self.builder_ref().unwrap();

let mty = mvec.get(0).unwrap(); // exists since !mvec.is_empty()
let vec_di_type = self.get_type(mty.clone(), &"unnamed-vector".to_string());
if vec_di_type == self.core().type_unspecified {
return; // proceed only when type is known
}

let llvec_info = llvec.print_to_str();
debug!(target: "vector", "create_vector {llvec_info}");
let vec_di_type = self.get_type(mty, &"unnamed-vector".to_string());

let mut vec_name_length: ::libc::size_t = 0;
let vec_name_c_str = unsafe { LLVMDITypeGetName(vec_di_type, &mut vec_name_length) };
let vec_name = unsafe {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ impl<'mm: 'up, 'up> ModuleContext<'mm, 'up> {
unreachable!("")
}
}
Type::Vector(_) => Some(self.rtty_cx.get_llvm_type_for_move_vector(self, mty)),
Type::Vector(_) => Some(self.rtty_cx.get_llvm_type_for_move_vector(self, tyvec)),
Type::Tuple(_) => {
todo!("{mty:?}")
}
Expand Down
11 changes: 7 additions & 4 deletions language/solana/move-to-solana/src/stackless/rttydesc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl<'mm, 'up> RttyContext<'mm, 'up> {
pub fn get_llvm_type_for_move_vector(
&self,
m_ctx: &ModuleContext,
mty: &mty::Type,
mvec: &[mty::Type],
) -> llvm::Type {
let llcx = self.get_llvm_cx();
let ty = llcx.get_anonymous_struct_type(&[
Expand All @@ -87,9 +87,12 @@ impl<'mm, 'up> RttyContext<'mm, 'up> {
let info = ty.print_to_str();
debug!(target: "rtty", "get_llvm_type_for_move_vector: {info}");
let llmod = self.get_llvm_module();
m_ctx
.llvm_di_builder
.create_vector(mty.clone(), &ty, llmod, None);
let ty_display_ctx = &self.g_env.get_type_display_ctx();
for mty in mvec.iter() {
let tyv_display = &mty.display(ty_display_ctx);
debug!(target: "rtty", "get_llvm_type_for_move_vector: {tyv_display}");
}
m_ctx.llvm_di_builder.create_vector(mvec, &ty, llmod, None);
ty
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,30 @@
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}
!struct.vector__Foo = !{!2, !10, !10, !10}
!struct.vector__Bar = !{!13, !18, !18, !18}
!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)
!2 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.vector__Foo__ptr", baseType: !3, size: 64, align: 64, dwarfAddressSpace: 0)
!3 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.vector__Foo", scope: !4, file: !1, line: 2, size: 128, align: 8, flags: DIFlagObjcClassComplete, elements: !5)
!4 = !DINamespace(name: "struct.vector__Foo", scope: !1)
!5 = !{!6, !8}
!6 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 2, baseType: !7, size: 64, align: 64)
!7 = !DIBasicType(name: "u64", size: 64)
!8 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !4, file: !1, line: 3, baseType: !9, size: 1, align: 8, offset: 64)
!9 = !DIBasicType(name: "bool", size: 8)
!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !3, size: 192, align: 8, flags: DIFlagVector, elements: !11)
!11 = !{!12}
!12 = !DISubrange(count: 1, lowerBound: 0)
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "struct.vector__Bar__ptr", baseType: !14, size: 64, align: 64, dwarfAddressSpace: 0)
!14 = !DICompositeType(tag: DW_TAG_structure_type, name: "struct.vector__Bar", scope: !15, file: !1, line: 3, size: 128, align: 8, flags: DIFlagObjcClassComplete, elements: !16)
!15 = !DINamespace(name: "struct.vector__Bar", scope: !1)
!16 = !{!17}
!17 = !DIDerivedType(tag: DW_TAG_member, name: "foo", scope: !15, file: !1, line: 3, baseType: !3, size: 128, align: 64)
!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !14, size: 192, align: 8, flags: DIFlagVector, elements: !11)
!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)
Expand All @@ -35,8 +34,8 @@ source_filename = "/language/tools/move-mv-llvm-compiler/tests/dwarf-tests/dwarf
!24 = !DINamespace(name: "singleton", scope: !1)
!25 = !DISubroutineType(types: !26)
!26 = !{!27}
!27 = !DILocalVariable(name: "e", scope: !24, file: !1, type: !7)
!27 = !DILocalVariable(name: "e", scope: !24, file: !1, type: !3)
!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)
!31 = !DILocalVariable(name: "e", scope: !24, file: !1, type: !14)
Loading