Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}

fn zombie_bitcast_ptr(&self, def: Word) {
fn zombie_bitcast_ptr(&self, def: Word, from_ty: Word, to_ty: Word) {
let is_logical = self
.emit()
.module_ref()
Expand All @@ -328,7 +328,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
inst.operands[0].unwrap_addressing_model() == AddressingModel::Logical
});
if is_logical {
self.zombie(def, "OpBitcast on ptr without AddressingModel != Logical")
if self.is_system_crate() {
self.zombie(def, "OpBitcast on ptr without AddressingModel != Logical")
} else {
self.struct_err("Cannot cast between pointer types")
.note(&format!("from: {}", self.debug_type(from_ty)))
.note(&format!("to: {}", self.debug_type(to_ty)))
.emit()
}
}
}

Expand Down Expand Up @@ -1111,7 +1118,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
let val_is_ptr = matches!(self.lookup_type(val.ty), SpirvType::Pointer{..});
let dest_is_ptr = matches!(self.lookup_type(dest_ty), SpirvType::Pointer{..});
if val_is_ptr || dest_is_ptr {
self.zombie_bitcast_ptr(result.def);
self.zombie_bitcast_ptr(result.def, val.ty, dest_ty);
}
result
}
Expand Down Expand Up @@ -1207,7 +1214,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
.bitcast(dest_ty, None, val.def)
.unwrap()
.with_type(dest_ty);
self.zombie_bitcast_ptr(result.def);
self.zombie_bitcast_ptr(result.def, val.ty, dest_ty);
result
}
}
Expand Down
3 changes: 1 addition & 2 deletions rustc_codegen_spirv/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc_codegen_ssa::traits::{
CoverageInfoBuilderMethods, DebugInfoBuilderMethods, HasCodegen, InlineAsmOperandRef,
StaticBuilderMethods,
};
use rustc_errors::DiagnosticBuilder;
use rustc_hir::LlvmInlineAsmInner;
use rustc_middle::mir::coverage::{
CodeRegion, CounterValueReference, ExpressionOperandId, InjectedExpressionIndex, Op,
Expand Down Expand Up @@ -63,15 +64,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
}

/*
pub fn struct_err(&self, msg: &str) -> DiagnosticBuilder<'_> {
if let Some(current_span) = self.current_span {
self.tcx.sess.struct_span_err(current_span, msg)
} else {
self.tcx.sess.struct_err(msg)
}
}
*/

pub fn err(&self, msg: &str) {
if let Some(current_span) = self.current_span {
Expand Down
2 changes: 1 addition & 1 deletion rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl<'tcx> CodegenCx<'tcx> {
self.zombie_values.borrow_mut().insert(word, reason);
}

fn is_system_crate(&self) -> bool {
pub fn is_system_crate(&self) -> bool {
self.tcx
.sess
.contains_name(self.tcx.hir().krate_attrs(), sym::compiler_builtins)
Expand Down