diff --git a/src/abi/pass_mode.rs b/src/abi/pass_mode.rs index 390637e8e44..02604a37572 100644 --- a/src/abi/pass_mode.rs +++ b/src/abi/pass_mode.rs @@ -100,7 +100,13 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) } // FIXME implement Vector Abi in a cg_llvm compatible way - Abi::Vector { .. } => PassMode::ByRef { size: Some(layout.size) }, + Abi::Vector { .. } => { + if let Some(vector_ty) = crate::intrinsics::clif_vector_type(tcx, layout) { + PassMode::ByVal(vector_ty) + } else { + PassMode::ByRef { size: Some(layout.size) } + } + } Abi::Aggregate { sized: true } => PassMode::ByRef { size: Some(layout.size) }, Abi::Aggregate { sized: false } => PassMode::ByRef { size: None }, diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index ae2fe30989a..ea7326edc04 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -175,7 +175,7 @@ fn lane_type_and_count<'tcx>( (lane_layout, lane_count) } -fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option { +pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Option { let (element, count) = match &layout.abi { Abi::Vector { element, count } => (element.clone(), *count), _ => unreachable!(),