Add CastKind::Transmute
to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
This commit is contained in:
parent
edb0717e7c
commit
9558e12965
2 changed files with 4 additions and 10 deletions
|
@ -709,6 +709,10 @@ fn codegen_stmt<'tcx>(
|
||||||
let operand = codegen_operand(fx, operand);
|
let operand = codegen_operand(fx, operand);
|
||||||
operand.coerce_dyn_star(fx, lval);
|
operand.coerce_dyn_star(fx, lval);
|
||||||
}
|
}
|
||||||
|
Rvalue::Cast(CastKind::Transmute, ref operand, _to_ty) => {
|
||||||
|
let operand = codegen_operand(fx, operand);
|
||||||
|
lval.write_cvalue_transmute(fx, operand);
|
||||||
|
}
|
||||||
Rvalue::Discriminant(place) => {
|
Rvalue::Discriminant(place) => {
|
||||||
let place = codegen_place(fx, place);
|
let place = codegen_place(fx, place);
|
||||||
let value = place.to_cvalue(fx);
|
let value = place.to_cvalue(fx);
|
||||||
|
|
|
@ -557,16 +557,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
||||||
fx.bcx.ins().band(ptr, mask);
|
fx.bcx.ins().band(ptr, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
sym::transmute => {
|
|
||||||
intrinsic_args!(fx, args => (from); intrinsic);
|
|
||||||
|
|
||||||
if ret.layout().abi.is_uninhabited() {
|
|
||||||
crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", source_info);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret.write_cvalue_transmute(fx, from);
|
|
||||||
}
|
|
||||||
sym::write_bytes | sym::volatile_set_memory => {
|
sym::write_bytes | sym::volatile_set_memory => {
|
||||||
intrinsic_args!(fx, args => (dst, val, count); intrinsic);
|
intrinsic_args!(fx, args => (dst, val, count); intrinsic);
|
||||||
let val = val.load_scalar(fx);
|
let val = val.load_scalar(fx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue