-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: more enum layout optimizations #101819
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #98588) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
I implemented |
About
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #102051) made this pull request unmergeable. Please resolve the merge conflicts. |
Status: In working on this, I've encountered what I'm 95% sure is a bug in the LLVM InstCombine pass that manifests in some cases with these layout optimizations. I'm going to investigate more, and then either fix that or report it, then will return to this PR. |
This comment has been minimized.
This comment has been minimized.
Rebased. Since some things were moved around it was most expedient to just squash the commits. I fixed the problem I mentioned above, which was in fact not an LLVM bug. The issue is that when there's a flag, the values of the niche are only actually restricted to its valid_range when the flag is set to its magic value. The solution I've adopted for now is, when there's a flag, to just emit the full range of the primitive as the valid range (see |
This comment has been minimized.
This comment has been minimized.
Also: Try to fit other variants by moving fields around the niche. Keep multiple niches, not just the largest one. Look for multiple largest variants. Introduce repr(flag). Fixes rust-lang#101567
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #102875) made this pull request unmergeable. Please resolve the merge conflicts. |
Do you want a review of this or are you still working on it? |
Let's hold off on a review for now. I'm going to modify it to fix #102997 also. |
@mikebenfield |
@JohnCSimon I've got local in-progress changes that are semi-close to being done. I've been meaning to get back to this anyway so I'll see if I can get them done and pushed here today or tomorrow. Can't guarantee it'll be done though. |
Status: I think I'll have this ready for review by end of week. I had it pretty much done and then got laid off and lost access to the code I had written 😂 . So I kind of had to start from scratch, but it should get done quickly this time. |
Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks |
Work in progress, but it works.
In addition to addressing #101567, also keep around multiple niches rather than just the largest one, and for tagged variants possibly move fields around the niche rather than just putting the whole variant before or after.
Things that aren't right at the moment:
rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs
Flag
, even though any field will doVec
of niches rather than just the largest one likely has a significant negative effect on performance, but I've done no performance testingFlag
Flag
probably makes no senserepr
to force anenum
to use aFlag
. Right now an enum like the one given in the issue:will just use a regular niche, which means
Option<Provenance>
won't be able to use a flag.