Skip to content
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

Avoid alignment mismatch between ABI and layout for unions. #104872

Merged
merged 9 commits into from
May 6, 2023

Conversation

luqmana
Copy link
Member

@luqmana luqmana commented Nov 25, 2022

Fixes #104802
Fixes #103634

r? @eddyb cc @RalfJung

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 25, 2022
@eddyb
Copy link
Member

eddyb commented Nov 28, 2022

I would prefer if this was fixed by #103926 - specifically, this comment: #103926 (comment).

If you can arrange with @oli-obk, you could take over in this PR - I don't care as long as both alignment sources are fixed at once without special-casing them.

Also, we need a test for #[repr(packed)] union Foo { zst: [u16; 0], byte: u8 }, which should, by virtue of #[repr(packed)] reducing alignment back, be able to be Abi::Scalar again!

@luqmana
Copy link
Member Author

luqmana commented Nov 28, 2022

I would prefer if this was fixed by #103926 - specifically, this comment: #103926 (comment).

If you can arrange with @oli-obk, you could take over in this PR - I don't care as long as both alignment sources are fixed at once without special-casing them.

Ah, admittedly I did see that issue but didn't dig too deep into it. I'm ok with taking a stab at it or leaving it to @oli-obk

@oli-obk
Copy link
Contributor

oli-obk commented Nov 29, 2022

I'm ok with taking a stab at it or leaving it to @oli-obk

I won't get to it this week or next week, so feel free to take over!

@bors
Copy link
Contributor

bors commented Dec 11, 2022

☔ The latest upstream changes (presumably #105554) made this pull request unmergeable. Please resolve the merge conflicts.

@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk requested a review from eddyb December 22, 2022 09:25
compiler/rustc_abi/src/layout.rs Outdated Show resolved Hide resolved
compiler/rustc_abi/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_abi/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_abi/src/lib.rs Outdated Show resolved Hide resolved
compiler/rustc_abi/src/layout.rs Outdated Show resolved Hide resolved
@apiraino
Copy link
Contributor

apiraino commented Feb 2, 2023

Switching to waiting on author to incorporate changes. Feel free to request a review with @rustbot ready, thanks!

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2023
@luqmana
Copy link
Member Author

luqmana commented Feb 20, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 20, 2023
@wesleywiser
Copy link
Member

Visited during the compiler team triage meeting. It looks like @eddyb's feedback has been taken into account and resolved. Reassigning to @oli-obk for review. Feel free to reroll if you would prefer!

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned eddyb Mar 16, 2023
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a nit, then this lgtm

Abi::Vector { element: x.to_union(), count }
let field_abi = field.abi().to_union();

if let Ok(Some((common_abi, common_align))) = &mut common_non_zst_abi_and_align {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relies on the !is_err check above. Maybe replace that check with a let Ok(common_non_zst_abi_and_align) = &mut common_non_zst_abi_and_align to make sure these two things stay in sync

Suggested change
if let Ok(Some((common_abi, common_align))) = &mut common_non_zst_abi_and_align {
if let Some((common_abi, common_align)) = &mut common_non_zst_abi_and_align {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, reordered it a bit to remove the is_err check.

@bors
Copy link
Contributor

bors commented Mar 26, 2023

☔ The latest upstream changes (presumably #109626) made this pull request unmergeable. Please resolve the merge conflicts.

@pnkfelix
Copy link
Member

pnkfelix commented May 4, 2023

@rustbot label: +S-waiting-on-author -S-waiting-on-review

just needs a rebase according to @oli-obk

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 4, 2023
@luqmana
Copy link
Member Author

luqmana commented May 5, 2023

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 5, 2023
@oli-obk
Copy link
Contributor

oli-obk commented May 6, 2023

@bors r+

@bors
Copy link
Contributor

bors commented May 6, 2023

📌 Commit 8e7714d has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 6, 2023
@bors
Copy link
Contributor

bors commented May 6, 2023

⌛ Testing commit 8e7714d with merge 151a070...

@bors
Copy link
Contributor

bors commented May 6, 2023

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 151a070 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 6, 2023
@bors bors merged commit 151a070 into rust-lang:master May 6, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 6, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (151a070): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.5% [-2.7%, -2.2%] 2
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 656.275s -> 653.613s (-0.41%)

@luqmana luqmana deleted the packed-union-align branch May 7, 2023 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet