Skip to content

pass_wrap_global_stmts always creates function of abiType::BindC #2700

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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,13 +1058,13 @@ int compile_python_using_llvm(
auto llvm_start = std::chrono::high_resolution_clock::now();

bool call_stmts = false;
if (m->get_return_type("__module___main_____main__global_stmts") == "void") {
if (m->get_return_type("__main__global_stmts") == "void") {
call_stmts = true;
}

e.add_module(std::move(m));
if (call_stmts) {
e.voidfn("__module___main_____main__global_stmts");
e.voidfn("__main__global_stmts");
}

if (compiler_options.enable_cpython) {
Expand Down
1 change: 1 addition & 0 deletions src/libasr/codegen/asr_to_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ class ASRToWASMVisitor : public ASR::BaseVisitor<ASRToWASMVisitor> {

bool is_unsupported_function(const ASR::Function_t &x) {
if (strcmp(x.m_name, "_start") == 0) return false;
if (strcmp(x.m_name, "__main__global_stmts") == 0) return false;

if (ASRUtils::get_FunctionType(x)->m_abi == ASR::abiType::BindJS) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/libasr/pass/global_stmts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void pass_wrap_global_stmts(Allocator &al,
/* a_body */ body.p,
/* n_body */ body.size(),
/* a_return_var */ (return_var ? return_var_ref : nullptr),
(return_var ? ASR::abiType::BindC : ASR::abiType::Source),
ASR::abiType::BindC,
ASR::Public, ASR::Implementation,
nullptr,
false, false, false, false, false,
Expand Down
6 changes: 2 additions & 4 deletions src/lpython/python_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@ Result<PythonCompiler::EvalResult> PythonCompiler::evaluate(
}

// ASR -> LLVM
std::string module_prefix = "__module___main___";
std::string module_name = "__main__";
std::string sym_name = module_name + "global_stmts_" + std::to_string(eval_count) + "__";
run_fn = module_prefix + sym_name;
run_fn = module_name + "global_stmts_" + std::to_string(eval_count) + "__";

Result<std::unique_ptr<LLVMModule>> res3 = get_llvm3(*asr,
pass_manager, diagnostics, lm.files.back().in_filename);
Expand Down Expand Up @@ -116,7 +114,7 @@ Result<PythonCompiler::EvalResult> PythonCompiler::evaluate(

if (call_run_fn) {
ASR::down_cast<ASR::Module_t>(symbol_table->resolve_symbol(module_name))->m_symtab
->erase_symbol(sym_name);
->erase_symbol(run_fn);
}

eval_count++;
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_01_decl-39cf894.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-array_01_decl-39cf894.stdout",
"stdout_hash": "292194a8fe4110a90c90bbcbf94f66b70f82978e14108ded75104711",
"stdout_hash": "b52f82a02459b8933b18e51ae7d2a68538e367b07024dcb45e759995",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_01_decl-39cf894.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_02_decl-e8f6874.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-array_02_decl-e8f6874.stdout",
"stdout_hash": "7b506405f2db787df8d5e04ea40bb26baf200b5ea75a29f8410dcaaa",
"stdout_hash": "40ba767ccf9b2fb13d3bd1408aab3664bc151355203a790b9db68052",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-array_02_decl-e8f6874.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-bindc_01-6d521a9.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-bindc_01-6d521a9.stdout",
"stdout_hash": "ef60e71b9f8d29c6c9788d7a614fda516a74a38d7a7423e7e39bbf7f",
"stdout_hash": "4e3b9d49754feec5684c3b48b76c5a388adbc3c20320e29976f7a385",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-bindc_01-6d521a9.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-bindc_02-bc1a7ea.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-bindc_02-bc1a7ea.stdout",
"stdout_hash": "0b63ac37d3c2fadcacabe7c8c985e02c6d3db8f19f945ab2a88414f7",
"stdout_hash": "135f090ac0e4fb7ac28f17c60f8ecbcae4bbea1db2c965f6158780fa",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-bindc_02-bc1a7ea.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-callback_01-df40fd5.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-callback_01-df40fd5.stdout",
"stdout_hash": "a8fbb30389ff308781e5cc08c41bee122eb1f40c9707b86000d81a39",
"stdout_hash": "95bba7dc5e898bc9db53f2086af51f929677ced1daaa551986ccae67",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-callback_01-df40fd5.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-cast-435c233.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-cast-435c233.stdout",
"stdout_hash": "57cf8fa21e9a019ea1b4e9c13ecfc8500bd40140ab73e3706f4a548b",
"stdout_hash": "2c6b37aaabeaaecdaf678f66947d3155708c83d0428e07e48644cbe3",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-cast-435c233.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-doconcurrentloop_01-3fdc189.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-doconcurrentloop_01-3fdc189.stdout",
"stdout_hash": "413974a16ffc353be79c5bba8842ef9190e2c5c845d605c96b15e55b",
"stdout_hash": "8a455bbdfe3a5ce8e15121598a3531c6e70b7e49375aef40fdb4ce45",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-doconcurrentloop_01-3fdc189.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-elemental_01-b58df26.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-elemental_01-b58df26.stdout",
"stdout_hash": "4c513521bada6163ac63fa332b183b73632bc0c1e8598ad0b75d8424",
"stdout_hash": "010de6d656ca155767b7b164826621d352f51e51e92a57e32941d1f5",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-elemental_01-b58df26.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr12-5c5b71e.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr12-5c5b71e.stdout",
"stdout_hash": "cc7faf4b191f80b30f9ba8ba5dc649e69a276ee40352403a890a7ecb",
"stdout_hash": "d3aaa8ff5b242d983778814608d445ae5469d57265ec7f40ad9e3ce0",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr12-5c5b71e.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr7-480ba2f.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr7-480ba2f.stdout",
"stdout_hash": "53cee9828734c67e8e5f67fd20774b45de191ad50be7867cd1fb1d7f",
"stdout_hash": "373a1b54b20cc68be611361764a9b440fd66619105ef2e157cabc681",
"stderr": "asr-expr7-480ba2f.stderr",
"stderr_hash": "6e9790ac88db1a9ead8f64a91ba8a6605de67167037908a74b77be0c",
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr7-480ba2f.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr9-814e4bc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr9-814e4bc.stdout",
"stdout_hash": "922dc300e7301fe54ac9c1bd22b4cda2551dcaa4ea76fb131db41882",
"stdout_hash": "ff65b192ccf4984cc053713450d454f5a6b81caeb477723efed5f0ed",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr9-814e4bc.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_01-211000e.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_01-211000e.stdout",
"stdout_hash": "1e770e5983d3028716293596137effa14c8ff482aff2f0f1d1efc3c4",
"stdout_hash": "1ac1c1d67b70d64420e6d6beedba7117588d81b73710e32307a7b9aa",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_01-211000e.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_01-a0d4829.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_01-a0d4829.stdout",
"stdout_hash": "81e8dec77a5c7bda11b512e25b14698a02c7923cacfd5d491a86e0b6",
"stdout_hash": "2b0d441cbc9e8590bf4feceed7c62fa491b8946caec0a28e88b76d6e",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_01-a0d4829.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_05-3a37324.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_05-3a37324.stdout",
"stdout_hash": "8d7c373fed48f50b1029b8e091d6ca356bc32fadc92ac016207ea166",
"stdout_hash": "285aaece272ea8a72777ff1d27fd6ffbe5c84a0d231441b47be18729",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_05-3a37324.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_07-7742668.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_07-7742668.stdout",
"stdout_hash": "15b03241d340d1abbeb06e4540d37bcd9307d085f7c484ed822f8555",
"stdout_hash": "e304290477e2f8f7de4138dde6035c4febc904e6bc783823ef29c2f7",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_07-7742668.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_09-f3e89c8.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_09-f3e89c8.stdout",
"stdout_hash": "6e8a419784bc7e466429ca4f3f3b0d6a1883b2dd0c5718fe71361765",
"stdout_hash": "2863cfbd8addb944cae250a0ee4962008f5055e82a537253a31bc029",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_09-f3e89c8.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_10-d39708c.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_10-d39708c.stdout",
"stdout_hash": "937ab19f6b8e31442a9a1b0c6bd4fa931e4d10aae2e80a351256227f",
"stdout_hash": "cb6140dc1d844e84d10cb017e0c569a12570c8da468d686850a41709",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_10-d39708c.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_12-6769be0.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_12-6769be0.stdout",
"stdout_hash": "2d85d51b025a58090c9848f23b6bfc7e236771cbeb8b6257e33256b5",
"stdout_hash": "26a6f3c078f8422248399fd5032510e51665ffc68fdcba085920cefc",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_12-6769be0.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_14-f2bd343.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outfile": null,
"outfile_hash": null,
"stdout": "asr-expr_14-f2bd343.stdout",
"stdout_hash": "d0556c7ad91fa6f49b4dc82b49e50843ffc424a9289b800e1bceb863",
"stdout_hash": "52e5aab0f63bf52204e50f53da3d89259b5bea127a9e5e12c422d5cb",
"stderr": null,
"stderr_hash": null,
"returncode": 0
Expand Down
2 changes: 1 addition & 1 deletion tests/reference/asr-expr_14-f2bd343.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(FunctionType
[]
()
Source
BindC
Implementation
()
.false.
Expand Down
Loading
Loading