Skip to content

Sync libasr from LFortran #1670

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2023
Merged

Sync libasr from LFortran #1670

merged 2 commits into from
Apr 7, 2023

Conversation

czgdp1807
Copy link
Collaborator

@czgdp1807 czgdp1807 commented Apr 6, 2023

Corresponding LFortran PR - lfortran/lfortran#1501

@ubaidsk
Copy link
Collaborator

ubaidsk commented Apr 6, 2023

For wasm, please include in this PR just the changes from lfortran/lfortran#1495, and then use the wasm and related files from lpython in lfortran. That would hopefully complete sync for wasm.

Comment on lines 55 to 73
#ifdef LCOMPILERS_FAST_ALLOC
try {
#endif
LCOMPILERS_ASSERT(start != nullptr);
size_t addr = current_pos;
current_pos += align(s);
if (size_current() > size_total()) throw std::bad_alloc();
if (size_current() > size_total()) {
#ifdef LCOMPILERS_FAST_ALLOC
throw std::bad_alloc();
#else
return new_chunk(s);
#endif
}
return (void*)addr;
#ifdef LCOMPILERS_FAST_ALLOC
} catch (const std::bad_alloc &e) {
return new_chunk(s);
}
#endif
Copy link
Collaborator

@ubaidsk ubaidsk Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, this can be reverted for now. We can add it later when building lpython to wasm in release mode.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about this. LFortran needs it. Let's add it in LPython as well. (I assumed we could diverge here slightly and later make them same. Maybe its better to have equal LibASRs.)

