Make simd_extract panic at runtime on non-const index again
This is necessary to compile packed_simd
This commit is contained in:
parent
d2eeed4ff5
commit
e99f78af08
@ -146,10 +146,17 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) {
|
let idx_const = if let Some(idx_const) = crate::constant::mir_operand_get_const_val(fx, idx) {
|
||||||
idx_const
|
idx_const
|
||||||
} else {
|
} else {
|
||||||
fx.tcx.sess.span_fatal(
|
fx.tcx.sess.span_warn(
|
||||||
span,
|
span,
|
||||||
"Index argument for `simd_extract` is not a constant",
|
"Index argument for `simd_extract` is not a constant",
|
||||||
);
|
);
|
||||||
|
let res = crate::trap::trap_unimplemented_ret_value(
|
||||||
|
fx,
|
||||||
|
ret.layout(),
|
||||||
|
"Index argument for `simd_extract` is not a constant",
|
||||||
|
);
|
||||||
|
ret.write_cvalue(fx, res);
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
|
let idx = idx_const.val.try_to_bits(Size::from_bytes(4 /* u32*/)).unwrap_or_else(|| panic!("kind not scalar: {:?}", idx_const));
|
||||||
|
12
src/trap.rs
12
src/trap.rs
@ -67,3 +67,15 @@ pub(crate) fn trap_unimplemented(fx: &mut FunctionCx<'_, '_, impl Module>, msg:
|
|||||||
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
let true_ = fx.bcx.ins().iconst(types::I32, 1);
|
||||||
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
fx.bcx.ins().trapnz(true_, TrapCode::User(!0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like `trap_unimplemented` but returns a fake value of the specified type.
|
||||||
|
///
|
||||||
|
/// Trap code: user65535
|
||||||
|
pub(crate) fn trap_unimplemented_ret_value<'tcx>(
|
||||||
|
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
|
||||||
|
dest_layout: TyAndLayout<'tcx>,
|
||||||
|
msg: impl AsRef<str>,
|
||||||
|
) -> CValue<'tcx> {
|
||||||
|
trap_unimplemented(fx, msg);
|
||||||
|
CValue::by_ref(Pointer::const_addr(fx, 0), dest_layout)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user