Skip to content

Commit

Permalink
Merge pull request #2707 from Vipul-Cariappa/symbol-duplication
Browse files Browse the repository at this point in the history
Fixes complex datatype's symbol duplication bug while using interactive
  • Loading branch information
Shaikh-Ubaid authored May 16, 2024
2 parents 5cf0594 + 0d56d14 commit fbbdbdd
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/libasr/codegen/asr_to_llvm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2806,33 +2806,41 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
llvm::StructType* list_type = static_cast<llvm::StructType*>(
llvm_utils->get_type_from_ttype_t_util(x.m_type, module.get()));
llvm::Constant *ptr = module->getOrInsertGlobal(x.m_name, list_type);
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(list_type,
llvm::Constant::getNullValue(list_type)));
if (!external) {
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(list_type,
llvm::Constant::getNullValue(list_type)));
}
llvm_symtab[h] = ptr;
} else if (x.m_type->type == ASR::ttypeType::Tuple) {
llvm::StructType* tuple_type = static_cast<llvm::StructType*>(
llvm_utils->get_type_from_ttype_t_util(x.m_type, module.get()));
llvm::Constant *ptr = module->getOrInsertGlobal(x.m_name, tuple_type);
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(tuple_type,
llvm::Constant::getNullValue(tuple_type)));
if (!external) {
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(tuple_type,
llvm::Constant::getNullValue(tuple_type)));
}
llvm_symtab[h] = ptr;
} else if(x.m_type->type == ASR::ttypeType::Dict) {
llvm::StructType* dict_type = static_cast<llvm::StructType*>(
llvm_utils->get_type_from_ttype_t_util(x.m_type, module.get()));
llvm::Constant *ptr = module->getOrInsertGlobal(x.m_name, dict_type);
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(dict_type,
llvm::Constant::getNullValue(dict_type)));
if (!external) {
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(dict_type,
llvm::Constant::getNullValue(dict_type)));
}
llvm_symtab[h] = ptr;
} else if(x.m_type->type == ASR::ttypeType::Set) {
llvm::StructType* set_type = static_cast<llvm::StructType*>(
llvm_utils->get_type_from_ttype_t_util(x.m_type, module.get()));
llvm::Constant *ptr = module->getOrInsertGlobal(x.m_name, set_type);
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(set_type,
llvm::Constant::getNullValue(set_type)));
if (!external) {
module->getNamedGlobal(x.m_name)->setInitializer(
llvm::ConstantStruct::get(set_type,
llvm::Constant::getNullValue(set_type)));
}
llvm_symtab[h] = ptr;
} else if (x.m_type->type == ASR::ttypeType::TypeParameter) {
// Ignore type variables
Expand Down

0 comments on commit fbbdbdd

Please sign in to comment.