Fix some ICEs with bools (#826)

This commit is contained in:
Ashley Hauck 2021-12-15 15:10:38 +01:00 committed by GitHub
parent d26716b881
commit f08819fede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 18 deletions

View File

@ -934,13 +934,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
llptr,
align,
);
// WARN! This does not go through to_immediate due to only having a Scalar, not a Ty, but it still does
// whatever to_immediate does!
if scalar.is_bool() {
self.trunc(load, SpirvType::Bool.def(self.span(), self))
} else {
load
}
self.to_immediate_scalar(load, *scalar)
};
OperandValue::Pair(

View File

@ -263,7 +263,6 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> {
fn codegen_static(&self, def_id: DefId, _is_mutable: bool) {
let g = self.get_static(def_id);
let span = self.tcx.def_span(def_id);
let alloc = match self.tcx.eval_static_initializer(def_id) {
Ok(alloc) => alloc,
@ -277,16 +276,7 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> {
other.debug(g.ty, self)
)),
};
let mut v = self.create_const_alloc(alloc, value_ty);
if self.lookup_type(v.ty) == SpirvType::Bool {
let val_int = match self.builder.lookup_const(v).unwrap() {
SpirvConst::Bool(val) => val as u8,
_ => bug!(),
};
v = self.constant_u8(span, val_int);
}
let v = self.create_const_alloc(alloc, value_ty);
assert_ty_eq!(self, value_ty, v.ty);
self.builder
.set_global_initializer(g.def_cx(self), v.def_cx(self));