diff --git a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs index eed512f0a6..a1143cd22b 100644 --- a/crates/rustc_codegen_spirv/src/builder/builder_methods.rs +++ b/crates/rustc_codegen_spirv/src/builder/builder_methods.rs @@ -981,14 +981,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { // ignore } - fn type_metadata(&mut self, _function: Self::Function, _typeid: String) { - // ignore - } - - fn typeid_metadata(&mut self, _typeid: String) -> Self::Value { - todo!() - } - fn store(&mut self, val: Self::Value, ptr: Self::Value, _align: Align) -> Self::Value { let ptr_elem_ty = match self.lookup_type(ptr.ty) { SpirvType::Pointer { pointee } => pointee, diff --git a/crates/rustc_codegen_spirv/src/builder/mod.rs b/crates/rustc_codegen_spirv/src/builder/mod.rs index baf1dfc6a1..7f86745066 100644 --- a/crates/rustc_codegen_spirv/src/builder/mod.rs +++ b/crates/rustc_codegen_spirv/src/builder/mod.rs @@ -18,7 +18,7 @@ use rustc_codegen_ssa::mir::operand::OperandValue; use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::{ AbiBuilderMethods, ArgAbiMethods, BackendTypes, BuilderMethods, CoverageInfoBuilderMethods, - DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, + DebugInfoBuilderMethods, HasCodegen, StaticBuilderMethods, TypeMembershipMethods, }; use rustc_errors::{DiagnosticBuilder, ErrorGuaranteed}; use rustc_middle::mir::coverage::{ @@ -439,3 +439,13 @@ impl<'tcx> FnAbiOfHelpers<'tcx> for Builder<'_, 'tcx> { self.cx.handle_fn_abi_err(err, span, fn_abi_request) } } + +impl<'tcx> TypeMembershipMethods<'tcx> for CodegenCx<'tcx> { + fn set_type_metadata(&self, _function: Self::Function, _typeid: String) { + // ignore + } + + fn typeid_metadata(&self, _typeid: String) -> Self::Value { + todo!() + } +} diff --git a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs index aa44556e95..640d3ec5db 100644 --- a/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs +++ b/crates/rustc_codegen_spirv/src/codegen_cx/constant.rs @@ -289,6 +289,22 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> { self.get_fn_addr(fn_instance.polymorphize(self.tcx)), self.data_layout().instruction_address_space, ), + GlobalAlloc::VTable(vty, trait_ref) => { + let alloc = self + .tcx + .global_alloc(self.tcx.vtable_allocation((vty, trait_ref))) + .unwrap_memory(); + let pointee = match self.lookup_type(ty) { + SpirvType::Pointer { pointee } => pointee, + other => self.tcx.sess.fatal(&format!( + "GlobalAlloc::VTable type not implemented: {}", + other.debug(ty, self) + )), + }; + let init = self.create_const_alloc(alloc, pointee); + let value = self.static_addr_of(init, alloc.inner().align, None); + (value, AddressSpace::DATA) + } GlobalAlloc::Static(def_id) => { assert!(self.tcx.is_static(def_id)); assert!(!self.tcx.is_thread_local_static(def_id));