@@ -4,6 +4,7 @@ use gccjit::{ToLValue, ToRValue, Type};
4
4
use rustc_codegen_ssa:: traits:: { AbiBuilderMethods , BaseTypeMethods } ;
5
5
use rustc_data_structures:: fx:: FxHashSet ;
6
6
use rustc_middle:: bug;
7
+ use rustc_middle:: ty:: layout:: LayoutOf ;
7
8
use rustc_middle:: ty:: Ty ;
8
9
#[ cfg( feature = "master" ) ]
9
10
use rustc_session:: config;
@@ -184,9 +185,17 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
184
185
}
185
186
PassMode :: Indirect { attrs, meta_attrs : Some ( meta_attrs) , on_stack } => {
186
187
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 ;
190
199
}
191
200
} ;
192
201
argument_tys. push ( arg_ty) ;
0 commit comments