Reimplement ConstProp using DataflowConstProp#110719
Closed
cjgillot wants to merge 4 commits intorust-lang:masterfrom
Closed
Reimplement ConstProp using DataflowConstProp#110719cjgillot wants to merge 4 commits intorust-lang:masterfrom
cjgillot wants to merge 4 commits intorust-lang:masterfrom
Conversation
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 PR attempts to remove the current ConstProp optimization, and replace it by an implementation based on DataflowConstProp.
The current ConstProp twists the MIR interpreter to do things it is not designed to do, including manipulating generic types. Meanwhile, @jachris has implemented a new DataflowConstProp pass that only uses a few chosen methods for arithmetic.
The main change concerns how propagatable places and operations are tracked. In the current ConstProp, all places are tracked and all operations executed, and we removed wrong or non-propagatable results. This new implementation does the opposite : place tracking is opt-in, and we only propagate supported operations. I believe this approach to be less risky from a soundness point of view.
As a consequence, this new implementation is more restricted. The main limitation is that we stop propagating inside a basic block, and only propagate SSA locals. This makes the implementation simpler, and is more consistent with this "opt-in" logic.
Some operations are added inside this PR (transmutes, algebraic simplifications,
Lenoperations). The handling of statics and non-scalar consts are left to a follow-up PR.This PR does not remove the const-prop lints (arithmetic overflow and unconditional panic), as I need to design a way to pass more span information around.
There has been quite a few perf runs below. Marking as ready for review, since I removed the massive regressions on diesel/keccak/serde. Kept as waiting-on-author until I bless CI.
Regressed optimizations:
Based on #110728, #110732, #110820