avoid asserts over missing before state when generating safe Div/Rem nodes on AArch64 #226
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.
The Problem:
This patch fixes the 12 CountedLoop unit tests that currently fail with an assert during code generation.
Diagnosis:
On AArch64 DIv/Rem nodes are replaced by a snippet which includes AArch64-specific SafeDiv/Rem nodes. The latter are cloned from the original DIv/Rem nodes with a null beforeState. Unfortunately, they inherit their generate method from the generic Div/Rem nodes. The inherited methods call gen.state(this) to retrieve the beforeState and construct a FrameState passed in the call to the generators emitDiv/Rem method. This blows up because the beforeState is null.
Fix:
The AArch64 generator's emitDiv/Rem methods ignore the state argument because they will never encounter a div by zero. So, there is no need to compute a frame state. The fix works by overriding the inherited methods and passing null for the frame state.
Testing:
After this patch the 12 failing CountedLoop unit tests all succeed.