Skip to content

Fix PassMode::Cast ABI argument lowering#1659

Open
Kuhai9801 wants to merge 2 commits into
rust-lang:mainfrom
Kuhai9801:fix-cast-abi-padding
Open

Fix PassMode::Cast ABI argument lowering#1659
Kuhai9801 wants to merge 2 commits into
rust-lang:mainfrom
Kuhai9801:fix-cast-abi-padding

Conversation

@Kuhai9801
Copy link
Copy Markdown

@Kuhai9801 Kuhai9801 commented May 31, 2026

Fixes #1477.

Updates PassMode::Cast lowering to pass rounded full ABI units for integer rest fields, matching CastTarget's rounded ABI layout. Casted call arguments now spill Rust-layout storage into an ABI-sized scratch slot before loading ABI parameters, so ABI padding does not cause loads from the wrong representation.

The patch also updates ABI parameter rounding for cast targets. A unit test covers the rounded integer rest case.

Verification:

  • git diff --check
  • cargo fmt --check

@Kuhai9801 Kuhai9801 force-pushed the fix-cast-abi-padding branch 2 times, most recently from c8ed51a to c15ab15 Compare May 31, 2026 14:53
Comment thread src/abi/pass_mode.rs Outdated
assert_eq!(params[1].0, Size::from_bytes(8));
assert_eq!(params[1].1.value_type, types::I64);
}
}
Copy link
Copy Markdown
Member

@bjorn3 bjorn3 May 31, 2026

Choose a reason for hiding this comment

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

We don't run unit tests.

View changes since the review

@bjorn3
Copy link
Copy Markdown
Member

bjorn3 commented May 31, 2026

It would be nice if we had a concrete test for a case that goes wrong without this change.

@Kuhai9801 Kuhai9801 force-pushed the fix-cast-abi-padding branch from c15ab15 to d3c9ff1 Compare May 31, 2026 15:10
@Kuhai9801 Kuhai9801 force-pushed the fix-cast-abi-padding branch from d3c9ff1 to 5e8d47a Compare May 31, 2026 15:20
@Kuhai9801 Kuhai9801 marked this pull request as ready for review May 31, 2026 17:44
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 31, 2026

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (NB. this repo may be misconfigured) some time within the next two weeks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply fixes from "https://github.com/rust-lang/rust/pull/122619" to cg_clif

3 participants