Remove unneeded clones in converter and rules - #371
Merged
Merged
Conversation
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 PR removes unneeded clones in converter by calling
SetValueFreshness/computed_expr_type_/SetFreshTypeon every fressh-value-producing path. It asserts thatcomputed_expr_type_is not Unknown after a conversion to make sure that we did not miss any path.PendingDeref carries freshness separately. Producers of PendingDeref set freshness and consumers act based on that. I also added
ComputedExprType::Pendingbecause freshness is unknown until the consumer of PendingDeref sets it.This PR also removes unneeded clones in rules using the
AccessIR attribute. Rules no longer clone their arguments. The preprocessor infers how each argument is used:borrow, borrow_mut, move, take. Amove(let s = a0) consumes the argument, and it's cloned if it's not already fresh. Aborrowusage (a0.len()) is never cloned.Besides removing unneeded clones, on the converter side, this fixes #363. On the rules side,
rule-preprocessorinfers the access type of each argument automatically instead on relying on the rule author to encode it properly. This caught a bug instd::vector::push_back(T&&): the rule argument took the argument by value and cloned it, instead of moving it.