Skip to content

Commit f08819f

Browse files
authored
Fix some ICEs with bools (#826)
1 parent d26716b commit f08819f

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -934,13 +934,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
934934
llptr,
935935
align,
936936
);
937-
// WARN! This does not go through to_immediate due to only having a Scalar, not a Ty, but it still does
938-
// whatever to_immediate does!
939-
if scalar.is_bool() {
940-
self.trunc(load, SpirvType::Bool.def(self.span(), self))
941-
} else {
942-
load
943-
}
937+
self.to_immediate_scalar(load, *scalar)
944938
};
945939

946940
OperandValue::Pair(

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> {
263263

264264
fn codegen_static(&self, def_id: DefId, _is_mutable: bool) {
265265
let g = self.get_static(def_id);
266-
let span = self.tcx.def_span(def_id);
267266

268267
let alloc = match self.tcx.eval_static_initializer(def_id) {
269268
Ok(alloc) => alloc,
@@ -277,16 +276,7 @@ impl<'tcx> StaticMethods for CodegenCx<'tcx> {
277276
other.debug(g.ty, self)
278277
)),
279278
};
280-
let mut v = self.create_const_alloc(alloc, value_ty);
281-
282-
if self.lookup_type(v.ty) == SpirvType::Bool {
283-
let val_int = match self.builder.lookup_const(v).unwrap() {
284-
SpirvConst::Bool(val) => val as u8,
285-
_ => bug!(),
286-
};
287-
v = self.constant_u8(span, val_int);
288-
}
289-
279+
let v = self.create_const_alloc(alloc, value_ty);
290280
assert_ty_eq!(self, value_ty, v.ty);
291281
self.builder
292282
.set_global_initializer(g.def_cx(self), v.def_cx(self));

0 commit comments

Comments
 (0)