@@ -4,6 +4,7 @@ use gccjit::{ToLValue, ToRValue, Type};
44use  rustc_codegen_ssa:: traits:: { AbiBuilderMethods ,  BaseTypeMethods } ; 
55use  rustc_data_structures:: fx:: FxHashSet ; 
66use  rustc_middle:: bug; 
7+ use  rustc_middle:: ty:: layout:: LayoutOf ; 
78use  rustc_middle:: ty:: Ty ; 
89#[ cfg( feature = "master" ) ]  
910use  rustc_session:: config; 
@@ -184,9 +185,17 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
184185 } 
185186 PassMode :: Indirect  {  attrs,  meta_attrs :  Some ( meta_attrs) ,  on_stack }  => { 
186187 assert ! ( !on_stack) ; 
187-  let  ty =
188-  apply_attrs ( cx. type_ptr_to ( arg. memory_ty ( cx) ) ,  & attrs,  argument_tys. len ( ) ) ; 
189-  apply_attrs ( ty,  & meta_attrs,  argument_tys. len ( ) ) 
188+  // Construct the type of a (wide) pointer to `ty`, and pass its two fields. 
189+  // Any two ABI-compatible unsized types have the same metadata type and 
190+  // moreover the same metadata value leads to the same dynamic size and 
191+  // alignment, so this respects ABI compatibility. 
192+  let  ptr_ty = Ty :: new_mut_ptr ( cx. tcx ,  arg. layout . ty ) ; 
193+  let  ptr_layout = cx. layout_of ( ptr_ty) ; 
194+  let  typ1 = ptr_layout. scalar_pair_element_gcc_type ( cx,  0 ) ; 
195+  let  typ2 = ptr_layout. scalar_pair_element_gcc_type ( cx,  1 ) ; 
196+  argument_tys. push ( apply_attrs ( typ1,  & attrs,  argument_tys. len ( ) ) ) ; 
197+  argument_tys. push ( apply_attrs ( typ2,  & meta_attrs,  argument_tys. len ( ) ) ) ; 
198+  continue ; 
190199 } 
191200 } ; 
192201 argument_tys. push ( arg_ty) ; 
0 commit comments