-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Refactor type memory layouts and ABIs, to be more general and easier to optimize. #45225
Merged
Merged
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
fab2532
rustc_trans: move const & lvalue access helpers from adt.
eddyb 9deea47
rustc_mir: always downcast enums, even if univariant.
eddyb f44b099
rustc_trans: avoid working with sizes/offsets and alignments as integ…
eddyb 386d59d
rustc_trans: use a predictable layout for constant ADTs.
eddyb b8671be
rustc_trans: remove obsolete Type methods.
eddyb 260c41b
rustc_trans: do not introspect LLVM aggregate field types.
eddyb 5b1fdae
rustc_trans: use more of the trans::mir and ty::layout APIs throughout.
eddyb 84b5a3d
rustc_trans: remove the in_memory_type_of distinction.
eddyb 0a1fcc3
rustc_trans: use *[T; 0] for slice data pointers instead of *T.
eddyb 8afa3a0
rustc_trans: always insert alignment padding, even before the first f…
eddyb 44eef7c
rustc: do not inject discriminant fields into Layout::General's varia…
eddyb 50a3fd0
rustc: remove useless 0 prefix from Layout::StructWrappedNullablePoin…
eddyb bc8e1f7
rustc: use an offset instead of a field path in Layout::StructWrapped…
eddyb aa811d7
rustc: remove source field path from Layout::StructWrappedNullablePoi…
eddyb 8864668
rustc: re-complicate the TyLayout API and use better names.
eddyb 8c4d5af
rustc: remove Ty::layout and move everything to layout_of.
eddyb 9a0efea
rustc: pre-compute field placements out of Layout.
eddyb 3071060
rustc_trans: treat General enums like unions.
eddyb 1dc572b
rustc: represent the discriminant as a field for Layout::{Raw,StructW…
eddyb caef91d
rustc: introduce layout::Abi for reduced general ABI "passing style".
eddyb 02276e9
rustc: collapse Layout::{Raw,StructWrapped}NullablePointer into one v…
eddyb 335bd8e
rustc: do not track `non_zero` in Layout.
eddyb 61c2bd9
rustc: use Primitive instead of Integer for CEnum and General discrim…
eddyb d318b9c
rustc: move CEnum's signedness into Primitive::Int.
eddyb 658ebfc
rustc: give Layout::CEnum a discriminant field like Layout::General.
eddyb 33a205b
rustc: collapse Layout::CEnum into Layout::General.
eddyb bd86f37
rustc: make Layout::NullablePointer a lot more like Layout::General.
eddyb bd51a2b
rustc: move size/alignment from Layout into layout::Abi.
eddyb ed788a6
rustc: store CachedLayout for each variant of enum Layout's instead o…
eddyb 08f9f13
rustc: hide details in Layout in favor of Abi or FieldPlacement.
eddyb 18d54aa
rustc: move layout::Struct into FieldPlacement/Abi.
eddyb fad9954
rustc: split layout::FieldPlacement::Linear back into Union and Array.
eddyb d0ab6e8
rustc_trans: compute LLVM types from type layouts, not Rust types.
eddyb b2d52d2
rustc: do not pub use Layout::* in layout.
eddyb f2e7e17
rustc_trans: pass OperandRef arguments to trans_intrinsic_call.
eddyb 88f7032
rustc_trans: nest abi::ArgType's for fat pointers instead of eagerly …
eddyb 1477119
rustc_trans: keep a layout instead of a type in {Lvalue,Operand}Ref.
eddyb 3fd6b00
rustc_trans: query LLVM types from a layout instead of a Ty.
eddyb 026214c
rustc: collapse Layout::FatPointer into Layout::Univariant.
eddyb b723af2
rustc_trans: go through layouts uniformly for fat pointers and variants.
eddyb b28f668
rustc: move size, align & primitive_align from Abi::Aggregate to layout.
eddyb 018323f
rustc: collapse the remains of Layout into Variants (enums vs everyth…
eddyb de3e581
rustc: support u128 discriminant ranges.
eddyb abbc1dd
rustc: make TyLayout::field(NonZero<*T>, 0) return &T.
eddyb 0190f27
rustc_trans: check for layout::I1 instead of TyBool.
eddyb b203a26
rustc: generalize layout::Variants::NicheFilling to niches other than 0.
eddyb 5df25c4
rustc: remove redundant/unused fields from layout::Abi::Vector.
eddyb f62e43d
rustc: track validity ranges for layout::Abi::Scalar values.
eddyb ced5e04
rustc: optimize out uninhabited types and variants.
eddyb f8d5d0c
rustc_trans: compute better align/dereferenceable attributes from poi…
eddyb ac60872
rustc_trans: generate LLVM pointee types based on alignment.
eddyb f1b7cd9
rustc_trans: restrict "immediate pairs" to pairs of scalars.
eddyb cdeb4b0
rustc: encode scalar pairs in layout ABI.
eddyb c4d9ada
rustc: place ZSTs first during struct field reordering.
eddyb 0b86972
rustc_trans: be more relaxed with non-lvalue consumes, especially ZSTs.
eddyb 37a7521
rustc: unpack scalar newtype layout ABIs.
eddyb 7a36141
rustc: unpack scalar pair newtype layout ABIs.
eddyb 18ecc56
rustc_trans: support scalar pairs directly in the Rust ABI.
eddyb fa67abd
rustc: don't special-case Box<T> as having a pointer layout.
eddyb 801a1a0
rustc_trans: remove type_is_fat_ptr and its uses.
eddyb d893285
rustc: use layout::Abi::ScalarPair for structs in more cases.
eddyb 8437d7c
rustc: extend the niche-filling enum optimization past 2 variants.
eddyb 753d582
rustc: rename CachedLayout to LayoutDetails.
eddyb 95687bf
rustc_trans: (hack) use preferred alignment for atomic loads/stores.
eddyb fb83283
Don't glob-import overlapping variant names in test/codegen/match-opt…
eddyb b0812de
cargotest: temporarily use eddyb/servo to include servo/servo#19285.
eddyb 88e4d2c
rustc_trans: work around i686-pc-windows-msvc byval align LLVM bug.
eddyb 89e4373
rustc_trans: remove primitive_align optimization.
eddyb f9f5ab9
Revert "tests: Update run-make/issue-25581 to reflect how fat pointer…
eddyb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
rustc: split layout::FieldPlacement::Linear back into Union and Array.
- Loading branch information
commit fad99542c8643984b7630d8e297007aef824b268
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do "general" enums use
FieldPlacement::Union
for the discriminant only and "niche" enums useFieldPlacement::Arbitrary
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because a tag is always at
offset
0
whereas a niche can be at some offset - we could have a variant ofFieldPlacement
that's just oneSize
to avoid theVec
but that's about it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why we can't use
FieldPlacement::Arbitrary
for both of them? "Normal" structs with one field don't suddenly useFieldPlacement::Union
because they can.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean,
FieldPlacement::Arbitrary
is a bit of a waste, and I considered usingFieldPlacement::Union
for normal structs too, but then I have checks forUnion
in some places which would conflict with that now. I think you're right and I should make the change here.EDIT: done.
EDIT2: That's funny, not using
FieldPlacement::Union
results in some missed optimizations (codegen/{alloc-optimisation,vec-optimizes-away}
). I'll try to see what I can do about it.EDIT3: None of the tricks I've tried work, I'll just leave it like this to avoid pessimizing tagged enums for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a comment to that effect?