@@ -1613,7 +1613,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
1613
1613
int64_t ptr_loads_copy = ptr_loads;
1614
1614
ptr_loads = 0 ;
1615
1615
this ->visit_expr (*x.m_a );
1616
- llvm::Value* plist = tmp;
1616
+ llvm::Value* plist = builder-> CreateBitCast ( tmp, list_type) ;
1617
1617
1618
1618
ptr_loads = !LLVM::is_llvm_struct (asr_list->m_type );
1619
1619
this ->visit_expr_wrapper (x.m_ele , true );
@@ -1652,7 +1652,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
1652
1652
int64_t ptr_loads_copy = ptr_loads;
1653
1653
ptr_loads = 0 ;
1654
1654
this ->visit_expr (*x.m_a );
1655
- llvm::Value* plist = tmp;
1655
+ llvm::Value* plist = builder-> CreateBitCast ( tmp, list_type) ;
1656
1656
1657
1657
ptr_loads = 1 ;
1658
1658
this ->visit_expr_wrapper (x.m_pos , true );
@@ -1707,7 +1707,7 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
1707
1707
ptr_loads = 0 ;
1708
1708
this ->visit_expr (*x.m_arg );
1709
1709
ptr_loads = ptr_loads_copy;
1710
- llvm::Value* plist = tmp;
1710
+ llvm::Value* plist = builder-> CreateBitCast ( tmp, list_type) ;
1711
1711
tmp = list_api->len (plist);
1712
1712
}
1713
1713
}
@@ -2295,6 +2295,21 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
2295
2295
}
2296
2296
}
2297
2297
llvm_symtab[h] = ptr;
2298
+ } else if (x.m_type ->type == ASR::ttypeType::List) {
2299
+ ASR::storage_typeType m_storage = ASR::storage_typeType::Default;
2300
+ bool is_array_type = false , is_malloc_array_type = false , is_list = false ;
2301
+ ASR::dimension_t * m_dims = nullptr ;
2302
+ int n_dims = -1 , a_kind = -1 ;
2303
+ list_type = get_type_from_ttype_t (x.m_type , m_storage, is_array_type,
2304
+ is_malloc_array_type, is_list, m_dims, n_dims, a_kind)->getPointerTo ();
2305
+ llvm::Type* void_ptr = llvm::Type::getVoidTy (context)->getPointerTo ();
2306
+ llvm::Constant *ptr = module->getOrInsertGlobal (x.m_name ,
2307
+ void_ptr);
2308
+ module->getNamedGlobal (x.m_name )->setInitializer (
2309
+ llvm::ConstantPointerNull::get (
2310
+ static_cast <llvm::PointerType*>(void_ptr))
2311
+ );
2312
+ llvm_symtab[h] = ptr;
2298
2313
} else if (x.m_type ->type == ASR::ttypeType::TypeParameter) {
2299
2314
// Ignore type variables
2300
2315
} else {
0 commit comments