summaryrefslogtreecommitdiff
path: root/compiler/rustc_codegen_cranelift
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-02-27 06:11:52 +0100
committerGitHub <noreply@github.com>2023-02-27 06:11:52 +0100
commit3fcc79f04a27850c243e33dd32c42b19ba64ee11 (patch)
tree336e7599b3d9475cfb0b26fc7517d23e853f5707 /compiler/rustc_codegen_cranelift
parent3a6c5429c29074961080cd9f368a2e46fdb371ff (diff)
parent025d2a147ff3dcde8f00ad5bc43b446837bd0240 (diff)
downloadrust-3fcc79f04a27850c243e33dd32c42b19ba64ee11.tar.gz
Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errors
Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r--compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
index 6feb3a7732e..f00e9321070 100644
--- a/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
+++ b/compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
@@ -21,7 +21,8 @@ mod simd;
pub(crate) use cpuid::codegen_cpuid_call;
pub(crate) use llvm::codegen_llvm_intrinsic_call;
-use rustc_middle::ty::layout::HasParamEnv;
+use rustc_middle::ty;
+use rustc_middle::ty::layout::{HasParamEnv, InitKind};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_middle::ty::subst::SubstsRef;
use rustc_span::symbol::{kw, sym, Symbol};
@@ -642,7 +643,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
if intrinsic == sym::assert_zero_valid
&& !fx
.tcx
- .permits_zero_init(fx.param_env().and(ty))
+ .check_validity_of_init((InitKind::Zero, fx.param_env().and(ty)))
.expect("expected to have layout during codegen")
{
with_no_trimmed_paths!({
@@ -661,7 +662,10 @@ fn codegen_regular_intrinsic_call<'tcx>(
if intrinsic == sym::assert_mem_uninitialized_valid
&& !fx
.tcx
- .permits_uninit_init(fx.param_env().and(ty))
+ .check_validity_of_init((
+ InitKind::UninitMitigated0x01Fill,
+ fx.param_env().and(ty),
+ ))
.expect("expected to have layout during codegen")
{
with_no_trimmed_paths!({