Skip to content

Commit a895df9

Browse files
committed
Fix usage of pass APIs in backends
1 parent dbd5e62 commit a895df9

File tree

5 files changed

+23
-9
lines changed

5 files changed

+23
-9
lines changed

src/libasr/codegen/asr_to_c.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,11 @@ Result<std::string> asr_to_c(Allocator &al, ASR::TranslationUnit_t &asr,
655655
diag::Diagnostics &diagnostics, Platform &platform,
656656
int64_t default_lower_bound)
657657
{
658-
pass_unused_functions(al, asr, true);
659-
pass_replace_class_constructor(al, asr);
658+
659+
LCompilers::PassOptions pass_options;
660+
pass_options.always_run = true;
661+
pass_unused_functions(al, asr, pass_options);
662+
pass_replace_class_constructor(al, asr, pass_options);
660663
ASRToCVisitor v(diagnostics, platform, default_lower_bound);
661664
try {
662665
v.visit_asr((ASR::asr_t &)asr);

src/libasr/codegen/asr_to_cpp.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,9 @@ Result<std::string> asr_to_cpp(Allocator &al, ASR::TranslationUnit_t &asr,
699699
diag::Diagnostics &diagnostics, Platform &platform,
700700
int64_t default_lower_bound)
701701
{
702-
pass_unused_functions(al, asr, true);
702+
LCompilers::PassOptions pass_options;
703+
pass_options.always_run = true;
704+
pass_unused_functions(al, asr, pass_options);
703705
ASRToCPPVisitor v(diagnostics, platform, default_lower_bound);
704706
try {
705707
v.visit_asr((ASR::asr_t &)asr);

src/libasr/codegen/asr_to_llvm.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5430,7 +5430,10 @@ Result<std::unique_ptr<LLVMModule>> asr_to_llvm(ASR::TranslationUnit_t &asr,
54305430
Platform platform, const std::string &run_fn)
54315431
{
54325432
ASRToLLVMVisitor v(al, context, platform, diagnostics);
5433-
pass_manager.apply_passes(al, &asr, run_fn, false);
5433+
LCompilers::PassOptions pass_options;
5434+
pass_options.run_fun = run_fn;
5435+
pass_options.always_run = false;
5436+
pass_manager.apply_passes(al, &asr, pass_options);
54345437

54355438
// Uncomment for debugging the ASR after the transformation
54365439
// std::cout << pickle(asr, true, true, true) << std::endl;

src/libasr/codegen/asr_to_wasm.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <libasr/pass/do_loops.h>
1212
#include <libasr/pass/unused_functions.h>
1313
#include <libasr/pass/arr_dims_propagate.h>
14+
#include <libasr/pass/pass_array_by_data.h>
1415
#include <libasr/exception.h>
1516
#include <libasr/asr_utils.h>
1617

@@ -1532,9 +1533,11 @@ Result<Vec<uint8_t>> asr_to_wasm_bytes_stream(ASR::TranslationUnit_t &asr, Alloc
15321533
ASRToWASMVisitor v(al, diagnostics);
15331534
Vec<uint8_t> wasm_bytes;
15341535

1535-
pass_unused_functions(al, asr, true);
1536-
pass_replace_do_loops(al, asr);
1537-
pass_propagate_arr_dims(al, asr);
1536+
LCompilers::PassOptions pass_options;
1537+
pass_replace_do_loops(al, asr, pass_options);
1538+
pass_array_by_data(al, asr, pass_options);
1539+
pass_options.always_run = true;
1540+
pass_unused_functions(al, asr, pass_options);
15381541

15391542
// std::cout << pickle(asr, true /* use colors */, true /* indent */,
15401543
// true /* with_intrinsic_modules */) << std::endl;

src/libasr/codegen/asr_to_x86.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,16 +532,19 @@ Result<int> asr_to_x86(ASR::TranslationUnit_t &asr, Allocator &al,
532532

533533
ASRToX86Visitor v(al);
534534

535+
LCompilers::PassOptions pass_options;
536+
pass_options.run_fun = "f";
537+
535538
{
536539
auto t1 = std::chrono::high_resolution_clock::now();
537-
pass_wrap_global_stmts_into_function(al, asr, "f");
540+
pass_wrap_global_stmts_into_function(al, asr, pass_options);
538541
auto t2 = std::chrono::high_resolution_clock::now();
539542
time_pass_global = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
540543
}
541544

542545
{
543546
auto t1 = std::chrono::high_resolution_clock::now();
544-
pass_replace_do_loops(al, asr);
547+
pass_replace_do_loops(al, asr, pass_options);
545548
auto t2 = std::chrono::high_resolution_clock::now();
546549
time_pass_do_loops = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
547550
}

0 commit comments

Comments
 (0)