-
Notifications
You must be signed in to change notification settings - Fork 115
update to rustc 1.98 #612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
update to rustc 1.98 #612
Changes from all commits
39b3dfe
3ac3f64
b6a2cbd
6b75a23
8014471
e920442
1a5281a
ce69403
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1854,7 +1854,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { | |
| self.bitcast(loaded_val, ty) | ||
| } | ||
|
|
||
| fn volatile_load(&mut self, ty: Self::Type, ptr: Self::Value) -> Self::Value { | ||
| fn volatile_load(&mut self, ty: Self::Type, ptr: Self::Value, _align: Align) -> Self::Value { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems problematic to ignore
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be completely honest, I have no idea what this function is even supposed to do. Sure you can probably find some unsafe rust code that reaches it, but like what it's supposed to do from the shader codegen perspective. This is sadly the case with quite a bit of code in rustc_codegen_spirv, where I highly suspect it's effectively unreachable for any sane shader, there is no compiletest that reaches that code, so I really don't know what it's really supposed to do. |
||
| // TODO: Implement this | ||
| let result = self.load(ty, ptr, Align::from_bytes(0).unwrap()); | ||
| self.zombie(result.def(self), "volatile load is not supported yet"); | ||
|
|
@@ -1909,7 +1909,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { | |
| let b_offset = a | ||
| .primitive() | ||
| .size(self) | ||
| .align_to(b.primitive().align(self).abi); | ||
| .align_to(b.primitive().default_align(self).abi); | ||
|
|
||
| let mut load = |i, scalar: Scalar, align| { | ||
| let llptr = if i == 0 { | ||
|
|
@@ -1993,7 +1993,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { | |
| align: Align, | ||
| flags: MemFlags, | ||
| ) -> Self::Value { | ||
| if flags != MemFlags::empty() { | ||
| let allowed_flags = MemFlags::CAPTURES_READ_ONLY; | ||
| if !(flags & !allowed_flags).is_empty() { | ||
| self.err(format!("store_with_flags is not supported yet: {flags:?}")); | ||
| } | ||
| self.store(val, ptr, align) | ||
|
|
@@ -3484,4 +3485,8 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> { | |
| fn alloca_with_ty(&mut self, _layout: TyAndLayout<'tcx>) -> Self::Value { | ||
| bug!("scalable alloca is not supported in SPIR-V backend") | ||
| } | ||
|
|
||
| fn vscale(&mut self, _ty: Self::Type) -> Self::Value { | ||
| self.fatal("scalable vectors not supported"); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,9 +9,11 @@ use crate::custom_insts::CustomInst; | |
| use crate::spirv_type::SpirvType; | ||
| use rspirv::dr::Operand; | ||
| use rspirv::spirv::GlslStd450Op as GLOp; | ||
| use rustc_abi::Align; | ||
| use rustc_codegen_ssa::RetagInfo; | ||
| use rustc_codegen_ssa::mir::IntrinsicResult; | ||
| use rustc_codegen_ssa::mir::operand::{OperandRef, OperandValue}; | ||
| use rustc_codegen_ssa::mir::place::PlaceRef; | ||
| use rustc_codegen_ssa::mir::place::{PlaceRef, PlaceValue}; | ||
| use rustc_codegen_ssa::traits::{BuilderMethods, IntrinsicCallBuilderMethods}; | ||
| use rustc_middle::ty::layout::LayoutOf; | ||
| use rustc_middle::ty::{FnDef, Instance, Ty, TyKind, TypingEnv}; | ||
|
|
@@ -64,9 +66,14 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | |
| &mut self, | ||
| instance: Instance<'tcx>, | ||
| args: &[OperandRef<'tcx, Self::Value>], | ||
| result: PlaceRef<'tcx, Self::Value>, | ||
| result_layout: ty::layout::TyAndLayout<'tcx>, | ||
| result_place: Option<PlaceValue<Self::Value>>, | ||
| _span: Span, | ||
| ) -> Result<(), ty::Instance<'tcx>> { | ||
| ) -> IntrinsicResult<'tcx, Self::Value> { | ||
| let result = PlaceRef { | ||
| val: result_place.unwrap(), | ||
| layout: result_layout, | ||
| }; | ||
| let callee_ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized()); | ||
|
|
||
| let (def_id, fn_args) = match *callee_ty.kind() { | ||
|
|
@@ -95,17 +102,18 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | |
| sym::breakpoint => { | ||
| self.abort(); | ||
| assert!(result.layout.ty.is_unit()); | ||
| return Ok(()); | ||
| return IntrinsicResult::WroteIntoPlace; | ||
| } | ||
|
|
||
| sym::volatile_load | sym::unaligned_volatile_load => { | ||
| let ptr = args[0].immediate(); | ||
| let layout = self.layout_of(fn_args.type_at(0)); | ||
| let load = self.volatile_load(layout.spirv_type(self.span(), self), ptr); | ||
| let load = | ||
| self.volatile_load(layout.spirv_type(self.span(), self), ptr, Align::ONE); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| if !result.layout.is_zst() { | ||
| self.store(load, result.val.llval, result.val.align); | ||
| } | ||
| return Ok(()); | ||
| return IntrinsicResult::WroteIntoPlace; | ||
| } | ||
|
|
||
| sym::prefetch_read_data | ||
|
|
@@ -114,7 +122,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | |
| | sym::prefetch_write_instruction => { | ||
| // ignore | ||
| assert!(result.layout.ty.is_unit()); | ||
| return Ok(()); | ||
| return IntrinsicResult::WroteIntoPlace; | ||
| } | ||
|
|
||
| sym::saturating_add => { | ||
|
|
@@ -352,7 +360,10 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | |
|
|
||
| _ => { | ||
| // Call the fallback body instead of generating the intrinsic code | ||
| return Err(ty::Instance::new_raw(instance.def_id(), instance.args)); | ||
| return IntrinsicResult::Fallback(Instance::new_raw( | ||
| instance.def_id(), | ||
| instance.args, | ||
| )); | ||
| } | ||
| }; | ||
|
|
||
|
|
@@ -368,7 +379,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | |
| .val | ||
| .store(self, result); | ||
| } | ||
| Ok(()) | ||
| IntrinsicResult::WroteIntoPlace | ||
| } | ||
|
|
||
| fn codegen_llvm_intrinsic_call( | ||
|
|
@@ -402,16 +413,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> { | |
| todo!() | ||
| } | ||
|
|
||
| fn va_start(&mut self, val: Self::Value) -> Self::Value { | ||
| // SPIR-V backend has no variadic ABI support; keep the placeholder | ||
| // operand unchanged so MIR lowering can proceed without crashing. | ||
| val | ||
| } | ||
|
|
||
| fn va_end(&mut self, val: Self::Value) -> Self::Value { | ||
| // See `va_start` above. | ||
| val | ||
| } | ||
| fn va_start(&mut self, _val: Self::Value) {} | ||
|
|
||
| fn retag_mem(&mut self, _place: Self::Value, _info: &RetagInfo<Self::Value>) { | ||
| bug!("retag not supported") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the main changes, but this is a kind of silly way to do patches. It can silently fail when things change around: replace does not assert the OG source contains the lines we want to replace, and fails silently if it does not. It might be worth it to add a helper like this:
Would make the failure mode louder, and easier to debug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've thought about replacing it with a directory of
*.patchfiles before. In fact I tripped up on a replace failing due to upstream changes and it not causing a compilation error but simply a behavior change. Luckily, I added that regex just a month ago so I knew what failed.