summaryrefslogtreecommitdiff
path: root/compiler/rustc_codegen_cranelift
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-03-23 18:43:04 +0000
committerbors <bors@rust-lang.org>2023-03-23 18:43:04 +0000
commite2163008763c326ec4003e07b8e6eef0c98f6204 (patch)
tree13526f6f563f37d8998736ea3ab7769358cfea93 /compiler/rustc_codegen_cranelift
parentdf7fd9995f10627f25ccb325f693a11b3395a73c (diff)
parent64cce5fc7d2c1070adeaa719932b4bbccf27dd46 (diff)
downloadrust-e2163008763c326ec4003e07b8e6eef0c98f6204.tar.gz
Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~ Includes lowering `transmute` calls to it, so it's used. Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r--compiler/rustc_codegen_cranelift/src/base.rs4
-rw-r--r--compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs10
2 files changed, 4 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs
index 1b8e9312e2f..2107ae147e9 100644
--- a/compiler/rustc_codegen_cranelift/src/base.rs
+++ b/compiler/rustc_codegen_cranelift/src/base.rs
@@ -709,6 +709,10 @@ fn codegen_stmt<'tcx>(
let operand = codegen_operand(fx, operand);
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) => {
let place = codegen_place(fx, place);
let value = place.to_cvalue(fx);
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
index fe48cac4faf..03f2a65fcca 100644
--- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
@@ -557,16 +557,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
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 => {
intrinsic_args!(fx, args => (dst, val, count); intrinsic);
let val = val.load_scalar(fx);