TEST: Use SmallVec<[u32; 4]> for field projection.
This commit is contained in:
parent
c627c0d88b
commit
c1d0f0a65c
@ -24,6 +24,7 @@ use rustc_span::source_map::{Span, DUMMY_SP};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::{HasDataLayout, LayoutOf, PointeeInfo, Size, TargetDataLayout, VariantIdx};
|
||||
use rustc_target::spec::{HasTargetSpec, RelocModel, Target, TlsModel};
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::ffi::CStr;
|
||||
@ -102,7 +103,7 @@ pub struct TypeLowering<'ll> {
|
||||
|
||||
/// If padding is used the slice maps fields from source order
|
||||
/// to llvm order.
|
||||
pub field_remapping: Option<Box<[u32]>>,
|
||||
pub field_remapping: Option<Box<SmallVec<[u32; 4]>>>,
|
||||
}
|
||||
|
||||
fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
|
||||
|
@ -10,6 +10,7 @@ use rustc_middle::ty::{self, Ty, TypeFoldable};
|
||||
use rustc_target::abi::{Abi, AddressSpace, Align, FieldsShape};
|
||||
use rustc_target::abi::{Int, Pointer, F32, F64};
|
||||
use rustc_target::abi::{LayoutOf, PointeeInfo, Scalar, Size, TyAndLayoutMethods, Variants};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use tracing::debug;
|
||||
|
||||
use std::fmt::Write;
|
||||
@ -18,7 +19,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
defer: &mut Option<(&'a Type, TyAndLayout<'tcx>)>,
|
||||
field_remapping: &mut Option<Box<[u32]>>,
|
||||
field_remapping: &mut Option<Box<SmallVec<[u32; 4]>>>,
|
||||
) -> &'a Type {
|
||||
match layout.abi {
|
||||
Abi::Scalar(_) => bug!("handled elsewhere"),
|
||||
@ -93,7 +94,7 @@ fn uncached_llvm_type<'a, 'tcx>(
|
||||
fn struct_llfields<'a, 'tcx>(
|
||||
cx: &CodegenCx<'a, 'tcx>,
|
||||
layout: TyAndLayout<'tcx>,
|
||||
) -> (Vec<&'a Type>, bool, Option<Box<[u32]>>) {
|
||||
) -> (Vec<&'a Type>, bool, Option<Box<SmallVec<[u32; 4]>>>) {
|
||||
debug!("struct_llfields: {:#?}", layout);
|
||||
let field_count = layout.fields.count();
|
||||
|
||||
@ -101,7 +102,7 @@ fn struct_llfields<'a, 'tcx>(
|
||||
let mut offset = Size::ZERO;
|
||||
let mut prev_effective_align = layout.align.abi;
|
||||
let mut result: Vec<_> = Vec::with_capacity(1 + field_count * 2);
|
||||
let mut field_remapping = vec![0; field_count];
|
||||
let mut field_remapping = smallvec![0; field_count];
|
||||
for i in layout.fields.index_by_increasing_offset() {
|
||||
let target_offset = layout.fields.offset(i as usize);
|
||||
let field = layout.field(cx, i);
|
||||
@ -150,7 +151,7 @@ fn struct_llfields<'a, 'tcx>(
|
||||
debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size);
|
||||
}
|
||||
|
||||
(result, packed, padding_used.then_some(field_remapping.into_boxed_slice()))
|
||||
(result, packed, padding_used.then_some(Box::new(field_remapping)))
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> CodegenCx<'a, 'tcx> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user