@@ -13,7 +13,7 @@ use rustc_session::{config::OptLevel, DataTypeKind, FieldInfo, SizeKind, Variant
13
13
use rustc_span:: symbol:: { Ident , 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,14 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
3182
3182
}
3183
3183
3184
3184
match arg. layout . abi {
3185
- Abi :: Aggregate { .. } => { }
3185
+ Abi :: Aggregate { .. } => {
3186
+ let max_by_val_size = Pointer . size ( self ) ;
3187
+ let size = arg. layout . size ;
3188
+
3189
+ if arg. layout . is_unsized ( ) || size > max_by_val_size {
3190
+ arg. make_indirect ( ) ;
3191
+ }
3192
+ }
3186
3193
3187
3194
// This is a fun case! The gist of what this is doing is
3188
3195
// that we want callers and callees to always agree on the
@@ -3208,24 +3215,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
3208
3215
&& self . tcx . sess . target . simd_types_indirect =>
3209
3216
{
3210
3217
arg. make_indirect ( ) ;
3211
- return ;
3212
3218
}
3213
-
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 } ) ;
3219
+ _ => { }
3229
3220
}
3230
3221
} ;
3231
3222
fixup ( & mut fn_abi. ret ) ;
0 commit comments