Skip to content

Commit 2f9b5d0

Browse files
committed
Replace SpirvValueKind::IllegalTypeUsed with mere undef.
1 parent 2a2fc59 commit 2f9b5d0

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
@@ -4110,10 +4110,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
41104110
self.codegen_buffer_store_intrinsic(args, mode);
41114111

41124112
let void_ty = SpirvType::Void.def(rustc_span::DUMMY_SP, self);
4113-
return SpirvValue {
4114-
kind: SpirvValueKind::IllegalTypeUsed(void_ty),
4115-
ty: void_ty,
4116-
};
4113+
return self.undef(void_ty);
41174114
}
41184115

41194116
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};
@@ -186,12 +186,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
186186
pass_mode: &PassMode,
187187
) -> SpirvValue {
188188
match pass_mode {
189-
PassMode::Ignore => {
190-
return SpirvValue {
191-
kind: SpirvValueKind::IllegalTypeUsed(result_type),
192-
ty: result_type,
193-
};
194-
}
189+
PassMode::Ignore => return self.undef(result_type),
190+
195191
// PassMode::Pair is identical to PassMode::Direct - it's returned as a struct
196192
PassMode::Direct(_) | PassMode::Pair(_, _) => (),
197193
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)