Skip to content

Support for print ASR after pass. #950

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

redbopo
Copy link
Contributor

@redbopo redbopo commented Aug 9, 2022

Add command --print-after-asr-pass on issue-943
The extra space end of line is removed by editor plugIns .

But there will be problems if we enter the python file a little large, like ./integration_tests/func_inline_01.py

@@ -37,7 +37,7 @@
#include <libasr/pass/loop_vectorise.h>
#include <libasr/pass/update_array_dim_intrinsic_calls.h>
#include <libasr/pass/pass_array_by_data.h>

#include <lpython/pickle.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

We can't include LPython nor LFortran in libasr. What we need some other way to do it. I think for now there might be a way to do this import with some ifdef preprocessor statements, but we really need to move the ASR printing into libasr itself from LFortran/LPython. That should be done in a separate PR.

@certik
Copy link
Contributor

certik commented Aug 9, 2022

Otherwise this is exactly how to do it.

For large Python files, the user can simply redirect to a file, so there will be no problem.

@redbopo
Copy link
Contributor Author

redbopo commented Aug 9, 2022

Thanks for quick review @certik . Forget to add the error msg , it's std::exception: std::bad_alloc . And I think it's that the return string type of LFortran::pickle_tree() is not suitable here, maybe we need some other function with input args std::iostream . I will find more about ASRTreeVisitor and be back later.

@czgdp1807
Copy link
Collaborator

czgdp1807 commented Aug 9, 2022

Well. I would print the output of each ASR Pass in a different file. Right now everything is directed to a single output stream. I would also generate a meta data file which contains the order of passes which were applied and in which files the output of each pass is available.

P.S. For now I wouldn’t use it as is because even for very small codes it would generate a huge output (hard to read through and eventually debugging would be harder). But anyways merging it is fine for me.

@certik
Copy link
Contributor

certik commented Aug 9, 2022

I like to use git diff --color-words to see diffs in large ASR outputs, it works very well. Otherwise also printing it as Fortran or Python code and use regular "diff" before and after an ASR pass should be very instructive. Anyway, we can get all this done later, this is just a start.

@czgdp1807
Copy link
Collaborator

czgdp1807 commented Aug 10, 2022

@redbopo Can you show the output (like just commenting here should be good) for your changes with a small input file?

@redbopo
Copy link
Contributor Author

redbopo commented Aug 10, 2022

Of couse, @czgdp1807 . The input file I code is as follow, and the output of ASR in the terminal
is in the details. It's too long.
Currently I turn off the color in the pickle() function, but it's easy to set on.


def f():
    print("SDg")

f()

