11use crate :: common:: * ;
2- use crate :: context:: TypeLowering ;
32use crate :: type_:: Type ;
43use rustc_codegen_ssa:: traits:: * ;
54use rustc_middle:: bug;
@@ -10,15 +9,13 @@ use rustc_target::abi::HasDataLayout;
109use rustc_target:: abi:: { Abi , Align , FieldsShape } ;
1110use rustc_target:: abi:: { Int , Pointer , F128 , F16 , F32 , F64 } ;
1211use rustc_target:: abi:: { Scalar , Size , Variants } ;
13- use smallvec:: { smallvec, SmallVec } ;
1412
1513use std:: fmt:: Write ;
1614
1715fn uncached_llvm_type < ' a , ' tcx > (
1816 cx : & CodegenCx < ' a , ' tcx > ,
1917 layout : TyAndLayout < ' tcx > ,
2018 defer : & mut Option < ( & ' a Type , TyAndLayout < ' tcx > ) > ,
21- field_remapping : & mut Option < SmallVec < [ u32 ; 4 ] > > ,
2219) -> & ' a Type {
2320 match layout. abi {
2421 Abi :: Scalar ( _) => bug ! ( "handled elsewhere" ) ,
@@ -71,8 +68,7 @@ fn uncached_llvm_type<'a, 'tcx>(
7168 FieldsShape :: Array { count, .. } => cx. type_array ( layout. field ( cx, 0 ) . llvm_type ( cx) , count) ,
7269 FieldsShape :: Arbitrary { .. } => match name {
7370 None => {
74- let ( llfields, packed, new_field_remapping) = struct_llfields ( cx, layout) ;
75- * field_remapping = new_field_remapping;
71+ let ( llfields, packed) = struct_llfields ( cx, layout) ;
7672 cx. type_struct ( & llfields, packed)
7773 }
7874 Some ( ref name) => {
@@ -87,15 +83,14 @@ fn uncached_llvm_type<'a, 'tcx>(
8783fn struct_llfields < ' a , ' tcx > (
8884 cx : & CodegenCx < ' a , ' tcx > ,
8985 layout : TyAndLayout < ' tcx > ,
90- ) -> ( Vec < & ' a Type > , bool , Option < SmallVec < [ u32 ; 4 ] > > ) {
86+ ) -> ( Vec < & ' a Type > , bool ) {
9187 debug ! ( "struct_llfields: {:#?}" , layout) ;
9288 let field_count = layout. fields . count ( ) ;
9389
9490 let mut packed = false ;
9591 let mut offset = Size :: ZERO ;
9692 let mut prev_effective_align = layout. align . abi ;
9793 let mut result: Vec < _ > = Vec :: with_capacity ( 1 + field_count * 2 ) ;
98- let mut field_remapping = smallvec ! [ 0 ; field_count] ;
9994 for i in layout. fields . index_by_increasing_offset ( ) {
10095 let target_offset = layout. fields . offset ( i as usize ) ;
10196 let field = layout. field ( cx, i) ;
@@ -120,12 +115,10 @@ fn struct_llfields<'a, 'tcx>(
120115 result. push ( cx. type_padding_filler ( padding, padding_align) ) ;
121116 debug ! ( " padding before: {:?}" , padding) ;
122117 }
123- field_remapping[ i] = result. len ( ) as u32 ;
124118 result. push ( field. llvm_type ( cx) ) ;
125119 offset = target_offset + field. size ;
126120 prev_effective_align = effective_field_align;
127121 }
128- let padding_used = result. len ( ) > field_count;
129122 if layout. is_sized ( ) && field_count > 0 {
130123 if offset > layout. size {
131124 bug ! ( "layout: {:#?} stride: {:?} offset: {:?}" , layout, layout. size, offset) ;
@@ -143,8 +136,7 @@ fn struct_llfields<'a, 'tcx>(
143136 } else {
144137 debug ! ( "struct_llfields: offset: {:?} stride: {:?}" , offset, layout. size) ;
145138 }
146- let field_remapping = padding_used. then_some ( field_remapping) ;
147- ( result, packed, field_remapping)
139+ ( result, packed)
148140}
149141
150142impl < ' a , ' tcx > CodegenCx < ' a , ' tcx > {
@@ -224,7 +216,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
224216 _ => None ,
225217 } ;
226218 if let Some ( llty) = cx. type_lowering . borrow ( ) . get ( & ( self . ty , variant_index) ) {
227- return llty. lltype ;
219+ return llty;
228220 }
229221
230222 debug ! ( "llvm_type({:#?})" , self ) ;
@@ -236,30 +228,22 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
236228 let normal_ty = cx. tcx . erase_regions ( self . ty ) ;
237229
238230 let mut defer = None ;
239- let mut field_remapping = None ;
240231 let llty = if self . ty != normal_ty {
241232 let mut layout = cx. layout_of ( normal_ty) ;
242233 if let Some ( v) = variant_index {
243234 layout = layout. for_variant ( cx, v) ;
244235 }
245236 layout. llvm_type ( cx)
246237 } else {
247- uncached_llvm_type ( cx, * self , & mut defer, & mut field_remapping )
238+ uncached_llvm_type ( cx, * self , & mut defer)
248239 } ;
249240 debug ! ( "--> mapped {:#?} to llty={:?}" , self , llty) ;
250241
251- cx. type_lowering
252- . borrow_mut ( )
253- . insert ( ( self . ty , variant_index) , TypeLowering { lltype : llty, field_remapping } ) ;
242+ cx. type_lowering . borrow_mut ( ) . insert ( ( self . ty , variant_index) , llty) ;
254243
255244 if let Some ( ( llty, layout) ) = defer {
256- let ( llfields, packed, new_field_remapping ) = struct_llfields ( cx, layout) ;
245+ let ( llfields, packed) = struct_llfields ( cx, layout) ;
257246 cx. set_struct_body ( llty, & llfields, packed) ;
258- cx. type_lowering
259- . borrow_mut ( )
260- . get_mut ( & ( self . ty , variant_index) )
261- . unwrap ( )
262- . field_remapping = new_field_remapping;
263247 }
264248 llty
265249 }
0 commit comments