Comment on lines 1443 to 1452
for (size_t idx=0; idx < s.size(); idx++) {
src += s[idx];
for (size_t idx = 0; idx < s.size(); idx++) {
if (s[idx] == '\n') {
src += "\\n";
} else if (s[idx] == '\\') {
src += "\\\\";
} else if (s[idx] == '\"') {
src += "\\\"";
} else {
src += s[idx];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this needs to be reverted. Please see 3c53ffb.

Comment on lines 82 to 87
std::vector<std::string> build_order = ASRUtils::determine_module_dependencies(x);
for (auto &item : build_order) {
ASR::symbol_t *mod = x.m_global_scope->get_symbol(item);
visit_symbol(*mod);
}

Copy link
Collaborator

@ubaidsk ubaidsk Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be reverted (39aed26).

Comment on lines 98 to 110
void visit_Module(const ASR::Module_t &x) {
std::vector<std::string> func_order
= ASRUtils::determine_function_definition_order(x.m_symtab);
for (size_t i = 0; i < func_order.size(); i++) {
ASR::symbol_t* sym = x.m_symtab->get_symbol(func_order[i]);
// Ignore external symbols because they are already defined by the loop above.
if( !sym || ASR::is_a<ASR::ExternalSymbol_t>(*sym) ) {
continue;
}
visit_symbol(*sym);
}
}

Copy link
Collaborator

@ubaidsk ubaidsk Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted (39aed26)

@ansharlubis
Copy link
Collaborator

Looks good here in the generics department.

std::string list_type_name = ASRUtils::get_type_code(list_type, true);
std::string list_type_name = ASRUtils::type_to_str_python(list_type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be reverted. Please see a166236.

std::string list_type_name = ASRUtils::get_type_code(x->m_type, true);
std::string list_type_name = ASRUtils::type_to_str_python(x->m_type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted. (a166236)

std::string list_type_name = ASRUtils::get_type_code(list_type, true);
std::string list_type_name = ASRUtils::type_to_str_python(list_type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, here (a166236)

std::string list_type_name = ASRUtils::get_type_code(x->m_type, true);
std::string list_type_name = ASRUtils::type_to_str_python(x->m_type);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here (a166236)

Comment on lines 1064 to 1162
llvm::Value* lfortran_str_item(llvm::Value* str, llvm::Value* idx1)
llvm::Value* lfortran_str_copy(llvm::Value* str, llvm::Value* idx1, llvm::Value* idx2)
{
std::string runtime_func_name = "_lfortran_str_item";
std::string runtime_func_name = "_lfortran_str_copy";
llvm::Function *fn = module->getFunction(runtime_func_name);
if (!fn) {
llvm::FunctionType *function_type = llvm::FunctionType::get(
character_type, {
character_type, llvm::Type::getInt32Ty(context)
character_type, llvm::Type::getInt32Ty(context), llvm::Type::getInt32Ty(context)
}, false);
fn = llvm::Function::Create(function_type,
llvm::Function::ExternalLinkage, runtime_func_name, *module);
}
return builder->CreateCall(fn, {str, idx1});
return builder->CreateCall(fn, {str, idx1, idx2});
}
Copy link
Collaborator

@ubaidsk ubaidsk Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs to be reverted. Please see 2f45421.

Comment on lines 1911 to 2044
p = lfortran_str_item(str, idx);
p = lfortran_str_copy(str, idx, idx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted (2f45421)

Comment on lines 1994 to 2128
llvm::Value *step = llvm::ConstantInt::get(context, llvm::APInt(32, 1));
llvm::Value *present = llvm::ConstantInt::get(context, llvm::APInt(1, 1));
llvm::Value *p = lfortran_str_slice(str, idx1, idx2, step, present, present);
llvm::Value *p = lfortran_str_copy(str, idx1, idx2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted (2f45421)

Comment on lines 4969 to 5597
tmp = lfortran_str_item(str, idx);
tmp = lfortran_str_copy(str, idx, idx);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be reverted (2f45421).

Comment on lines 7037 to 8038
// std::cout << LPython::pickle(asr, true, true, true) << std::endl;
// std::cout << LFortran::pickle(asr, true, true, true) << std::endl;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be reverted.

@ubaidsk
Copy link
Collaborator

ubaidsk commented Apr 6, 2023

I guess we missed to include write_array_using_doloop() in pass/print_arr.cpp. It was added in lfortran in lfortran/lfortran@b1992c3.

def visit_BaseWASMVisitor(self, mod, *args):
def visitWASMInstructions(self, mod, *args):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole file needs to be reverted. Please see my comment here #1670 (comment).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did and now I am getting the following errors,

Consolidate compiler generated dependencies of target asr
[  1%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/wasm_to_wat.cpp.o
In file included from /Users/czgdp1807/lpython_project/lpython/src/libasr/codegen/wasm_to_wat.cpp:5:
In file included from /Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/codegen/wasm_to_wat.h:4:
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2794:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, labelidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2799:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, labelidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2808:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, funcidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2813:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, typeidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2814:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, tableidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2819:15: error: no member named 'emit_b8' in namespace 'LCompilers::wasm'
        wasm::emit_b8(m_code, m_al, reftype);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2828:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, funcidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2841:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, localidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2846:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, localidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2851:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, localidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2856:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, globalidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2861:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, globalidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2866:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, tableidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2871:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, tableidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2876:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_align);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2877:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_offset);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2882:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_align);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2883:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_offset);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2888:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_align);
        ~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [src/libasr/CMakeFiles/asr.dir/build.make:174: src/libasr/CMakeFiles/asr.dir/codegen/wasm_to_wat.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:287: src/libasr/CMakeFiles/asr.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
(lp) 15:18:20:~/lpython_project/lpython % ./build0.sh
+ ci/version.sh
++ git describe --tags --dirty
+ version=v0.12.0-239-gb35e744dc-dirty
+ version=0.12.0-239-gb35e744dc-dirty
+ echo 0.12.0-239-gb35e744dc-dirty
+ python grammar/asdl_py.py
Assuming default values of Python.asdl and python_ast.py
+ python src/libasr/asdl_cpp.py grammar/Python.asdl src/lpython/python_ast.h
+ python src/libasr/asdl_cpp.py src/libasr/ASR.asdl src/libasr/asr.h
+ python src/libasr/wasm_instructions_visitor.py
Assuming default values of wasm_instructions.txt and wasm_visitor.h
+ cd src/lpython/parser
+ re2c -W -b tokenizer.re -o tokenizer.cpp
+ cd src/lpython/parser
+ bison -Wall -d -r all parser.yy
+ grep -n ''\''' src/lpython/parser/parser.yy
+ echo OK
OK
(lp) 15:18:46:~/lpython_project/lpython % make
Consolidate compiler generated dependencies of target asr
[  1%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/asr_to_cpp.cpp.o
[  2%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/asr_to_c.cpp.o
[  3%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/asr_to_julia.cpp.o
[  4%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/asr_to_py.cpp.o
[  5%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/asr_to_x86.cpp.o
[  7%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/asr_to_wasm.cpp.o
[  8%] Building CXX object src/libasr/CMakeFiles/asr.dir/codegen/wasm_to_wat.cpp.o
In file included from /Users/czgdp1807/lpython_project/lpython/src/libasr/codegen/wasm_to_wat.cpp:5:
In file included from /Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/codegen/wasm_to_wat.h:4:
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2794:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, labelidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2799:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, labelidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2808:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, funcidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2813:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, typeidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2814:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, tableidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2819:15: error: no member named 'emit_b8' in namespace 'LCompilers::wasm'
        wasm::emit_b8(m_code, m_al, reftype);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2828:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, funcidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2841:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, localidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2846:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, localidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2851:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, localidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2856:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, globalidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2861:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, globalidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2866:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, tableidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2871:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, tableidx);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2876:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_align);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2877:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_offset);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2882:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_align);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2883:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_offset);
        ~~~~~~^
/Users/czgdp1807/lpython_project/lpython/src/libasr/../libasr/wasm_visitor.h:2888:15: error: no member named 'emit_u32' in namespace 'LCompilers::wasm'
        wasm::emit_u32(m_code, m_al, mem_align);
        ~~~~~~^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [src/libasr/CMakeFiles/asr.dir/build.make:174: src/libasr/CMakeFiles/asr.dir/codegen/wasm_to_wat.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:287: src/libasr/CMakeFiles/asr.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved. Thanks.

@ubaidsk
Copy link
Collaborator

ubaidsk commented Apr 6, 2023

The rest looks good to me. Thank you so much for this PR.

Comment on lines 863 to 880
// idx starts from 1
LFORTRAN_API char* _lfortran_str_item(char* s, int32_t idx) {
// idx1 and idx2 both start from 1
LFORTRAN_API char* _lfortran_str_copy(char* s, int32_t idx1, int32_t idx2) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be reverted 2f45421

@Pranavchiku
Copy link
Collaborator

I guess change of pass/implied_do_loops.cpp are missed, lfortran/lfortran@3e69b8d.

@czgdp1807
Copy link
Collaborator Author

For wasm, please include in this PR just the changes from lfortran/lfortran#1495, and then use the wasm and related files from lpython in lfortran. That would hopefully complete sync for wasm.

They are already there in this PR.

@czgdp1807
Copy link
Collaborator Author

I guess change of pass/implied_do_loops.cpp are missed, lfortran/lfortran@3e69b8d.

The commit you have mentioned is a very old one. implied_do_loops.cpp was revamped afterwards.

@@ -85,7 +85,7 @@ class PrintArrVisitor : public PassUtils::PassVisitor<PrintArrVisitor>
doloop_body.push_back(al, doloop);
doloop_body.push_back(al, empty_print_endl);
}
doloop = ASRUtils::STMT(ASR::make_DoLoop_t(al, loc, head, doloop_body.p, doloop_body.size()));
doloop = ASRUtils::STMT(ASR::make_DoLoop_t(al, loc, nullptr, head, doloop_body.p, doloop_body.size()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in pass/print_arr.cpp are missing, lfortran/lfortran@b1992c3

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I shared here #1670 (comment).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, that's a very old commit. I just copied today mornings main from lfortran into lpython.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is there in the latest main as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I added it in this PR.

@ubaidsk
Copy link
Collaborator

ubaidsk commented Apr 6, 2023

For wasm, please include in this PR just the changes from lfortran/lfortran#1495, and then use the wasm and related files from lpython in lfortran. That would hopefully complete sync for wasm.

They are already there in this PR.

Please consider the wasm and related files at lpython, current main branch to be the latest/ultimate version. And to this latest version we just need to add the changes in lfortran/lfortran#1495. Now, the wasm and related files are fully synced (for lpython).

We now copy these files from lpython and paste/replace in lfortran. Please let me know if it is clear. Also, please let me know if I shall make the above change.

Copy link
Collaborator

@Pranavchiku Pranavchiku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One or two commits are missing, rest all look good to me. Thanks for syncing!

@czgdp1807
Copy link
Collaborator Author

@Shaikh-Ubaid WASM fails on CI. Could you please take a look?

17/33 Test #22: test_complex_01 ..................***Failed    0.28 sec
(node:15485) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[CompileError: WebAssembly.compile(): Compiling function #15 failed: function index #4294967295 is out of bounds @+2470]

ASR::Function_t *s = ASR::down_cast<ASR::Function_t>(
ASRUtils::symbol_get_past_external(x.m_name));
ASR::Function_t *s = ASR::down_cast<ASR::Function_t>(x.m_name);
Copy link
Collaborator

@ubaidsk ubaidsk Apr 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think/guess this needs to be reverted (39aed26).

@czgdp1807 czgdp1807 marked this pull request as ready for review April 6, 2023 17:46
Comment on lines 5492 to 6182
std::string s = unescape_string(al, x.m_s);
tmp = builder->CreateGlobalStringPtr(s);
tmp = builder->CreateGlobalStringPtr(x.m_s);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be reverted, I think. Can you please add this LFortran as well!

https://github.com/lcompilers/lpython/pull/1502/files

ASR::StructType_t* der_type = ASR::down_cast<ASR::StructType_t>(
ASRUtils::symbol_get_past_external(der->m_derived_type));
ASR::Struct_t* der = (ASR::Struct_t*)(&(x->m_type->base));
ASR::StructType_t* der_type = (ASR::StructType_t*)(&(der->m_derived_type->base));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@Thirumalai-Shaktivel Thirumalai-Shaktivel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the above changes. I think this looks good to go in.
Thank you very much!

Copy link
Collaborator

@Pranavchiku Pranavchiku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for doing this!

Comment on lines 5597 to 6292
ASR::Class_t* der = ASR::down_cast<ASR::Class_t>(x->m_type);
ASR::ClassType_t* der_type = ASR::down_cast<ASR::ClassType_t>(
ASRUtils::symbol_get_past_external(der->m_class_type));
ASR::Class_t* der = (ASR::Class_t*)(&(x->m_type->base));
ASR::ClassType_t* der_type = (ASR::ClassType_t*)(&(der->m_class_type->base));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mention this earlier. Can you please revert this as well.

@czgdp1807 czgdp1807 requested a review from certik April 7, 2023 15:46
@certik certik merged commit c313b33 into lcompilers:main Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants