Skip to content

Commit dfc475d

Browse files
committed
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.
1 parent c58275e commit dfc475d

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
17371737
op.store_with_annotation(bx, scratch);
17381738
(scratch.val.llval, scratch.val.align, true)
17391739
}
1740-
_ => (op.immediate_or_packed_pair(bx), arg.layout.align.abi, false),
1740+
PassMode::Direct(_) => (op.immediate(), arg.layout.align.abi, false),
1741+
PassMode::Ignore | PassMode::Pair(..) => unreachable!("handled above"),
17411742
},
17421743
Ref(op_place_val) => match arg.mode {
17431744
PassMode::Indirect { attrs, on_stack, .. } => {

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,12 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
499499
PassMode::Direct(_) => {
500500
let llarg = bx.get_param(llarg_idx);
501501
llarg_idx += 1;
502-
return local(OperandRef::from_immediate_or_packed_pair(
503-
bx, llarg, arg.layout,
504-
));
502+
debug_assert!(bx.is_backend_immediate(arg.layout));
503+
return local(OperandRef {
504+
val: OperandValue::Immediate(llarg),
505+
layout: arg.layout,
506+
move_annotation: None,
507+
});
505508
}
506509
PassMode::Pair(..) => {
507510
let (a, b) = (bx.get_param(llarg_idx), bx.get_param(llarg_idx + 1));

compiler/rustc_codegen_ssa/src/mir/operand.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
306306

307307
/// If this operand is a `Pair`, we return an aggregate with the two values.
308308
/// For other cases, see `immediate`.
309+
///
310+
/// Note: The use of this is discouraged outside cg_llvm, as some other backends
311+
/// don't natively support packing multiple things into one like this.
309312
pub fn immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
310313
self,
311314
bx: &mut Bx,
@@ -324,6 +327,9 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
324327
}
325328

326329
/// If the type is a pair, we return a `Pair`, otherwise, an `Immediate`.
330+
///
331+
/// Note: The use of this is discouraged outside cg_llvm, as some other backends
332+
/// don't natively support packing multiple things into one like this.
327333
pub fn from_immediate_or_packed_pair<Bx: BuilderMethods<'a, 'tcx, Value = V>>(
328334
bx: &mut Bx,
329335
llval: V,

0 commit comments

Comments
 (0)