Cranelift: extend alias analysis to eliminate dead stores#13806
Open
fitzgen wants to merge 1 commit into
Open
Conversation
This commit adds an "observed?" bit to every alias region in the alias analysis's `LastStores` data. Loads from a region set the bit, as do instructions that act as memory fences, like calls. When we see a store to a region that hasn't been observed, and the store is to the same memory location as the last store to that region, then the last store is dead and can be removed. This integrates with alias analysis's existing single forwards pass that is fused with the egraph pass; it doesn't require additional passes or iterations. However, because it is a single pass and not a fixed point, updates do not cascade, and removing a dead store does not then recompute `LastStores` and reveal that (for example) the dead store's killer is an idempotent store which could also be removed. See the new `check-unset-reset-flag.clif` filetest, which roughly reflects what component-model fused adapters do with the `MAY_LEAVE` flag, for an example of this behavior. Fixes bytecodealliance#4167
Member
Author
|
This is a speed up for our compile-time builtins benchmarks, as mentioned here: On a PCA-based subset of Sightglass:
Sightglass resultsI can look into speeding things up a bit more, but we should probably discuss this at the next Cranelift meeting. |
Member
|
I'm going to move this to being reviewed by @cfallin who I know is on PTO right now but I think will have sufficiently more context about this that he'll do a much better job than I |
Member
|
(happy to do so; logistical note that I'm out on PTO this week and next, then traveling-for-work the following week, so I can't guarantee I'll get to this before Mon Jul 20) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This commit adds an "observed?" bit to every alias region in the alias analysis's
LastStoresdata. Loads from a region set the bit, as do instructions that act as memory fences, like calls. When we see a store to a region that hasn't been observed, and the store is to the same memory location as the last store to that region, then the last store is dead and can be removed. This integrates with alias analysis's existing single forwards pass that is fused with the egraph pass; it doesn't require additional passes or iterations. However, because it is a single pass and not a fixed point, updates do not cascade, and removing a dead store does not then recomputeLastStoresand reveal that (for example) the dead store's killer is an idempotent store which could also be removed. See the newcheck-unset-reset-flag.cliffiletest, which roughly reflects what component-model fused adapters do with theMAY_LEAVEflag, for an example of this behavior.Fixes #4167