@@ -10,6 +10,7 @@ use rustc_middle::ty::{self, Ty, TypeFoldable};
10
10
use rustc_target:: abi:: { Abi , AddressSpace , Align , FieldsShape } ;
11
11
use rustc_target:: abi:: { Int , Pointer , F32 , F64 } ;
12
12
use rustc_target:: abi:: { LayoutOf , PointeeInfo , Scalar , Size , TyAndLayoutMethods , Variants } ;
13
+ use smallvec:: { smallvec, SmallVec } ;
13
14
use tracing:: debug;
14
15
15
16
use std:: fmt:: Write ;
@@ -18,7 +19,7 @@ fn uncached_llvm_type<'a, 'tcx>(
18
19
cx : & CodegenCx < ' a , ' tcx > ,
19
20
layout : TyAndLayout < ' tcx > ,
20
21
defer : & mut Option < ( & ' a Type , TyAndLayout < ' tcx > ) > ,
21
- field_remapping : & mut Option < Box < [ u32 ] > > ,
22
+ field_remapping : & mut Option < Box < SmallVec < [ u32 ; 4 ] > > > ,
22
23
) -> & ' a Type {
23
24
match layout. abi {
24
25
Abi :: Scalar ( _) => bug ! ( "handled elsewhere" ) ,
@@ -93,15 +94,15 @@ fn uncached_llvm_type<'a, 'tcx>(
93
94
fn struct_llfields < ' a , ' tcx > (
94
95
cx : & CodegenCx < ' a , ' tcx > ,
95
96
layout : TyAndLayout < ' tcx > ,
96
- ) -> ( Vec < & ' a Type > , bool , Option < Box < [ u32 ] > > ) {
97
+ ) -> ( Vec < & ' a Type > , bool , Option < Box < SmallVec < [ u32 ; 4 ] > > > ) {
97
98
debug ! ( "struct_llfields: {:#?}" , layout) ;
98
99
let field_count = layout. fields . count ( ) ;
99
100
100
101
let mut packed = false ;
101
102
let mut offset = Size :: ZERO ;
102
103
let mut prev_effective_align = layout. align . abi ;
103
104
let mut result: Vec < _ > = Vec :: with_capacity ( 1 + field_count * 2 ) ;
104
- let mut field_remapping = vec ! [ 0 ; field_count] ;
105
+ let mut field_remapping = smallvec ! [ 0 ; field_count] ;
105
106
for i in layout. fields . index_by_increasing_offset ( ) {
106
107
let target_offset = layout. fields . offset ( i as usize ) ;
107
108
let field = layout. field ( cx, i) ;
@@ -150,7 +151,7 @@ fn struct_llfields<'a, 'tcx>(
150
151
debug ! ( "struct_llfields: offset: {:?} stride: {:?}" , offset, layout. size) ;
151
152
}
152
153
153
- ( result, packed, padding_used. then_some ( field_remapping . into_boxed_slice ( ) ) )
154
+ ( result, packed, padding_used. then_some ( Box :: new ( field_remapping ) ) )
154
155
}
155
156
156
157
impl < ' a , ' tcx > CodegenCx < ' a , ' tcx > {
0 commit comments