-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
remove redundant clones via mir opt? #83193
Copy link
Copy link
Open
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I wonder if it is possible to have an optimization pass that removes redundant clones if we know that
.clone()does not do anything funky and that the original object would have been untouched and dropped in the same block where it was cloned.There's a clippy lint which tries to warn about useless clones https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
The pass could optimize something like
to