-
Notifications
You must be signed in to change notification settings - Fork 171
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
base: main
Are you sure you want to change the base?
Conversation
src/libasr/pass/pass_manager.h
Outdated
@@ -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> |
There was a problem hiding this comment.
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.
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. |
Thanks for quick review @certik . Forget to add the error msg , it's |
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. |
I like to use |
@redbopo Can you show the output (like just commenting here should be good) for your changes with a small input file? |
Of couse, @czgdp1807 . The input file I code is as follow, and the output of ASR in the terminal
|
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. |
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.
10d5f4a
to
b54c7a2
Compare
add ifdef like
Now will mkdir a folder ./asr_pass_log/ and put all the asr.log files in it. |
src/libasr/pass/pass_manager.h
Outdated
std::cout << "The command '" + cmd + "' failed." << std::endl; | ||
exit(1); | ||
} | ||
LFortran::write_asr_to_file("./asr_pass_log/0_raw.log", *asr, false, false); |
There was a problem hiding this comment.
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
I think this is near the solution. Here emit_asr_after_pass() and emit_asr() can't combine together, |
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. |
Add command
--print-after-asr-pass
on issue-943The 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