Skip to content
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

Add cumulative flag for pass #2156

Merged
merged 3 commits into from
Jul 13, 2023
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
9 changes: 7 additions & 2 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ def is_included(backend):
llvm_dbg = is_included("llvm_dbg")
cpp = is_included("cpp")
c = is_included("c")
is_cumulative = is_included("cumulative")
wat = is_included("wat")
run = is_included("run")
run_with_dbg = is_included("run_with_dbg")
disable_main = is_included("disable_main")
pass_ = test.get("pass", None)
optimization_passes = ["flip_sign", "div_to_mul", "fma", "sign_from_value",
"inline_function_calls", "loop_unroll",
"dead_code_removal", "loop_vectorise", "print_list_tuple"]
"dead_code_removal", "loop_vectorise", "print_list_tuple",
"class_constructor"]

if pass_ and (pass_ not in ["do_loops", "global_stmts"] and
pass_ not in optimization_passes):
Expand Down Expand Up @@ -91,7 +93,10 @@ def is_included(backend):
extra_args)

if pass_ is not None:
cmd = "lpython --pass=" + pass_ + \
cmd = "lpython "
if is_cumulative:
cmd += "--cumulative "
cmd += "--pass=" + pass_ + \
" --show-asr --no-color {infile} -o {outfile}"
run_test(filename, "pass_{}".format(pass_), cmd,
filename, update_reference, extra_args)
Expand Down
2 changes: 2 additions & 0 deletions src/bin/lpython.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ int emit_asr(const std::string &infile,
pass_options.run_fun = "f";
pass_options.always_run = true;
pass_options.verbose = compiler_options.verbose;
pass_options.pass_cumulative = compiler_options.pass_cumulative;

pass_manager.apply_passes(al, asr, pass_options, diagnostics);

Expand Down Expand Up @@ -1574,6 +1575,7 @@ int main(int argc, char *argv[])
app.add_flag("--get-rtl-header-dir", print_rtl_header_dir, "Print the path to the runtime library header file");
app.add_flag("--get-rtl-dir", print_rtl_dir, "Print the path to the runtime library file");
app.add_flag("--verbose", compiler_options.verbose, "Print debugging statements");
app.add_flag("--cumulative", compiler_options.pass_cumulative, "Apply all the passes cumulatively till the given pass");
app.add_flag("--enable-cpython", compiler_options.enable_cpython, "Enable CPython runtime");
app.add_flag("--enable-symengine", compiler_options.enable_symengine, "Enable Symengine runtime");
app.add_flag("--link-numpy", compiler_options.link_numpy, "Enable NumPy runtime (implies --enable-cpython)");
Expand Down
13 changes: 13 additions & 0 deletions tests/reference/asr-structs_16-44de89a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"basename": "asr-structs_16-44de89a",
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}",
"infile": "tests/../integration_tests/structs_16.py",
"infile_hash": "e87ea0ba10cb7fcd6ce2eb6d2e953a26dcd6a843f6cf4e891287dcb1",
"outfile": null,
"outfile_hash": null,
"stdout": "asr-structs_16-44de89a.stdout",
"stdout_hash": "003d4550abb6fca33a8741e4d586a32ab5ce3355a40da5f911d61112",
"stderr": null,
"stderr_hash": null,
"returncode": 0
}
329 changes: 329 additions & 0 deletions tests/reference/asr-structs_16-44de89a.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,329 @@
(TranslationUnit
(SymbolTable
1
{
_global_symbols:
(Module
(SymbolTable
9
{
A:
(StructType
(SymbolTable
2
{
B:
(UnionType
(SymbolTable
3
{
x:
(Variable
3
x
[]
Local
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
),
y:
(Variable
3
y
[]
Local
()
()
Default
(Integer 8)
()
Source
Public
Required
.false.
)
})
B
[]
[x
y]
Source
Public
[(())
(())]
()
),
b:
(Variable
2
b
[]
Local
()
()
Default
(Union
2 B
)
()
Source
Public
Required
.false.
),
c:
(Variable
2
c
[]
Local
()
()
Default
(Integer 4)
()
Source
Public
Required
.false.
)
})
A
[]
[b
c]
Source
Public
.false.
.false.
[(())
(())]
()
()
),
_lpython_main_program:
(Function
(SymbolTable
8
{

})
_lpython_main_program
(FunctionType
[]
()
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
[test_ordering]
[]
[(SubroutineCall
9 test_ordering
()
[]
()
)]
()
Public
.false.
.false.
()
),
test_ordering:
(Function
(SymbolTable
4
{
A_B:
(ExternalSymbol
4
A_B
2 B
A
[]
B
Public
),
ad:
(Variable
4
ad
[]
Local
()
()
Default
(Struct
9 A
)
()
Source
Public
Required
.false.
),
bd:
(Variable
4
bd
[]
Local
()
()
Default
(Union
4 A_B
)
()
Source
Public
Required
.false.
)
})
test_ordering
(FunctionType
[]
()
Source
Implementation
()
.false.
.false.
.false.
.false.
.false.
[]
[]
.false.
)
[]
[]
[(=
(Var 4 bd)
(UnionTypeConstructor
4 A_B
[]
(Union
4 A_B
)
()
)
()
)
(=
(UnionInstanceMember
(Var 4 bd)
3 x
(Integer 4)
()
)
(IntegerConstant 1 (Integer 4))
()
)
(=
(Var 4 ad)
(StructTypeConstructor
9 A
[((Var 4 bd))
((IntegerConstant 2 (Integer 4)))]
(Struct
9 A
)
()
)
()
)
(Assert
(IntegerCompare
(UnionInstanceMember
(StructInstanceMember
(Var 4 ad)
2 b
(Union
2 B
)
()
)
3 x
(Integer 4)
()
)
Eq
(IntegerConstant 1 (Integer 4))
(Logical 4)
()
)
()
)
(Assert
(IntegerCompare
(StructInstanceMember
(Var 4 ad)
2 c
(Integer 4)
()
)
Eq
(IntegerConstant 2 (Integer 4))
(Logical 4)
()
)
()
)]
()
Public
.false.
.false.
()
)
})
_global_symbols
[]
.false.
.false.
),
main_program:
(Program
(SymbolTable
7
{
_lpython_main_program:
(ExternalSymbol
7
_lpython_main_program
9 _lpython_main_program
_global_symbols
[]
_lpython_main_program
Public
)
})
main_program
[_global_symbols]
[(SubroutineCall
7 _lpython_main_program
()
[]
()
)]
)
})
[]
)
Loading