From eaaa03faf77b157907894a4207d8378ecaec7b45 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 1 Nov 2023 23:01:53 +0100 Subject: default Aggregate ABI to Indirect, and make sure it's never used for unsized --- compiler/rustc_ty_utils/src/abi.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_ty_utils/src') diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 7c044efdc0a..0db9c5a24a8 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -591,13 +591,14 @@ fn fn_abi_adjust_for_abi<'tcx>( _ => return, } - // `Aggregate` ABI must be adjusted to ensure that ABI-compatible Rust types are passed - // the same way. + // Compute `Aggregate` ABI. + + let is_indirect_not_on_stack = + matches!(arg.mode, PassMode::Indirect { on_stack: false, .. }); + assert!(is_indirect_not_on_stack, "{:?}", arg); let size = arg.layout.size; - if arg.layout.is_unsized() || size > Pointer(AddressSpace::DATA).size(cx) { - arg.make_indirect(); - } else { + if !arg.layout.is_unsized() && size <= Pointer(AddressSpace::DATA).size(cx) { // We want to pass small aggregates as immediates, but using // an LLVM aggregate type for this leads to bad optimizations, // so we pick an appropriately sized integer type instead. -- cgit 1.4.1-3-g733a5