diff --git a/src/intrinsics/simd.rs b/src/intrinsics/simd.rs index 99149d7d89bf..e42309663d05 100644 --- a/src/intrinsics/simd.rs +++ b/src/intrinsics/simd.rs @@ -127,7 +127,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.mir.span, "`simd_insert` is not yet implemented. Calling this function will panic.", ); - crate::trap::trap_unimplemented(fx, "`simd_insert` is not yet implemented"); + let val = crate::trap::trap_unimplemented_ret_value(fx, ret.layout(), "`simd_insert` is not yet implemented"); + ret.write_cvalue(fx, val); }; simd_extract, (c v, o idx) { @@ -138,7 +139,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( fx.mir.span, "`#[rustc_arg_required_const(..)]` is not yet supported. Calling this function will panic.", ); - crate::trap::trap_unimplemented(fx, "`#[rustc_arg_required_const(..)]` is not yet supported."); + let val = crate::trap::trap_unimplemented_ret_value(fx, ret.layout(), "`#[rustc_arg_required_const(..)]` is not yet supported."); + ret.write_cvalue(fx, val); return; }; diff --git a/src/trap.rs b/src/trap.rs index 5d3064906834..a223e6397da6 100644 --- a/src/trap.rs +++ b/src/trap.rs @@ -75,6 +75,18 @@ pub fn trap_unreachable( fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); } +/// Like `trap_unreachable` but returns a fake value of the specified type. +/// +/// Trap code: user65535 +pub fn trap_unreachable_ret_value<'tcx>( + fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, + dest_layout: TyLayout<'tcx>, + msg: impl AsRef, +) -> CValue<'tcx> { + trap_unreachable(fx, msg); + CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout) +} + /// Use this when something is unimplemented, but `libcore` or `libstd` requires it to codegen. /// Unlike `trap_unreachable` this will not fill the current block, so you **must** add instructions /// to it afterwards. @@ -89,10 +101,10 @@ pub fn trap_unimplemented( fx.bcx.ins().trapnz(true_, TrapCode::User(!0)); } -/// Like `trap_unreachable` but returns a fake value of the specified type. +/// Like `trap_unimplemented` but returns a fake value of the specified type. /// /// Trap code: user65535 -pub fn trap_unreachable_ret_value<'tcx>( +pub fn trap_unimplemented_ret_value<'tcx>( fx: &mut FunctionCx<'_, 'tcx, impl cranelift_module::Backend>, dest_layout: TyLayout<'tcx>, msg: impl AsRef,