@@ -213,7 +213,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
213
213
OperandValue :: Ref ( val, None , self . layout . align . abi ) . store ( bx, dst)
214
214
} else if self . is_unsized_indirect ( ) {
215
215
bug ! ( "unsized `ArgAbi` must be handled through `store_fn_arg`" ) ;
216
- } else if let PassMode :: Cast ( cast) = & self . mode {
216
+ } else if let PassMode :: Cast ( cast, _ ) = & self . mode {
217
217
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
218
218
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
219
219
let can_store_through_cast_ptr = false ;
@@ -283,7 +283,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
283
283
}
284
284
PassMode :: Direct ( _)
285
285
| PassMode :: Indirect { attrs : _, extra_attrs : None , on_stack : _ }
286
- | PassMode :: Cast ( _ ) => {
286
+ | PassMode :: Cast ( .. ) => {
287
287
let next_arg = next ( ) ;
288
288
self . store ( bx, next_arg, dst) ;
289
289
}
@@ -336,19 +336,14 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
336
336
let llreturn_ty = match & self . ret . mode {
337
337
PassMode :: Ignore => cx. type_void ( ) ,
338
338
PassMode :: Direct ( _) | PassMode :: Pair ( ..) => self . ret . layout . immediate_llvm_type ( cx) ,
339
- PassMode :: Cast ( cast) => cast. llvm_type ( cx) ,
339
+ PassMode :: Cast ( cast, _ ) => cast. llvm_type ( cx) ,
340
340
PassMode :: Indirect { .. } => {
341
341
llargument_tys. push ( cx. type_ptr_to ( self . ret . memory_ty ( cx) ) ) ;
342
342
cx. type_void ( )
343
343
}
344
344
} ;
345
345
346
346
for arg in args {
347
- // add padding
348
- if arg. pad_i32 {
349
- llargument_tys. push ( Reg :: i32 ( ) . llvm_type ( cx) ) ;
350
- }
351
-
352
347
let llarg_ty = match & arg. mode {
353
348
PassMode :: Ignore => continue ,
354
349
PassMode :: Direct ( _) => arg. layout . immediate_llvm_type ( cx) ,
@@ -364,7 +359,13 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
364
359
llargument_tys. push ( ptr_layout. scalar_pair_element_llvm_type ( cx, 1 , true ) ) ;
365
360
continue ;
366
361
}
367
- PassMode :: Cast ( cast) => cast. llvm_type ( cx) ,
362
+ PassMode :: Cast ( cast, pad_i32) => {
363
+ // add padding
364
+ if * pad_i32 {
365
+ llargument_tys. push ( Reg :: i32 ( ) . llvm_type ( cx) ) ;
366
+ }
367
+ cast. llvm_type ( cx)
368
+ }
368
369
PassMode :: Indirect { attrs : _, extra_attrs : None , on_stack : _ } => {
369
370
cx. type_ptr_to ( arg. memory_ty ( cx) )
370
371
}
@@ -434,15 +435,12 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
434
435
let sret = llvm:: CreateStructRetAttr ( cx. llcx , self . ret . layout . llvm_type ( cx) ) ;
435
436
attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Argument ( i) , & [ sret] ) ;
436
437
}
437
- PassMode :: Cast ( cast) => {
438
+ PassMode :: Cast ( cast, _ ) => {
438
439
cast. attrs . apply_attrs_to_llfn ( llvm:: AttributePlace :: ReturnValue , cx, llfn) ;
439
440
}
440
441
_ => { }
441
442
}
442
443
for arg in self . args . iter ( ) {
443
- if arg. pad_i32 {
444
- apply ( & ArgAttributes :: new ( ) ) ;
445
- }
446
444
match & arg. mode {
447
445
PassMode :: Ignore => { }
448
446
PassMode :: Indirect { attrs, extra_attrs : None , on_stack : true } => {
@@ -463,7 +461,10 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
463
461
apply ( a) ;
464
462
apply ( b) ;
465
463
}
466
- PassMode :: Cast ( cast) => {
464
+ PassMode :: Cast ( cast, pad_i32) => {
465
+ if * pad_i32 {
466
+ apply ( & ArgAttributes :: new ( ) ) ;
467
+ }
467
468
apply ( & cast. attrs ) ;
468
469
}
469
470
}
@@ -496,7 +497,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
496
497
let sret = llvm:: CreateStructRetAttr ( bx. cx . llcx , self . ret . layout . llvm_type ( bx) ) ;
497
498
attributes:: apply_to_callsite ( callsite, llvm:: AttributePlace :: Argument ( i) , & [ sret] ) ;
498
499
}
499
- PassMode :: Cast ( cast) => {
500
+ PassMode :: Cast ( cast, _ ) => {
500
501
cast. attrs . apply_attrs_to_callsite (
501
502
llvm:: AttributePlace :: ReturnValue ,
502
503
& bx. cx ,
@@ -516,9 +517,6 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
516
517
}
517
518
}
518
519
for arg in self . args . iter ( ) {
519
- if arg. pad_i32 {
520
- apply ( bx. cx , & ArgAttributes :: new ( ) ) ;
521
- }
522
520
match & arg. mode {
523
521
PassMode :: Ignore => { }
524
522
PassMode :: Indirect { attrs, extra_attrs : None , on_stack : true } => {
@@ -542,7 +540,10 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
542
540
apply ( bx. cx , a) ;
543
541
apply ( bx. cx , b) ;
544
542
}
545
- PassMode :: Cast ( cast) => {
543
+ PassMode :: Cast ( cast, pad_i32) => {
544
+ if * pad_i32 {
545
+ apply ( bx. cx , & ArgAttributes :: new ( ) ) ;
546
+ }
546
547
apply ( bx. cx , & cast. attrs ) ;
547
548
}
548
549
}
0 commit comments