diff options
| author | bors <bors@rust-lang.org> | 2022-07-09 17:16:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-07-09 17:16:00 +0000 |
| commit | f893495e3da91dc319d37861b803eed9d6c8c7c7 (patch) | |
| tree | c6d89a3df967969c4505c35c705545ae64be3807 /compiler/rustc_codegen_gcc | |
| parent | 6c20ab744b0f82646d90ce9d25894823abc9c669 (diff) | |
| parent | 4e7aaf1f448dd9808a94e98dffe4c1176c388e0d (diff) | |
| download | rust-f893495e3da91dc319d37861b803eed9d6c8c7c7.tar.gz rust-f893495e3da91dc319d37861b803eed9d6c8c7c7.zip | |
Auto merge of #98957 - RalfJung:zst-are-different, r=lcnr,oli-obk
don't allow ZST in ScalarInt There are several indications that we should not ZST as a ScalarInt: - We had two ways to have ZST valtrees, either an empty `Branch` or a `Leaf` with a ZST in it. `ValTree::zst()` used the former, but the latter could possibly arise as well. - Likewise, the interpreter had `Immediate::Uninit` and `Immediate::Scalar(Scalar::ZST)`. - LLVM codegen already had to special-case ZST ScalarInt. So I propose we stop using ScalarInt to represent ZST (which are clearly not integers). Instead, we can add new ZST variants to those types that did not have other variants which could be used for this purpose. Based on https://github.com/rust-lang/rust/pull/98831. Only the commits starting from "don't allow ZST in ScalarInt" are new. r? `@oli-obk`
Diffstat (limited to 'compiler/rustc_codegen_gcc')
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/common.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs index d156f874434..fc391f53f18 100644 --- a/compiler/rustc_codegen_gcc/src/common.rs +++ b/compiler/rustc_codegen_gcc/src/common.rs @@ -9,7 +9,6 @@ use rustc_codegen_ssa::traits::{ StaticMethods, }; use rustc_middle::mir::Mutability; -use rustc_middle::ty::ScalarInt; use rustc_middle::ty::layout::{TyAndLayout, LayoutOf}; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; use rustc_target::abi::{self, HasDataLayout, Pointer, Size}; @@ -159,13 +158,13 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> { None } + fn zst_to_backend(&self, _ty: Type<'gcc>) -> RValue<'gcc> { + self.const_undef(self.type_ix(0)) + } + fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) -> RValue<'gcc> { let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() }; match cv { - Scalar::Int(ScalarInt::ZST) => { - assert_eq!(0, layout.size(self).bytes()); - self.const_undef(self.type_ix(0)) - } Scalar::Int(int) => { let data = int.assert_bits(layout.size(self)); |
