From 67028cee5177aa5e5f9300114c9a8449258adb3a Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 28 Mar 2020 15:33:50 +0100 Subject: [PATCH] Use PassMode::ByVal for Abi::Vector --- src/abi/pass_mode.rs | 8 +++++++- src/intrinsics/mod.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) 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!(),