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
[Opt] [ir] [refactor] Remove exceptions from IR passes #1059
Comments
@xumingkuan I'd like to help with this. What would you suggest the proper size of a related PR? Should we use a single PR to refactor all TODO passes or maybe 3-4 passes in one PR? |
I think it's fine with only 1 pass in one PR. Different passes usually won't cause conflicts even if you open several PRs at the same time, and it might be error-prone if many passes are refactored in one PR. |
As I look through the taichi/taichi/transforms/lower_ast.cpp Lines 143 to 145 in 4213973
I believe the code corresponds to your comment in #1272. But if we'll change the pass's signature to |
Oh, for the specific pass |
@TH3CHARLie |
@xumingkuan IIRC the |
I think yes, and shall we replace |
That sounds good. Thanks. |
If I understand the conversations correctly, |
I think yes -- I'll try to remove the CSE part of |
It looks like that |
I agree. It seems that its dependency, |
Agreed. The |
Currently, we have many IR passes using the pattern of exception, and we want to get rid of it.
How do we use exceptions now
We
throw IRModified();
when the IR is modified, and catch it using some code like the follows:Why do we need to use exceptions
I think the main reason comes from here:
Whenever we erase a statement from or insert one to a block, all
std::vector::iterator
s of that block'sstatements
may be invalidated. So we need to break allfor
loops like the above, and the most convenient way is to use exceptions.Why we want & how to get rid of exceptions
Using exceptions is probably not a good coding style, and it may cause some incompatibility issues, as discussed in #655.
If we mark all modifications in IR optimization passes and do them together iteratively instead of modifying the IR and throw an exception as soon as we find an optimization opportunity, this will greatly reduce compilation time and solve #926.
TODO list
variable_optimization([opt] [refactor] Remove the variable_optimization pass #3927)Additional comments
Shall we add the
noexcept
specifier to some functions known to not throwIRModified
? Will it cause some issues with other exceptions?The text was updated successfully, but these errors were encountered: