Write dummy return value on unimplemented simd_{insert,extract}
Fixes #919
This commit is contained in:
parent
9fd8b84a4b
commit
10ee80c288
2 changed files with 18 additions and 4 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
|||
16
src/trap.rs
16
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<str>,
|
||||
) -> 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<str>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue