Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
29 changes: 29 additions & 0 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3526,6 +3526,34 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
line = v->base.base.loc.first;
column = 0;
}

if (ASR::is_a<ASR::List_t>(*v->m_type)) {
std::string member_type_name;
uint32_t member_type_size, member_type_encoding;

llvm::DIType *int_type = DBuilder->createBasicType("integer", 32, llvm::dwarf::DW_ATE_signed);
ASR::ttype_t *asr_member_type = ASRUtils::get_contained_type(v->m_type);

get_type_debug_info(asr_member_type, member_type_name,
member_type_size, member_type_encoding);
llvm::DIType *member_type = DBuilder->createBasicType(member_type_name, member_type_size, member_type_encoding);

llvm::DIType *member_pointer_type = DBuilder->createPointerType(member_type, 64, 0, 0, member_type_name+"*");
llvm::DIType *list_type = DBuilder->createStructType(
debug_current_scope, "list", debug_Unit, line, 64+member_type_size, 0, llvm::DINode::FlagZero, nullptr, DBuilder->getOrCreateArray({
DBuilder->createMemberType(debug_Unit, "i321", debug_Unit, line, 32, 0, 0, llvm::DINode::FlagZero, int_type),
DBuilder->createMemberType(debug_Unit, "i322", debug_Unit, line, 32, 32, 0, llvm::DINode::FlagZero, int_type),
DBuilder->createMemberType(debug_Unit, "member", debug_Unit, line, 64, 64, 0, llvm::DINode::FlagZero, member_pointer_type)
}));
llvm::DILocalVariable *debug_var = DBuilder->createParameterVariable(debug_current_scope,
v->m_name, ++debug_arg_count, debug_Unit, line, list_type, true);
DBuilder->insertDeclare(ptr, debug_var, DBuilder->createExpression(),
llvm::DILocation::get(debug_current_scope->getContext(),
line, 0, debug_current_scope), builder->GetInsertBlock());
} else if (ASR::is_a<ASR::Dict_t>(*v->m_type)) {
std::cout << "hi i am dictionary" << std::endl;
} else {

std::string type_name;
uint32_t type_size, type_encoding;
get_type_debug_info(v->m_type, type_name, type_size,
Expand All @@ -3536,6 +3564,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
DBuilder->insertDeclare(ptr, debug_var, DBuilder->createExpression(),
llvm::DILocation::get(debug_current_scope->getContext(),
line, 0, debug_current_scope), builder->GetInsertBlock());
}
}

