Skip to content

Commit

Permalink
Remove return value freeing
Browse files Browse the repository at this point in the history
  • Loading branch information
advikkabra committed Aug 9, 2024
1 parent 58066c3 commit 757181c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3793,6 +3793,14 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
}
}

if (ASR::is_a<ASR::List_t>(*v->m_type)) {
lists[ptr] = v->m_type;
} else if (ASR::is_a<ASR::Dict_t>(*v->m_type)) {
dictionaries[ptr] = v->m_type;
} else if (ASR::is_a<ASR::Set_t>(*v->m_type)) {
sets[ptr] = v->m_type;
}

llvm_symtab[h] = ptr;
if( (ASRUtils::is_array(v->m_type) &&
((ASRUtils::extract_physical_type(v->m_type) == ASR::array_physical_typeType::DescriptorArray) ||
Expand Down Expand Up @@ -3901,7 +3909,6 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
ASR::List_t* asr_list = ASR::down_cast<ASR::List_t>(v->m_type);
std::string type_code = ASRUtils::get_type_code(asr_list->m_type);
list_api->list_init(type_code, ptr, *module);
lists[ptr] = asr_list->m_type;
}
}
}
Expand Down Expand Up @@ -4172,6 +4179,9 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
ret_val2 = tmp;
}
}
lists.erase(ret_val);
dictionaries.erase(ret_val);
sets.erase(ret_val);
free_heap_structures();
for( auto& value: heap_arrays ) {
LLVM::lfortran_free(context, *module, *builder, value);
Expand Down Expand Up @@ -4846,7 +4856,6 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
list_api->list_deepcopy(value_list, target_list,
value_asr_list, module.get(),
name2memidx);
lists[target_list] = ASRUtils::expr_type(x.m_target);
return ;
} else if( is_target_tuple && is_value_tuple ) {
int64_t ptr_loads_copy = ptr_loads;
Expand Down Expand Up @@ -4915,7 +4924,6 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm_utils->set_dict_api(value_dict_type);
llvm_utils->dict_api->dict_deepcopy(value_dict, target_dict,
value_dict_type, module.get(), name2memidx);
dictionaries[target_dict] = ASRUtils::expr_type(x.m_target);
return ;
} else if( is_target_set && is_value_set ) {
int64_t ptr_loads_copy = ptr_loads;
Expand All @@ -4929,7 +4937,6 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm_utils->set_set_api(value_set_type);
llvm_utils->set_api->set_deepcopy(value_set, target_set,
value_set_type, module.get(), name2memidx);
sets[target_set] = ASRUtils::expr_type(x.m_target);
return ;
} else if( is_target_struct && is_value_struct ) {
int64_t ptr_loads_copy = ptr_loads;
Expand Down

0 comments on commit 757181c

Please sign in to comment.