@@ -13,7 +13,7 @@ use rustc_session::{config::OptLevel, DataTypeKind, FieldInfo, SizeKind, Variant
13
13
use rustc_span:: symbol:: Symbol ;
14
14
use rustc_span:: { Span , DUMMY_SP } ;
15
15
use rustc_target:: abi:: call:: {
16
- ArgAbi , ArgAttribute , ArgAttributes , ArgExtension , Conv , FnAbi , PassMode , Reg , RegKind ,
16
+ ArgAbi , ArgAttribute , ArgAttributes , ArgExtension , Conv , FnAbi , PassMode ,
17
17
} ;
18
18
use rustc_target:: abi:: * ;
19
19
use rustc_target:: spec:: { abi:: Abi as SpecAbi , HasTargetSpec , PanicStrategy , Target } ;
@@ -3182,7 +3182,17 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
3182
3182
}
3183
3183
3184
3184
match arg. layout . abi {
3185
- Abi :: Aggregate { .. } => { }
3185
+ Abi :: Aggregate { .. } => {
3186
+ // Pass and return structures up to 2 pointers in size by value,
3187
+ // matching `ScalarPair`. LLVM will usually pass these in 2 registers
3188
+ // which is more efficient than by-ref.
3189
+ let max_by_val_size = Pointer . size ( self ) * 2 ;
3190
+ let size = arg. layout . size ;
3191
+
3192
+ if arg. layout . is_unsized ( ) || size >= max_by_val_size {
3193
+ arg. make_indirect ( ) ;
3194
+ }
3195
+ }
3186
3196
3187
3197
// This is a fun case! The gist of what this is doing is
3188
3198
// that we want callers and callees to always agree on the
@@ -3208,24 +3218,9 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
3208
3218
&& self . tcx . sess . target . simd_types_indirect =>
3209
3219
{
3210
3220
arg. make_indirect ( ) ;
3211
- return ;
3212
3221
}
3213
3222
3214
- _ => return ,
3215
- }
3216
-
3217
- // Pass and return structures up to 2 pointers in size by value, matching `ScalarPair`.
3218
- // LLVM will usually pass these in 2 registers, which is more efficient than by-ref.
3219
- let max_by_val_size = Pointer . size ( self ) * 2 ;
3220
- let size = arg. layout . size ;
3221
-
3222
- if arg. layout . is_unsized ( ) || size > max_by_val_size {
3223
- arg. make_indirect ( ) ;
3224
- } else {
3225
- // We want to pass small aggregates as immediates, but using
3226
- // a LLVM aggregate type for this leads to bad optimizations,
3227
- // so we pick an appropriately sized integer type instead.
3228
- arg. cast_to ( Reg { kind : RegKind :: Integer , size } ) ;
3223
+ _ => { }
3229
3224
}
3230
3225
} ;
3231
3226
fixup ( & mut fn_abi. ret ) ;
0 commit comments