-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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.htmlC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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.
Description
#35168 adds the capability of deaggregating structs like:
tmp0 = ...;
tmp1 = ...;
tmp2 = Foo { a: ..., b: ... };
Into:
tmp2.0 = ...
tmp2.1 = ...
But, one could imagine situations where this is counter productive.
It's not clear if this should be handled by the Deaggregator or MIR trans.
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.htmlC-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-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
Projects
Milestone
Relationships
Development
Select code repository
Activity
nagisa commentedon Aug 4, 2016
I can’t think of a trivial way to reverse deaggregation, especially after multiple optimisation passes go through the MIR.
The newtype concern raised by Ariel could be easily handled by replacing
with
(This is probably the same thing as SRoA, which @eddyb mentioned) This likely would allow us to discard some of the
Pair
stuff in the translator as well, but would need a good heuristic to not become a pessimisation itself.nagisa commentedon Aug 4, 2016
That being said, I feel like LLVM should be more than capable to handle such case quite quickly by itself.
eddyb commentedon Aug 4, 2016
@nagisa There's 2 reasons SRoA isn't enough to replace
Pair
: fat pointers usePair
andCheckedBinOp
produces one. And yes, LLVM can handle most of these by itself anyway.Newtypes (including those with extra ZST fields) are more relevant because of "zero-cost abstractions".
Aatch commentedon Aug 4, 2016
@nagisa I think the issue is about not deaggregating in some cases, rather than trying to reverse it.
eddyb commentedon Feb 7, 2018
I have a prototype of optimizing through fields of locals and it's much more straight-forward to do it after deaggregation than trying to understand the creation of aggregates as a whole.
Feel free to reopen this if anything changes, but we're more likely to remove
Aggregate
from MIR.(which we can do in a borrowck-friendly way via
SetDiscriminant(x, 0)
on all aggregates)bjorn3 commentedon Jul 15, 2023
#107267 fixed this, right?