[Util] Fix intermittent crash in OptimizeIntArithmeticPass #20637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We're seeing intermittent failures in 'sharktank_model_tests :: rocm_hip_w7900' tests on main:
The following issue contains more information on the crash and a reproducer: #20636
I am not entirely sure whether this PR contains a fix or a workaround. On one hand, it seems like correctly updating and invalidating all states manually in the transformations should lead to the same result without needing to recompute all states. On the other hand, the
DataFlowSolver
mentions that all analysis states should be erased when IR changes before a re-run (https://github.com/llvm/llvm-project/blob/12a31658ea36cda74157c6b4e6b6c031e39a19c0/mlir/include/mlir/Analysis/DataFlowFramework.h#L320):Note: I didn't add a test because I don't have a deterministic reproducer. As the crash is intermittent, the reproducer needs to be run a large number of times and will fail once in 10-200 runs maybe.