1
1
use crate :: common:: * ;
2
- use crate :: context:: TypeLowering ;
3
2
use crate :: type_:: Type ;
4
3
use rustc_codegen_ssa:: traits:: * ;
5
4
use rustc_middle:: bug;
@@ -10,15 +9,13 @@ use rustc_target::abi::HasDataLayout;
10
9
use rustc_target:: abi:: { Abi , Align , FieldsShape } ;
11
10
use rustc_target:: abi:: { Int , Pointer , F128 , F16 , F32 , F64 } ;
12
11
use rustc_target:: abi:: { Scalar , Size , Variants } ;
13
- use smallvec:: { smallvec, SmallVec } ;
14
12
15
13
use std:: fmt:: Write ;
16
14
17
15
fn uncached_llvm_type < ' a , ' tcx > (
18
16
cx : & CodegenCx < ' a , ' tcx > ,
19
17
layout : TyAndLayout < ' tcx > ,
20
18
defer : & mut Option < ( & ' a Type , TyAndLayout < ' tcx > ) > ,
21
- field_remapping : & mut Option < SmallVec < [ u32 ; 4 ] > > ,
22
19
) -> & ' a Type {
23
20
match layout. abi {
24
21
Abi :: Scalar ( _) => bug ! ( "handled elsewhere" ) ,
@@ -71,8 +68,7 @@ fn uncached_llvm_type<'a, 'tcx>(
71
68
FieldsShape :: Array { count, .. } => cx. type_array ( layout. field ( cx, 0 ) . llvm_type ( cx) , count) ,
72
69
FieldsShape :: Arbitrary { .. } => match name {
73
70
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) ;
76
72
cx. type_struct ( & llfields, packed)
77
73
}
78
74
Some ( ref name) => {
@@ -87,15 +83,14 @@ fn uncached_llvm_type<'a, 'tcx>(
87
83
fn struct_llfields < ' a , ' tcx > (
88
84
cx : & CodegenCx < ' a , ' tcx > ,
89
85
layout : TyAndLayout < ' tcx > ,
90
- ) -> ( Vec < & ' a Type > , bool , Option < SmallVec < [ u32 ; 4 ] > > ) {
86
+ ) -> ( Vec < & ' a Type > , bool ) {
91
87
debug ! ( "struct_llfields: {:#?}" , layout) ;
92
88
let field_count = layout. fields . count ( ) ;
93
89
94
90
let mut packed = false ;
95
91
let mut offset = Size :: ZERO ;
96
92
let mut prev_effective_align = layout. align . abi ;
97
93
let mut result: Vec < _ > = Vec :: with_capacity ( 1 + field_count * 2 ) ;
98
- let mut field_remapping = smallvec ! [ 0 ; field_count] ;
99
94
for i in layout. fields . index_by_increasing_offset ( ) {
100
95
let target_offset = layout. fields . offset ( i as usize ) ;
101
96
let field = layout. field ( cx, i) ;
@@ -120,12 +115,10 @@ fn struct_llfields<'a, 'tcx>(
120
115
result. push ( cx. type_padding_filler ( padding, padding_align) ) ;
121
116
debug ! ( " padding before: {:?}" , padding) ;
122
117
}
123
- field_remapping[ i] = result. len ( ) as u32 ;
124
118
result. push ( field. llvm_type ( cx) ) ;
125
119
offset = target_offset + field. size ;
126
120
prev_effective_align = effective_field_align;
127
121
}
128
- let padding_used = result. len ( ) > field_count;
129
122
if layout. is_sized ( ) && field_count > 0 {
130
123
if offset > layout. size {
131
124
bug ! ( "layout: {:#?} stride: {:?} offset: {:?}" , layout, layout. size, offset) ;
@@ -143,8 +136,7 @@ fn struct_llfields<'a, 'tcx>(
143
136
} else {
144
137
debug ! ( "struct_llfields: offset: {:?} stride: {:?}" , offset, layout. size) ;
145
138
}
146
- let field_remapping = padding_used. then_some ( field_remapping) ;
147
- ( result, packed, field_remapping)
139
+ ( result, packed)
148
140
}
149
141
150
142
impl < ' a , ' tcx > CodegenCx < ' a , ' tcx > {
@@ -224,7 +216,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
224
216
_ => None ,
225
217
} ;
226
218
if let Some ( llty) = cx. type_lowering . borrow ( ) . get ( & ( self . ty , variant_index) ) {
227
- return llty. lltype ;
219
+ return llty;
228
220
}
229
221
230
222
debug ! ( "llvm_type({:#?})" , self ) ;
@@ -236,30 +228,22 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
236
228
let normal_ty = cx. tcx . erase_regions ( self . ty ) ;
237
229
238
230
let mut defer = None ;
239
- let mut field_remapping = None ;
240
231
let llty = if self . ty != normal_ty {
241
232
let mut layout = cx. layout_of ( normal_ty) ;
242
233
if let Some ( v) = variant_index {
243
234
layout = layout. for_variant ( cx, v) ;
244
235
}
245
236
layout. llvm_type ( cx)
246
237
} else {
247
- uncached_llvm_type ( cx, * self , & mut defer, & mut field_remapping )
238
+ uncached_llvm_type ( cx, * self , & mut defer)
248
239
} ;
249
240
debug ! ( "--> mapped {:#?} to llty={:?}" , self , llty) ;
250
241
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) ;
254
243
255
244
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) ;
257
246
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;
263
247
}
264
248
llty
265
249
}
0 commit comments