From the above ASR, the variable x must be included in the _lpython_main_program SymbolTable, right?
Is this a bug or we have not handled the global variable yet? or is this expected output?
$ lpython examples/expr2.py
...
File "/home/thirumalai/Open_Source/lpython/src/libasr/../libasr/asr.h", line 4150, in LFortran::ASR::BaseVisitor<LFortran::ASRToLLVMVisitor>::visit_symbol(LFortran::ASR::symbol_t const&)
void visit_symbol(const symbol_t &b) { visit_symbol_t(b, self()); }
File "/home/thirumalai/Open_Source/lpython/src/libasr/../libasr/asr.h", line 3919, in ??
case symbolType::Variable: { v.visit_Variable((const Variable_t &)x); return; }
File "/home/thirumalai/Open_Source/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 1999, in LFortran::ASRToLLVMVisitor::visit_Variable(LFortran::ASR::Variable_t const&)
this->visit_expr_wrapper(x.m_symbolic_value, true);
File "/home/thirumalai/Open_Source/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 4144, in LFortran::ASRToLLVMVisitor::visit_expr_wrapper(LFortran::ASR::expr_t const*, bool)
this->visit_expr(*x);
File "/home/thirumalai/Open_Source/lpython/src/libasr/../libasr/asr.h", line 4208, in LFortran::ASR::BaseVisitor<LFortran::ASRToLLVMVisitor>::visit_expr(LFortran::ASR::expr_t const&)
void visit_expr(const expr_t &b) { visit_expr_t(b, self()); }
File "/home/thirumalai/Open_Source/lpython/src/libasr/../libasr/asr.h", line 4007, in ??
case exprType::ListConstant: { v.visit_ListConstant((const ListConstant_t &)x); return; }
File "/home/thirumalai/Open_Source/lpython/src/libasr/codegen/asr_to_llvm.cpp", line 1390, in LFortran::ASRToLLVMVisitor::visit_ListConstant(LFortran::ASR::ListConstant_t const&)
llvm::Value* const_list = builder->CreateAlloca(const_list_type, nullptr, "const_list");
File "/home/thirumalai/mambaforge/envs/lp/include/llvm/IR/IRBuilder.h", line 1598, in llvm::IRBuilderBase::CreateAlloca(llvm::Type*, llvm::Value*, llvm::Twine const&)
const DataLayout &DL = BB->getModule()->getDataLayout();
File "/home/thirumalai/mambaforge/envs/lp/include/llvm/IR/BasicBlock.h", line 117, in llvm::BasicBlock::getModule()
static_cast<const BasicBlock *>(this)->getModule());
Binary file "/home/thirumalai/Open_Source/lpython/src/bin/lpython", in llvm::SymbolTableListTraits<llvm::Instruction>::toPtr(llvm::ValueSymbolTable&)
Binary file "/lib/x86_64-linux-gnu/libc.so.6", in __GI___sigaction()
Segfault: Signal SIGSEGV (segmentation fault) received
Consider an example
ASR
From the above ASR, the variable
x
must be included in the_lpython_main_program
SymbolTable, right? Is this a bug or we have not handled the global variable yet? or is this expected output?Originally posted by @Thirumalai-Shaktivel in https://github.com/lcompilers/lpython/issues/1358#issuecomment-1348140087