support scalar pairs properly - #640
Draft
Firestar99 wants to merge 1 commit into
Draft
Conversation
…rgs and entry point
Closed
eddyb
requested changes
Aug 7, 2026
eddyb
left a comment
Member
There was a problem hiding this comment.
LGTM, modulo trying to simplify entry.rs using the higher-level helpers that already exist.
Comment on lines
+687
to
+699
| let b_offset = a | ||
| .primitive() | ||
| .size(self) | ||
| .align_to(b.primitive().align(self).abi); | ||
|
|
||
| let elem0_ty = self.scalar_pair_element_backend_type(layout, 0, false); | ||
| let elem1_ty = self.scalar_pair_element_backend_type(layout, 1, false); | ||
|
|
||
| let base_ptr = value_ptr.unwrap(); | ||
| let ptr1 = bx.inbounds_ptradd(base_ptr, self.const_usize(b_offset.bytes())); | ||
|
|
||
| let v0 = bx.load(elem0_ty, base_ptr, layout.align.abi); | ||
| let v1 = bx.load(elem1_ty, ptr1, layout.align.restrict_for_offset(b_offset)); |
Member
There was a problem hiding this comment.
It might be possible to replace this with a call to load_operand.
Comment on lines
+584
to
+607
| } else if let Some( | ||
| &[ | ||
| Inst::Call(call_ret_id, callee_id, ref call_args), | ||
| Inst::CompositeExtract(extracted0, from0, 0), | ||
| Inst::CompositeExtract(extracted1, from1, 1), | ||
| ], | ||
| ) = try_rev_take(-3).as_deref() | ||
| && [from0, from1] == [call_ret_id; 2] | ||
| && [extracted0, extracted1] == [template_id, rt_args_ptr_id] | ||
| { | ||
| // Newer rustc, since `BackendRepr::ScalarPair` args are no | ||
| // longer forced to `PassMode::Direct`, returns the whole | ||
| // `fmt::Arguments` from its `new_*` constructor as a scalar | ||
| // pair, and splits it (via `OpCompositeExtract`s) into the | ||
| // two scalar values passed to the panic entry-point. | ||
| // | ||
| // The constructor's own arguments (i.e. `pieces`/`template` | ||
| // and the `rt::Argument` slice pointers) still carry the | ||
| // recoverable const data, so use those, like the aggregate | ||
| // (non-split) `Call`+`extract`+`insert` case does below. | ||
| let call_args_storage = call_args.iter().copied().collect(); | ||
| // Consume the matched call + both `OpCompositeExtract`s. | ||
| try_rev_take(3).unwrap(); | ||
| (lookup_fmt_args_ctor(callee_id)?, call_args_storage) |
Member
There was a problem hiding this comment.
The only reason I don't like this has to do with it feeling misplaced, likely a consequence of the split_fmt_args changes from months ago, which I might eventually revisit (and shouldn't block this PR).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Supersedes #381, see discussions over there.
Removes the "abi readjustment" aka hack to treat ScalarPairs as Scalars and adds proper support for ScalarPairs where necessary. Likely required to update beyond
nightly-2025-07-19, see discussion in PR #630 (comment).Reviewers: the fmt args decompiler adjustments are AI written, I have no idea what's going on in that module.