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

Commit

Permalink
More load-store instructions debug support (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcivlin authored Mar 14, 2024
1 parent 8af22c3 commit 6981a47
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 41 deletions.
37 changes: 26 additions & 11 deletions language/solana/move-to-solana/src/stackless/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ impl<'mm, 'up> FunctionContext<'mm, 'up> {
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Reference(_, _) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Struct(_, _, _) => {
// A move renders the source location inaccessible, but the storage is
Expand All @@ -401,9 +402,11 @@ impl<'mm, 'up> FunctionContext<'mm, 'up> {
self.locals[*dst] = self.locals[*src].clone();
}
mty::Type::Vector(_) => {
self.module_cx
let (load, store) = self
.module_cx
.llvm_builder
.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
_ => todo!("{mty:?}"),
}
Expand All @@ -423,13 +426,16 @@ impl<'mm, 'up> FunctionContext<'mm, 'up> {
| mty::PrimitiveType::U128
| mty::PrimitiveType::U256,
) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Struct(_, _, _) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Primitive(mty::PrimitiveType::Address) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Vector(elt_mty) => {
self.module_cx.emit_rtcall_with_retval(RtCall::VecCopy(
Expand All @@ -440,10 +446,14 @@ impl<'mm, 'up> FunctionContext<'mm, 'up> {
}
mty::Type::Reference(_, referent) => match **referent {
mty::Type::Struct(_, _, _) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg
.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
_ => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg
.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
},
_ => todo!("{mty:?}"),
Expand All @@ -466,18 +476,23 @@ impl<'mm, 'up> FunctionContext<'mm, 'up> {
| mty::PrimitiveType::Address
| mty::PrimitiveType::Signer,
) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Reference(_, _) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Struct(_, _, _) => {
builder.load_store(llty, src_llval, dst_llval);
let (load, store) = builder.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
mty::Type::Vector(_) => {
self.module_cx
let (load, store) = self
.module_cx
.llvm_builder
.load_store(llty, src_llval, dst_llval);
instr_dbg.create_load_store(load, store, mty, llty, src_llval, dst_llval);
}
_ => todo!("{mty:#?}"),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ entry:
%local_2 = alloca ptr, align 8
%local_3 = alloca [32 x i8], align 1
store ptr %s, ptr %local_0, align 8
%load_store_tmp = load ptr, ptr %local_0, align 8
store ptr %load_store_tmp, ptr %local_1, align 8
%load_store_tmp = load ptr, ptr %local_0, align 8, !dbg !10
store ptr %load_store_tmp, ptr %local_1, align 8, !dbg !10
call void @llvm.dbg.declare(metadata ptr %local_0, metadata !11, metadata !DIExpression()), !dbg !10
call void @llvm.dbg.declare(metadata ptr %local_1, metadata !13, metadata !DIExpression()), !dbg !10
%loaded_alloca = load ptr, ptr %local_1, align 8
%retval = call ptr @move_native_signer_borrow_address(ptr %loaded_alloca)
store ptr %retval, ptr %local_2, align 8
Expand All @@ -26,6 +28,11 @@ entry:

declare ptr @move_native_signer_borrow_address(ptr)

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare void @llvm.dbg.declare(metadata, metadata, metadata) #0

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!llvm.dbg.cu = !{!0}
!address_of = !{!2, !7, !8, !9}

Expand All @@ -39,3 +46,8 @@ declare ptr @move_native_signer_borrow_address(ptr)
!7 = distinct !DILexicalBlock(scope: !2, file: !1, line: 10)
!8 = !DINamespace(name: "address_of", scope: !1)
!9 = !DILocation(line: 11, column: 4, scope: !7)
!10 = !DILocation(line: 13, column: 25, scope: !2)
!11 = !DILocalVariable(name: "load_store_./../../../../../move-stdlib/sources/signer.move_13_s", scope: !12, file: !1, line: 13, type: !5)
!12 = distinct !DILexicalBlock(scope: !2, file: !1, line: 13, column: 25)
!13 = !DILocalVariable(name: "load_store_./../../../../../move-stdlib/sources/signer.move_13_s", scope: !14, file: !1, line: 13, type: !5)
!14 = distinct !DILexicalBlock(scope: !2, file: !1, line: 13, column: 25)
Loading

0 comments on commit 6981a47

Please sign in to comment.