@@ -785,9 +785,9 @@ fn call_inline_asm<'tcx>(
785
785
for ( offset, place) in outputs {
786
786
let ty = if place. layout ( ) . ty . is_simd ( ) {
787
787
let ( lane_count, lane_type) = place. layout ( ) . ty . simd_size_and_type ( fx. tcx ) ;
788
- fx . clif_type ( lane_type) . unwrap ( ) . by ( lane_count. try_into ( ) . unwrap ( ) ) . unwrap ( )
788
+ asm_clif_type ( fx , lane_type) . unwrap ( ) . by ( lane_count. try_into ( ) . unwrap ( ) ) . unwrap ( )
789
789
} else {
790
- fx . clif_type ( place. layout ( ) . ty ) . unwrap ( )
790
+ asm_clif_type ( fx , place. layout ( ) . ty ) . unwrap ( )
791
791
} ;
792
792
let value = stack_slot. offset ( fx, i32:: try_from ( offset. bytes ( ) ) . unwrap ( ) . into ( ) ) . load (
793
793
fx,
@@ -797,3 +797,24 @@ fn call_inline_asm<'tcx>(
797
797
place. write_cvalue ( fx, CValue :: by_val ( value, place. layout ( ) ) ) ;
798
798
}
799
799
}
800
+
801
+ fn asm_clif_type < ' tcx > ( fx : & FunctionCx < ' _ , ' _ , ' tcx > , ty : Ty < ' tcx > ) -> Option < types:: Type > {
802
+ match ty. kind ( ) {
803
+ // Adapted from https://github.com/rust-lang/rust/blob/f3c66088610c1b80110297c2d9a8b5f9265b013f/compiler/rustc_hir_analysis/src/check/intrinsicck.rs#L136-L151
804
+ ty:: Adt ( adt, args) if Some ( adt. did ( ) ) == fx. tcx . lang_items ( ) . maybe_uninit ( ) => {
805
+ let fields = & adt. non_enum_variant ( ) . fields ;
806
+ let ty = fields[ FieldIdx :: from_u32 ( 1 ) ] . ty ( fx. tcx , args) ;
807
+ let ty:: Adt ( ty, args) = ty. kind ( ) else {
808
+ unreachable ! ( "expected first field of `MaybeUninit` to be an ADT" )
809
+ } ;
810
+ assert ! (
811
+ ty. is_manually_drop( ) ,
812
+ "expected first field of `MaybeUninit` to be `ManuallyDrop`"
813
+ ) ;
814
+ let fields = & ty. non_enum_variant ( ) . fields ;
815
+ let ty = fields[ FieldIdx :: ZERO ] . ty ( fx. tcx , args) ;
816
+ fx. clif_type ( ty)
817
+ }
818
+ _ => fx. clif_type ( ty) ,
819
+ }
820
+ }
0 commit comments