Use PassMode::Direct for Abi::Aggregate by default
This commit is contained in:
parent
eb99ea5142
commit
c1c06f3e3f
2 changed files with 5 additions and 6 deletions
|
@ -2843,10 +2843,9 @@ where
|
||||||
let max_by_val_size = Pointer.size(cx) * 2;
|
let max_by_val_size = Pointer.size(cx) * 2;
|
||||||
let size = arg.layout.size;
|
let size = arg.layout.size;
|
||||||
|
|
||||||
let is_indirect_not_on_stack =
|
if arg.layout.is_unsized() || size > max_by_val_size {
|
||||||
matches!(arg.mode, PassMode::Indirect { on_stack: false, .. });
|
arg.make_indirect();
|
||||||
assert!(is_indirect_not_on_stack, "{:?}", arg);
|
} else {
|
||||||
if !arg.layout.is_unsized() && size <= max_by_val_size {
|
|
||||||
// We want to pass small aggregates as immediates, but using
|
// We want to pass small aggregates as immediates, but using
|
||||||
// a LLVM aggregate type for this leads to bad optimizations,
|
// a LLVM aggregate type for this leads to bad optimizations,
|
||||||
// so we pick an appropriately sized integer type instead.
|
// so we pick an appropriately sized integer type instead.
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub enum PassMode {
|
||||||
Ignore,
|
Ignore,
|
||||||
/// Pass the argument directly.
|
/// Pass the argument directly.
|
||||||
///
|
///
|
||||||
/// The argument has a layout abi of `Scalar` or `Vector`.
|
/// The argument has a layout abi of `Scalar`, `Vector` or in rare cases `Aggregate`.
|
||||||
Direct(ArgAttributes),
|
Direct(ArgAttributes),
|
||||||
/// Pass a pair's elements directly in two arguments.
|
/// Pass a pair's elements directly in two arguments.
|
||||||
///
|
///
|
||||||
|
@ -453,7 +453,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
|
||||||
scalar_attrs(&layout, b, a.value.size(cx).align_to(b.value.align(cx).abi)),
|
scalar_attrs(&layout, b, a.value.size(cx).align_to(b.value.align(cx).abi)),
|
||||||
),
|
),
|
||||||
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
|
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
|
||||||
Abi::Aggregate { .. } => Self::indirect_pass_mode(&layout),
|
Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
|
||||||
};
|
};
|
||||||
ArgAbi { layout, pad: None, mode }
|
ArgAbi { layout, pad: None, mode }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue