From dfc475d018c780475ea962f15d86cfa05a50a148 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 31 May 2026 13:19:56 -0700 Subject: [PATCH] cg_ssa: a bit less `immediate_or_packed_pair` This is one of the things that made cg_clif not use cg_ssa, IIRC, so let's take the opportunities to avoid it where we can. --- compiler/rustc_codegen_ssa/src/mir/block.rs | 3 ++- compiler/rustc_codegen_ssa/src/mir/mod.rs | 9 ++++++--- compiler/rustc_codegen_ssa/src/mir/operand.rs | 6 ++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index b6b95c5f12aae..0eaad18430c2b 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1737,7 +1737,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { op.store_with_annotation(bx, scratch); (scratch.val.llval, scratch.val.align, true) } - _ => (op.immediate_or_packed_pair(bx), arg.layout.align.abi, false), + PassMode::Direct(_) => (op.immediate(), arg.layout.align.abi, false), + PassMode::Ignore | PassMode::Pair(..) => unreachable!("handled above"), }, Ref(op_place_val) => match arg.mode { PassMode::Indirect { attrs, on_stack, .. } => { diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 4bcf037ecce07..0abdef85b1980 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -499,9 +499,12 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( PassMode::Direct(_) => { let llarg = bx.get_param(llarg_idx); llarg_idx += 1; - return local(OperandRef::from_immediate_or_packed_pair( - bx, llarg, arg.layout, - )); + debug_assert!(bx.is_backend_immediate(arg.layout)); + return local(OperandRef { + val: OperandValue::Immediate(llarg), + layout: arg.layout, + move_annotation: None, + }); } PassMode::Pair(..) => { let (a, b) = (bx.get_param(llarg_idx), bx.get_param(llarg_idx + 1)); diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index c0c71edd4d905..68a84ebdae9fc 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -306,6 +306,9 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { /// If this operand is a `Pair`, we return an aggregate with the two values. /// For other cases, see `immediate`. + /// + /// Note: The use of this is discouraged outside cg_llvm, as some other backends + /// don't natively support packing multiple things into one like this. pub fn immediate_or_packed_pair>( self, bx: &mut Bx, @@ -324,6 +327,9 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } /// If the type is a pair, we return a `Pair`, otherwise, an `Immediate`. + /// + /// Note: The use of this is discouraged outside cg_llvm, as some other backends + /// don't natively support packing multiple things into one like this. pub fn from_immediate_or_packed_pair>( bx: &mut Bx, llval: V,