@@ -2806,33 +2806,41 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
28062806 llvm::StructType* list_type = static_cast <llvm::StructType*>(
28072807 llvm_utils->get_type_from_ttype_t_util (x.m_type , module .get ()));
28082808 llvm::Constant *ptr = module ->getOrInsertGlobal (x.m_name , list_type);
2809- module ->getNamedGlobal (x.m_name )->setInitializer (
2810- llvm::ConstantStruct::get (list_type,
2811- llvm::Constant::getNullValue (list_type)));
2809+ if (!external) {
2810+ module ->getNamedGlobal (x.m_name )->setInitializer (
2811+ llvm::ConstantStruct::get (list_type,
2812+ llvm::Constant::getNullValue (list_type)));
2813+ }
28122814 llvm_symtab[h] = ptr;
28132815 } else if (x.m_type ->type == ASR::ttypeType::Tuple) {
28142816 llvm::StructType* tuple_type = static_cast <llvm::StructType*>(
28152817 llvm_utils->get_type_from_ttype_t_util (x.m_type , module .get ()));
28162818 llvm::Constant *ptr = module ->getOrInsertGlobal (x.m_name , tuple_type);
2817- module ->getNamedGlobal (x.m_name )->setInitializer (
2818- llvm::ConstantStruct::get (tuple_type,
2819- llvm::Constant::getNullValue (tuple_type)));
2819+ if (!external) {
2820+ module ->getNamedGlobal (x.m_name )->setInitializer (
2821+ llvm::ConstantStruct::get (tuple_type,
2822+ llvm::Constant::getNullValue (tuple_type)));
2823+ }
28202824 llvm_symtab[h] = ptr;
28212825 } else if (x.m_type ->type == ASR::ttypeType::Dict) {
28222826 llvm::StructType* dict_type = static_cast <llvm::StructType*>(
28232827 llvm_utils->get_type_from_ttype_t_util (x.m_type , module .get ()));
28242828 llvm::Constant *ptr = module ->getOrInsertGlobal (x.m_name , dict_type);
2825- module ->getNamedGlobal (x.m_name )->setInitializer (
2826- llvm::ConstantStruct::get (dict_type,
2827- llvm::Constant::getNullValue (dict_type)));
2829+ if (!external) {
2830+ module ->getNamedGlobal (x.m_name )->setInitializer (
2831+ llvm::ConstantStruct::get (dict_type,
2832+ llvm::Constant::getNullValue (dict_type)));
2833+ }
28282834 llvm_symtab[h] = ptr;
28292835 } else if (x.m_type ->type == ASR::ttypeType::Set) {
28302836 llvm::StructType* set_type = static_cast <llvm::StructType*>(
28312837 llvm_utils->get_type_from_ttype_t_util (x.m_type , module .get ()));
28322838 llvm::Constant *ptr = module ->getOrInsertGlobal (x.m_name , set_type);
2833- module ->getNamedGlobal (x.m_name )->setInitializer (
2834- llvm::ConstantStruct::get (set_type,
2835- llvm::Constant::getNullValue (set_type)));
2839+ if (!external) {
2840+ module ->getNamedGlobal (x.m_name )->setInitializer (
2841+ llvm::ConstantStruct::get (set_type,
2842+ llvm::Constant::getNullValue (set_type)));
2843+ }
28362844 llvm_symtab[h] = ptr;
28372845 } else if (x.m_type ->type == ASR::ttypeType::TypeParameter) {
28382846 // Ignore type variables
0 commit comments