if( ASR::is_a<ASR::Struct_t>(*v->m_type) ) {
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-dictionary1-a105a36.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-dictionary1-a105a36.stdout",
"stdout_hash": "ac58817e3dc84de980d646cffeb63540c55bde9ca4229b8a7c58b77a",
"stdout_hash": "3ea42309cc8f2201f43bb2fdeb28a85feea890fe49db4063af5c46f8",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
74 changes: 1 addition & 73 deletions tests/reference/asr-dictionary1-a105a36.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,6 @@
[]
[]
[(Assignment
(Var 3 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Integer 4)
)
)
()
)
(Assignment
(Var 3 x)
(DictConstant
[(IntegerConstant 1 (Integer 4))
Expand All @@ -166,18 +154,6 @@
)
()
)
(Assignment
(Var 3 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 3 y)
(DictConstant
Expand Down Expand Up @@ -310,18 +286,6 @@
[]
[]
[(Assignment
(Var 5 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 5 y)
(DictConstant
[(StringConstant
Expand Down Expand Up @@ -426,18 +390,6 @@
[]
[]
[(Assignment
(Var 4 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 4 y)
(DictConstant
[(StringConstant
Expand Down Expand Up @@ -542,18 +494,6 @@
[]
[]
[(Assignment
(Var 6 y)
(DictConstant
[]
[]
(Dict
(Character 1 -2 ())
(Integer 4)
)
)
()
)
(Assignment
(Var 6 y)
(DictConstant
[(StringConstant
Expand Down Expand Up @@ -634,19 +574,7 @@
)
[f]
[]
[(Assignment
(Var 8 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Integer 4)
)
)
()
)
(SubroutineCall
[(SubroutineCall
2 f
()
[((Var 8 x))]
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-print_list_tuple_03-9de3736.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-print_list_tuple_03-9de3736.stdout",
"stdout_hash": "9bc9712a40c386ddbd519614bb9ed900ebde24b5db7d0876f7e88e95",
"stdout_hash": "8962f3d49727ceb8f899acc2382f5fb6d24b16506a154ccf907400f5",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
29 changes: 0 additions & 29 deletions tests/reference/asr-print_list_tuple_03-9de3736.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,6 @@
[]
[]
[(Assignment
(Var 3 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Tuple
[(Integer 4)
(Integer 4)]
)
)
)
()
)
(Assignment
(Var 3 x)
(DictConstant
[(IntegerConstant 1 (Integer 4))
Expand Down Expand Up @@ -155,20 +140,6 @@
)
()
)
(Assignment
(Var 3 y)
(DictConstant
[]
[]
(Dict
(Integer 4)
(List
(Integer 4)
)
)
)
()
)
(Assignment
(Var 3 y)
(DictConstant
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/llvm_dbg-expr_01-9fc5f30.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "llvm_dbg-expr_01-9fc5f30.stdout",
"stdout_hash": "70643017f0ad204393988f111369cdd921c1c297149078182707cb54",
"stdout_hash": "05769e73cdff14fdd425e63737873d8843446992063a8c0715e1b8ba",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
22 changes: 11 additions & 11 deletions tests/reference/llvm_dbg-expr_01-9fc5f30.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ source_filename = "LFortran"
@1 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1
@2 = private unnamed_addr constant [5 x i8] c"%d%s\00", align 1

define void @__module___main_____main__global_stmts() !dbg !3 {
define void @__module___main_____main__global_stmts() !dbg !2 {
.entry:
call void @__module___main___main0(), !dbg !6
br label %return, !dbg !6
Expand Down Expand Up @@ -33,7 +33,7 @@ return: ; preds = %.entry
ret void, !dbg !21
}

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

declare void @_lfortran_printf(i8*, ...)
Expand All @@ -47,18 +47,18 @@ define i32 @main(i32 %0, i8** %1) !dbg !22 {

declare void @_lpython_call_initial_functions(i32, i8**)

attributes #0 = { nounwind readnone speculatable willreturn }
attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }

!llvm.dbg.cu = !{!0}

!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "LPython Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "LPython Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "tests/expr_01.py", directory: ".")
!2 = !{}
!3 = distinct !DISubprogram(name: "__main__global_stmts", scope: !1, file: !1, line: 1, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!4 = !DISubroutineType(types: !5)
!5 = !{null}
!6 = !DILocation(line: 9, column: 1, scope: !3)
!7 = distinct !DISubprogram(name: "main0", scope: !1, file: !1, line: 1, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!2 = distinct !DISubprogram(name: "__main__global_stmts", scope: !1, file: !1, line: 1, type: !3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !5)
!3 = !DISubroutineType(types: !4)
!4 = !{null}
!5 = !{}
!6 = !DILocation(line: 9, column: 1, scope: !2)
!7 = distinct !DISubprogram(name: "main0", scope: !1, file: !1, line: 1, type: !3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !5)
!8 = !DILocation(line: 1, column: 1, scope: !7)
!9 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 2, type: !10)
!10 = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed)
Expand All @@ -73,7 +73,7 @@ attributes #0 = { nounwind readnone speculatable willreturn }
!19 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
!20 = !DILocation(line: 5, scope: !7)
!21 = !DILocation(line: 6, column: 5, scope: !7)
!22 = distinct !DISubprogram(name: "main_program", scope: !1, file: !1, line: 1, type: !23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!22 = distinct !DISubprogram(name: "main_program", scope: !1, file: !1, line: 1, type: !23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !5)
!23 = !DISubroutineType(types: !24)
!24 = !{!10}
!25 = !DILocation(line: 1, column: 1, scope: !22)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "pass_print_list_tuple-print_list_tuple_03-195fa9c.stdout",
"stdout_hash": "edb9d31c77ac27a72de4454275693936ef43c07263a2da687e16da5c",
"stdout_hash": "f63197ac9c1a649cfb2d3a3ef6f6672964ad753593afc68ce6d567e9",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,6 @@
[]
[]
[(Assignment
(Var 3 x)
(DictConstant
[]
[]
(Dict
(Integer 4)
(Tuple
[(Integer 4)
(Integer 4)]
)
)
)
()
)
(Assignment
(Var 3 x)
(DictConstant
[(IntegerConstant 1 (Integer 4))
Expand Down Expand Up @@ -189,20 +174,6 @@
)
()
)
(Assignment
(Var 3 y)
(DictConstant
[]
[]
(Dict
(Integer 4)
(List
(Integer 4)
)
)
)
()
)
(Assignment
(Var 3 y)
(DictConstant
Expand Down