Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove is_fast and its associated methods from PassManager #2600

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 5 commits into from
Mar 13, 2024
Merged
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
3 changes: 3 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def is_included(backend):
run = is_included("run")
run_with_dbg = is_included("run_with_dbg")
disable_main = is_included("disable_main")
fast = is_included("fast")
pass_ = test.get("pass", None)
optimization_passes = ["flip_sign", "div_to_mul", "fma", "sign_from_value",
"inline_function_calls", "loop_unroll",
Expand Down Expand Up @@ -97,6 +98,8 @@ def is_included(backend):
cmd = "lpython "
if is_cumulative:
cmd += "--cumulative "
if fast:
cmd += "--fast "
cmd += "--pass=" + pass_ + \
" --show-asr --no-color {infile} -o {outfile}"
run_test(filename, "pass_{}".format(pass_), cmd,
Expand Down
5 changes: 4 additions & 1 deletion src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,10 @@ int main(int argc, char *argv[])
// ReleaseSafe Mode
} else if ( compiler_options.po.fast ) {
// Release Mode
lpython_pass_manager.use_optimization_passes();
// No need to do anything, compiler_options.po.fast
// sends the signal to pass_manager when passes are applied
// Earlier it was redundant to call `use_optimisation_passes`
// which is now removed
} else {
// Debug Mode
compiler_options.enable_bounds_checking = true;
Expand Down
15 changes: 2 additions & 13 deletions src/libasr/pass/pass_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ namespace LCompilers {
{"insert_deallocate", &pass_insert_deallocate}
};

bool is_fast;
bool apply_default_passes;
bool c_skip_pass; // This will contain the passes that are to be skipped in C

Expand Down Expand Up @@ -196,7 +195,7 @@ namespace LCompilers {
}
}

PassManager(): is_fast{false}, apply_default_passes{false},
PassManager(): apply_default_passes{false},
c_skip_pass{false} {
_passes = {
"nested_vars",
Expand Down Expand Up @@ -287,12 +286,10 @@ namespace LCompilers {
PassOptions& pass_options,
diag::Diagnostics &diagnostics) {
if( !_user_defined_passes.empty() ) {
pass_options.fast = true;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same here. pass_options.fast should only be read from the command line and should not be set to true deliberately. This line caused bugs in LC and optimisations weren't being applied to LLVM because of such modifications of pass_options.

apply_passes(al, asr, _user_defined_passes, pass_options,
diagnostics);
} else if( apply_default_passes ) {
pass_options.fast = is_fast;
if( is_fast ) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was wrong earlier. The user input should never be modified. In fact pass_options.fast is alone enough. is_fast was redundant.

if( pass_options.fast ) {
apply_passes(al, asr, _with_optimization_passes, pass_options,
diagnostics);
} else {
Expand Down Expand Up @@ -371,14 +368,6 @@ namespace LCompilers {
}
}

void use_optimization_passes() {
is_fast = true;
}

void do_not_use_optimization_passes() {
is_fast = false;
}

void use_default_passes(bool _c_skip_pass=false) {
apply_default_passes = true;
c_skip_pass = _c_skip_pass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"basename": "pass_inline_function_calls-func_inline_01-8b6a5da",
"cmd": "lpython --pass=inline_function_calls --show-asr --no-color {infile} -o {outfile}",
"basename": "pass_inline_function_calls-func_inline_01-fba3c47",
"cmd": "lpython --fast --pass=inline_function_calls --show-asr --no-color {infile} -o {outfile}",
"infile": "tests/../integration_tests/func_inline_01.py",
"infile_hash": "65a2e9a9bc7ad68a5e104549eed00cafd02b643a1d91ab2e175b2198",
"outfile": null,
"outfile_hash": null,
"stdout": "pass_inline_function_calls-func_inline_01-8b6a5da.stdout",
"stdout": "pass_inline_function_calls-func_inline_01-fba3c47.stdout",
"stdout_hash": "1705050e9a2183a2f6aa493125e093e7c4d17a4f2f4949749950e11a",
"stderr": null,
"stderr_hash": null,
Expand Down
1 change: 1 addition & 0 deletions tests/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ asr = true
llvm = true
pass_with_llvm = true
pass = "inline_function_calls"
fast = true

# to make sure static keyword is actually present in function declaration
[[test]]
Expand Down