<<<< Start of Print ASR After Pass >>>> 
<<<< Raw TranslationUnit_t ASR >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (global_stmts) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (class_constructor) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (implied_do_loops) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (pass_array_by_data) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (arr_slice) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (array_op) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (print_arr) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (array_dim_intrinsics_update) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (do_loops) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (forall) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (select_case) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< After ASR Pass (unused_functions) >>>> 
└-TranslationUnit
  |-SymbolTable
  | |-counter=1
  | └-scope=↧
  |   |-_lpython_main_program: Function
  |   | |-SymbolTable
  |   | | |-counter=4
  |   | | └-scope=↧
  |   | |-name=_lpython_main_program
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-SubroutineCall
  |   | |   |-name=Function
  |   | |   | |-SymbolTable
  |   | |   | | |-counter=2
  |   | |   | | └-scope=↧
  |   | |   | |-name=f
  |   | |   | |-args=↧
  |   | |   | |-type_params=↧
  |   | |   | |-body=↧
  |   | |   | | └-Print
  |   | |   | |   |-fmt=()
  |   | |   | |   |-values=↧
  |   | |   | |   | └-StringConstant
  |   | |   | |   |   |-s="SDg"
  |   | |   | |   |   └-type=Character
  |   | |   | |   |     |-kind=1
  |   | |   | |   |     |-len=3
  |   | |   | |   |     |-len_expr=()
  |   | |   | |   |     └-dims=↧
  |   | |   | |   |-separator=()
  |   | |   | |   └-end=()
  |   | |   | |-return_var=()
  |   | |   | |-abiType=Source
  |   | |   | |-accessType=Public
  |   | |   | |-deftypeType=Implementation
  |   | |   | |-bindc_name=()
  |   | |   | |-elemental=.false.
  |   | |   | |-pure=.false.
  |   | |   | └-module=.false.
  |   | |   |-original_name=()
  |   | |   |-args=↧
  |   | |   └-dt=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   |-f: 
  |   |-Function
  |   | |-SymbolTable
  |   | | |-counter=2
  |   | | └-scope=↧
  |   | |-name=f
  |   | |-args=↧
  |   | |-type_params=↧
  |   | |-body=↧
  |   | | └-Print
  |   | |   |-fmt=()
  |   | |   |-values=↧
  |   | |   | └-StringConstant
  |   | |   |   |-s="SDg"
  |   | |   |   └-type=Character
  |   | |   |     |-kind=1
  |   | |   |     |-len=3
  |   | |   |     |-len_expr=()
  |   | |   |     └-dims=↧
  |   | |   |-separator=()
  |   | |   └-end=()
  |   | |-return_var=()
  |   | |-abiType=Source
  |   | |-accessType=Public
  |   | |-deftypeType=Implementation
  |   | |-bindc_name=()
  |   | |-elemental=.false.
  |   | |-pure=.false.
  |   | └-module=.false.
  |   └-main_program: 
  |   └-Program
  |     |-SymbolTable
  |     | |-counter=3
  |     | └-scope=↧
  |     |-name=main_program
  |     |-dependencies=
  |     └-body=↧
  |       └-SubroutineCall
  |         |-name=Function
  |         | |-SymbolTable
  |         | | |-counter=4
  |         | | └-scope=↧
  |         | |-name=_lpython_main_program
  |         | |-args=↧
  |         | |-type_params=↧
  |         | |-body=↧
  |         | | └-SubroutineCall
  |         | |   |-name=Function
  |         | |   | |-SymbolTable
  |         | |   | | |-counter=2
  |         | |   | | └-scope=↧
  |         | |   | |-name=f
  |         | |   | |-args=↧
  |         | |   | |-type_params=↧
  |         | |   | |-body=↧
  |         | |   | | └-Print
  |         | |   | |   |-fmt=()
  |         | |   | |   |-values=↧
  |         | |   | |   | └-StringConstant
  |         | |   | |   |   |-s="SDg"
  |         | |   | |   |   └-type=Character
  |         | |   | |   |     |-kind=1
  |         | |   | |   |     |-len=3
  |         | |   | |   |     |-len_expr=()
  |         | |   | |   |     └-dims=↧
  |         | |   | |   |-separator=()
  |         | |   | |   └-end=()
  |         | |   | |-return_var=()
  |         | |   | |-abiType=Source
  |         | |   | |-accessType=Public
  |         | |   | |-deftypeType=Implementation
  |         | |   | |-bindc_name=()
  |         | |   | |-elemental=.false.
  |         | |   | |-pure=.false.
  |         | |   | └-module=.false.
  |         | |   |-original_name=()
  |         | |   |-args=↧
  |         | |   └-dt=()
  |         | |-return_var=()
  |         | |-abiType=Source
  |         | |-accessType=Public
  |         | |-deftypeType=Implementation
  |         | |-bindc_name=()
  |         | |-elemental=.false.
  |         | |-pure=.false.
  |         | └-module=.false.
  |         |-original_name=()
  |         |-args=↧
  |         └-dt=()
  └-items=↧
<<<< End of Print ASR After Pass >>>> 

@czgdp1807
Copy link
Collaborator

So that's the cause of worry for me. The input code is very small. But since 10-15 ASRs printed to the same output stream, its hard to read and interpret. First I will have to locate the ASR I am looking for in the file and then search for the bug.

Printing each ASR in a different file will make life easier. I will be able to compare two ASRs easily by splitting the window and looking at two files simultaneously.

@certik
Copy link
Contributor

certik commented Aug 10, 2022

Multiple files are probably better, perhaps in a directory, so that we do not pollute the current directory. I think that can probably be done later quite easily after this is merged.

The bigger issue to resolve is the frontend dependency.

  Now we will generate a log folder to store each asr pass log.
  And add a helper function to select file to store the asr.
@redbopo redbopo force-pushed the print_ASR_after_pass branch from 10d5f4a to b54c7a2 Compare August 17, 2022 17:04
@redbopo
Copy link
Contributor Author

redbopo commented Aug 17, 2022

add ifdef like lpython/utils.h to deal with lpython/pickle.h

#if __has_include(<lpython/utils.h>)
    #include <lpython/pickle.h>
#endif

Now will mkdir a folder ./asr_pass_log/ and put all the asr.log files in it.
And a helper function write_asr_to_file.

std::cout << "The command '" + cmd + "' failed." << std::endl;
exit(1);
}
LFortran::write_asr_to_file("./asr_pass_log/0_raw.log", *asr, false, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is only available in LPython (in this PR), so it will fail in LFortran. We cannot use any LPython specific things in libasr. We'll have to figure out another solution to fix this.

  add apply_one_pass in pass mangaer that return str pass name.
  add emit_asr_after_pass in lpython.cpp
@redbopo
Copy link
Contributor Author

redbopo commented Aug 29, 2022

I think this is near the solution.
Since I add apply_one_pass method which return pass name in pass manger.

Here emit_asr_after_pass() and emit_asr() can't combine together,
since emit_asr_after_pass() need to be placed after lpython_pass_manager.use_default_passes();

@redbopo redbopo requested a review from certik August 30, 2022 11:07
@certik certik marked this pull request as draft October 4, 2022 15:32
@certik
Copy link
Contributor

certik commented Oct 4, 2022

I converted it to draft, when this is ready for review, just click on the "Ready for review" button, which will convert it back to a mergeable PR.

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.

3 participants