Skip to content

Commit 0546ebd

Browse files
committed
Replace SpirvValueKind::IllegalTypeUsed with mere undef.
1 parent 696080e commit 0546ebd

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3411,10 +3411,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
34113411
if buffer_store_intrinsic {
34123412
self.codegen_buffer_store_intrinsic(fn_abi, args);
34133413
let void_ty = SpirvType::Void.def(rustc_span::DUMMY_SP, self);
3414-
return SpirvValue {
3415-
kind: SpirvValueKind::IllegalTypeUsed(void_ty),
3416-
ty: void_ty,
3417-
};
3414+
return self.undef(void_ty);
34183415
}
34193416

34203417
if let Some((source_ty, target_ty)) = from_trait_impl {

crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::maybe_pqp_cg_ssa as rustc_codegen_ssa;
33

44
use super::Builder;
5-
use crate::builder_spirv::{SpirvValue, SpirvValueExt, SpirvValueKind};
5+
use crate::builder_spirv::{SpirvValue, SpirvValueExt};
66
use crate::spirv_type::SpirvType;
77
use rspirv::spirv::{Decoration, Word};
88
use rustc_abi::{Align, Size};
@@ -188,12 +188,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
188188
) -> SpirvValue {
189189
let pass_mode = &fn_abi.unwrap().ret.mode;
190190
match pass_mode {
191-
PassMode::Ignore => {
192-
return SpirvValue {
193-
kind: SpirvValueKind::IllegalTypeUsed(result_type),
194-
ty: result_type,
195-
};
196-
}
191+
PassMode::Ignore => return self.undef(result_type),
192+
197193
// PassMode::Pair is identical to PassMode::Direct - it's returned as a struct
198194
PassMode::Direct(_) | PassMode::Pair(_, _) => (),
199195
PassMode::Cast { .. } => {

crates/rustc_codegen_spirv/src/builder_spirv.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ pub enum SpirvValueKind {
4040
/// of such constants, instead of where they're generated (and cached).
4141
IllegalConst(Word),
4242

43-
/// This can only happen in one specific case - which is as a result of
44-
/// `codegen_buffer_store_intrinsic`, that function is supposed to return
45-
/// `OpTypeVoid`, however because it gets inline by the compiler it can't.
46-
/// Instead we return this, and trigger an error if we ever end up using the
47-
/// result of this function call (which we can't).
48-
IllegalTypeUsed(Word),
49-
5043
// FIXME(eddyb) this shouldn't be needed, but `rustc_codegen_ssa` still relies
5144
// on converting `Function`s to `Value`s even for direct calls, the `Builder`
5245
// should just have direct and indirect `call` variants (or a `Callee` enum).
@@ -166,16 +159,6 @@ impl SpirvValue {
166159
id
167160
}
168161

169-
SpirvValueKind::IllegalTypeUsed(id) => {
170-
cx.tcx
171-
.dcx()
172-
.struct_span_err(span, "Can't use type as a value")
173-
.with_note(format!("Type: *{}", cx.debug_type(id)))
174-
.emit();
175-
176-
id
177-
}
178-
179162
SpirvValueKind::FnAddr { .. } => {
180163
cx.builder
181164
.const_to_id

0 commit comments

Comments
 (0)