fix cranelift and gcc backends

This commit is contained in:
Ralf Jung 2022-07-05 16:53:48 -04:00
parent a422b42159
commit 052651dd13
2 changed files with 5 additions and 5 deletions

View file

@ -167,6 +167,7 @@ pub(crate) fn codegen_const_value<'tcx>(
} }
match const_val { match const_val {
ConstValue::ZST => unreachable!(), // we already handles ZST above
ConstValue::Scalar(x) => match x { ConstValue::Scalar(x) => match x {
Scalar::Int(int) => { Scalar::Int(int) => {
if fx.clif_type(layout.ty).is_some() { if fx.clif_type(layout.ty).is_some() {

View file

@ -9,7 +9,6 @@
StaticMethods, StaticMethods,
}; };
use rustc_middle::mir::Mutability; use rustc_middle::mir::Mutability;
use rustc_middle::ty::ScalarInt;
use rustc_middle::ty::layout::{TyAndLayout, LayoutOf}; use rustc_middle::ty::layout::{TyAndLayout, LayoutOf};
use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar};
use rustc_target::abi::{self, HasDataLayout, Pointer, Size}; use rustc_target::abi::{self, HasDataLayout, Pointer, Size};
@ -159,13 +158,13 @@ fn const_to_opt_u128(&self, _v: RValue<'gcc>, _sign_ext: bool) -> Option<u128> {
None 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> { 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() }; let bitsize = if layout.is_bool() { 1 } else { layout.size(self).bits() };
match cv { match cv {
Scalar::Int(ScalarInt::ZST) => {
assert_eq!(0, layout.size(self).bytes());
self.const_undef(self.type_ix(0))
}
Scalar::Int(int) => { Scalar::Int(int) => {
let data = int.assert_bits(layout.size(self)); let data = int.assert_bits(layout.size(self));