-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Deduplicate closures #63660
Copy link
Copy link
Closed
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-codegenArea: Code generationArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-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-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-codegenArea: Code generationArea: Code generationC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-heavyIssue: Problems and improvements with respect to binary size of generated code.Issue: Problems and improvements with respect to binary size of generated code.T-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.
#62429 manually deduplicated monomorphizations of closures. We should automate this during building instead of requiring users to do it manually. Ideally we'll revert the parts of #62429 that made things less readable as the last step of closing this issue.
I think the endgame would be that we'd deduplicate closures (in release mode only, so backtraces's file:line locations still make sense in debug mode), as long as their body is the same.
Not sure if that is possible, but random idea:
If we only care about monomorphizations in llvm, we could create a function that takes a closure's
mir::Body, cleans it of all "unnecessary" info likeSpans and then feeds that through a query (which thus will only be called once with the same arguments), producing the appropriate codegen backend's function handle.If we want to reduce type lengths, too, we'd need to change the way closure substs are built, by computing the minimal required set ahead of time.