@@ -213,7 +213,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
213213 OperandValue :: Ref ( val, None , self . layout . align . abi ) . store ( bx, dst)
214214 } else if self . is_unsized_indirect ( ) {
215215 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 {
217217 // FIXME(eddyb): Figure out when the simpler Store is safe, clang
218218 // uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
219219 let can_store_through_cast_ptr = false ;
@@ -283,7 +283,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
283283 }
284284 PassMode :: Direct ( _)
285285 | PassMode :: Indirect { attrs : _, extra_attrs : None , on_stack : _ }
286- | PassMode :: Cast ( _ ) => {
286+ | PassMode :: Cast ( .. ) => {
287287 let next_arg = next ( ) ;
288288 self . store ( bx, next_arg, dst) ;
289289 }
@@ -336,19 +336,14 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
336336 let llreturn_ty = match & self . ret . mode {
337337 PassMode :: Ignore => cx. type_void ( ) ,
338338 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) ,
340340 PassMode :: Indirect { .. } => {
341341 llargument_tys. push ( cx. type_ptr_to ( self . ret . memory_ty ( cx) ) ) ;
342342 cx. type_void ( )
343343 }
344344 } ;
345345
346346 for arg in args {
347- // add padding
348- if arg. pad_i32 {
349- llargument_tys. push ( Reg :: i32 ( ) . llvm_type ( cx) ) ;
350- }
351-
352347 let llarg_ty = match & arg. mode {
353348 PassMode :: Ignore => continue ,
354349 PassMode :: Direct ( _) => arg. layout . immediate_llvm_type ( cx) ,
@@ -364,7 +359,13 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
364359 llargument_tys. push ( ptr_layout. scalar_pair_element_llvm_type ( cx, 1 , true ) ) ;
365360 continue ;
366361 }
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+ }
368369 PassMode :: Indirect { attrs : _, extra_attrs : None , on_stack : _ } => {
369370 cx. type_ptr_to ( arg. memory_ty ( cx) )
370371 }
@@ -434,15 +435,12 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
434435 let sret = llvm:: CreateStructRetAttr ( cx. llcx , self . ret . layout . llvm_type ( cx) ) ;
435436 attributes:: apply_to_llfn ( llfn, llvm:: AttributePlace :: Argument ( i) , & [ sret] ) ;
436437 }
437- PassMode :: Cast ( cast) => {
438+ PassMode :: Cast ( cast, _ ) => {
438439 cast. attrs . apply_attrs_to_llfn ( llvm:: AttributePlace :: ReturnValue , cx, llfn) ;
439440 }
440441 _ => { }
441442 }
442443 for arg in self . args . iter ( ) {
443- if arg. pad_i32 {
444- apply ( & ArgAttributes :: new ( ) ) ;
445- }
446444 match & arg. mode {
447445 PassMode :: Ignore => { }
448446 PassMode :: Indirect { attrs, extra_attrs : None , on_stack : true } => {
@@ -463,7 +461,10 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
463461 apply ( a) ;
464462 apply ( b) ;
465463 }
466- PassMode :: Cast ( cast) => {
464+ PassMode :: Cast ( cast, pad_i32) => {
465+ if * pad_i32 {
466+ apply ( & ArgAttributes :: new ( ) ) ;
467+ }
467468 apply ( & cast. attrs ) ;
468469 }
469470 }
@@ -496,7 +497,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
496497 let sret = llvm:: CreateStructRetAttr ( bx. cx . llcx , self . ret . layout . llvm_type ( bx) ) ;
497498 attributes:: apply_to_callsite ( callsite, llvm:: AttributePlace :: Argument ( i) , & [ sret] ) ;
498499 }
499- PassMode :: Cast ( cast) => {
500+ PassMode :: Cast ( cast, _ ) => {
500501 cast. attrs . apply_attrs_to_callsite (
501502 llvm:: AttributePlace :: ReturnValue ,
502503 & bx. cx ,
@@ -516,9 +517,6 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
516517 }
517518 }
518519 for arg in self . args . iter ( ) {
519- if arg. pad_i32 {
520- apply ( bx. cx , & ArgAttributes :: new ( ) ) ;
521- }
522520 match & arg. mode {
523521 PassMode :: Ignore => { }
524522 PassMode :: Indirect { attrs, extra_attrs : None , on_stack : true } => {
@@ -542,7 +540,10 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
542540 apply ( bx. cx , a) ;
543541 apply ( bx. cx , b) ;
544542 }
545- PassMode :: Cast ( cast) => {
543+ PassMode :: Cast ( cast, pad_i32) => {
544+ if * pad_i32 {
545+ apply ( bx. cx , & ArgAttributes :: new ( ) ) ;
546+ }
546547 apply ( bx. cx , & cast. attrs ) ;
547548 }
548549 }
0 commit comments