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

Make Rust ABI return types up to two pointers in registers #124373

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ty_utils/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ fn fn_abi_adjust_for_abi<'tcx>(
// an LLVM aggregate type for this leads to bad optimizations,
// so we pick an appropriately sized integer type instead.
arg.cast_to(Reg { kind: RegKind::Integer, size });
} else if size <= data_pointer_size * 2 && size.bytes() % 2 == 0 {
} else if size == data_pointer_size * 2 && size.bytes() % 2 == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

There's no comment or anything explaining this subtlety -- please add it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, my original idea on how this should look got shot down by CI, so I'll look into this some more and add comments to the final version.

Copy link
Member

Choose a reason for hiding this comment

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

Right, so it would be useful to understand why the original assumption you made is not compatible with codegen and explain it here. It also may suggest a deeper bug in your implementation, though it's not certain unless you look into it.

// Aggregates like `[usize; 2]` or (on 64-bit arch) `[u128; 1]`
// can be passed as a scalar pair.
let part_size = Size::from_bytes(size.bytes() / 2);
Expand Down
Loading