Skip to content
Draft
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
9 changes: 6 additions & 3 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use std::{env, fs, mem};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2026-07-03"
channel = "nightly-2026-07-16"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = c397dae808f70caebab1fc4e11b3edf7e59f58c7"#;
# commit_hash = d0babd8b6b05ef9bb65d42f928cef4129d64cf65"#;

fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
Expand Down Expand Up @@ -153,7 +153,10 @@ fn generate_pqp_cg_ssa() -> Result<(), Box<dyn Error>> {
for line in mem::take(&mut src).lines() {
if line.starts_with("#!") {
src += "// ";
if !line.starts_with("#![doc(") && line != "#![warn(unreachable_pub)]" {
if !line.starts_with("#![doc(")
&& line != "#![warn(unreachable_pub)]"
&& !line.starts_with("#![cfg_attr(bootstrap,")
{
writeln(&mut cg_ssa_lib_rc_attrs, line);
}
} else if line == "#[macro_use]" || line.starts_with("extern crate ") {
Expand Down
6 changes: 3 additions & 3 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub(crate) fn provide(providers: &mut Providers) {
fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>,
) -> &'tcx FnAbi<'tcx, Ty<'tcx>> {
let readjust_arg_abi = |arg: &ArgAbi<'tcx, Ty<'tcx>>| {
let mut arg = ArgAbi::new(&tcx, arg.layout, |_, _| ArgAttributes::new());
let mut arg = ArgAbi::new(arg.layout, |_, _| ArgAttributes::new());
// FIXME: this is bad! https://github.com/rust-lang/rust/issues/115666
// <https://github.com/rust-lang/rust/commit/eaaa03faf77b157907894a4207d8378ecaec7b45>
arg.make_direct_deprecated();
Expand Down Expand Up @@ -364,7 +364,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
}
.def_with_name(cx, span, TyLayoutNameKey::from(*self)),
BackendRepr::Scalar(scalar) => trans_scalar(cx, span, *self, scalar, Size::ZERO),
BackendRepr::ScalarPair(a, b) => {
BackendRepr::ScalarPair { a, b, .. } => {
// NOTE(eddyb) unlike `BackendRepr::Scalar`'s simpler newtype-unpacking
// behavior, `BackendRepr::ScalarPair` can be composed in two ways:
// * two `BackendRepr::Scalar` fields (and any number of ZST fields),
Expand Down Expand Up @@ -465,7 +465,7 @@ pub fn scalar_pair_element_backend_type<'tcx>(
index: usize,
) -> Word {
let [a, b] = match ty.layout.backend_repr() {
BackendRepr::ScalarPair(a, b) => [a, b],
BackendRepr::ScalarPair { a, b, .. } => [a, b],
other => span_bug!(
span,
"scalar_pair_element_backend_type invalid abi: {:?}",
Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::symbols::Symbols;
use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass};
use rustc_ast::{LitKind, MetaItemInner, MetaItemLit};
use rustc_hir as hir;
use rustc_hir::def_id::LocalModDefId;
use rustc_hir::def_id::LocalModId;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{Attribute, CRATE_HIR_ID, HirId, MethodKind, Target};
use rustc_middle::hir::nested_filter;
Expand Down Expand Up @@ -503,7 +503,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
}

// FIXME(eddyb) DRY this somehow and make it reusable from somewhere in `rustc`.
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalModId) {
let check_spirv_attr_visitor = &mut CheckSpirvAttrVisitor {
tcx,
sym: Symbols::get(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
place.val.align,
);
OperandValue::Immediate(llval)
} else if let BackendRepr::ScalarPair(a, b) = place.layout.backend_repr {
} else if let BackendRepr::ScalarPair { a, b, .. } = place.layout.backend_repr {
let b_offset = a
.primitive()
.size(self)
Expand Down
7 changes: 2 additions & 5 deletions crates/rustc_codegen_spirv/src/builder/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
let callee_ty = instance.ty(self.tcx, TypingEnv::fully_monomorphized());

let (def_id, fn_args) = match *callee_ty.kind() {
FnDef(def_id, fn_args) => (def_id, fn_args),
FnDef(def_id, fn_args) => (def_id, fn_args.skip_binder()),
_ => bug!("expected fn item type, found {}", callee_ty),
};

Expand Down Expand Up @@ -360,10 +360,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {

_ => {
// Call the fallback body instead of generating the intrinsic code
return IntrinsicResult::Fallback(Instance::new_raw(
instance.def_id(),
instance.args,
));
return IntrinsicResult::Fallback(Instance::new_raw(def_id, instance.args));
}
};

Expand Down
7 changes: 3 additions & 4 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ use crate::spirv_type::SpirvType;
use itertools::Itertools as _;
use rspirv::spirv::Word;
use rustc_abi::{self as abi, AddressSpace, Float, HasDataLayout, Integer, Primitive, Size};
use rustc_codegen_ssa::traits::{
ConstCodegenMethods, MiscCodegenMethods, PacMetadata, StaticCodegenMethods,
};
use rustc_codegen_ssa::traits::{ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods};
use rustc_middle::mir::interpret::{AllocError, ConstAllocation, GlobalAlloc, Scalar, alloc_range};
use rustc_middle::ty::layout::LayoutOf;
use rustc_session::PointerAuthSchema;
use rustc_span::{DUMMY_SP, Span};

impl<'tcx> CodegenCx<'tcx> {
Expand Down Expand Up @@ -233,7 +232,7 @@ impl ConstCodegenMethods for CodegenCx<'_> {
cv: Scalar,
layout: rustc_abi::Scalar,
ty: Self::Type,
_pac: Option<PacMetadata>,
_pac: Option<&PointerAuthSchema>,
) -> Self::Value {
self.scalar_to_backend(cv, layout, ty)
}
Expand Down
10 changes: 7 additions & 3 deletions crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ use rustc_abi::{AddressSpace, HasDataLayout, TargetDataLayout};
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::traits::{
AsmCodegenMethods, BackendTypes, DebugInfoCodegenMethods, GlobalAsmOperandRef,
MiscCodegenMethods, PacMetadata,
MiscCodegenMethods,
};
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_hir::def_id::DefId;
use rustc_middle::mono::CodegenUnit;
use rustc_middle::ty::layout::{HasTyCtxt, HasTypingEnv};
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypingEnv};
use rustc_session::Session;
use rustc_session::{PointerAuthSchema, Session};
use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, Span};
use rustc_target::spec::{HasTargetSpec, Target, TargetTuple};
Expand Down Expand Up @@ -887,7 +887,11 @@ impl<'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'tcx> {
// NOTE(eddyb) see the comment on `SpirvValueKind::FnAddr`, this should
// be fixed upstream, so we never see any "function pointer" values being
// created just to perform direct calls.
fn get_fn_addr(&self, instance: Instance<'tcx>, _pac: Option<PacMetadata>) -> Self::Value {
fn get_fn_addr(
&self,
instance: Instance<'tcx>,
_pac: Option<&PointerAuthSchema>,
) -> Self::Value {
let function = self.get_fn(instance);
let span = self.tcx.def_span(instance.def_id());

Expand Down
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/src/codegen_cx/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ impl<'tcx> LayoutTypeCodegenMethods<'tcx> for CodegenCx<'tcx> {
BackendRepr::Scalar(_)
| BackendRepr::SimdScalableVector { .. }
| BackendRepr::SimdVector { .. } => true,
BackendRepr::ScalarPair(..) => false,
BackendRepr::ScalarPair { .. } => false,
BackendRepr::Memory { .. } => layout.is_zst(),
}
}

fn is_backend_scalar_pair(&self, layout: TyAndLayout<'tcx>) -> bool {
match layout.backend_repr {
BackendRepr::ScalarPair(..) => true,
BackendRepr::ScalarPair { .. } => true,
BackendRepr::Scalar(_)
| BackendRepr::SimdScalableVector { .. }
| BackendRepr::SimdVector { .. }
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![feature(deref_patterns)]
#![feature(file_buffered)]
#![feature(negative_impls)]
#![feature(string_from_utf8_lossy_owned)]
#![feature(option_into_flat_iter)]
#![feature(trait_alias)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
channel = "nightly-2026-07-03"
channel = "nightly-2026-07-16"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = c397dae808f70caebab1fc4e11b3edf7e59f58c7
# commit_hash = d0babd8b6b05ef9bb65d42f928cef4129d64cf65

# Whenever changing the nightly channel, update the commit hash above, and
# change `REQUIRED_RUST_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` too.
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
%1 = OpFunction %2 None %3
%4 = OpFunctionParameter %5
%6 = OpLabel
%8 = OpCompositeExtract %9 %4 0
%11 = OpGroupNonUniformAllEqual %2 %12 %8
%13 = OpLogicalAnd %2 %14 %11
%15 = OpCompositeExtract %16 %4 1
%17 = OpGroupNonUniformAllEqual %2 %12 %15
%18 = OpLogicalAnd %2 %13 %17
%19 = OpCompositeExtract %20 %4 2
%21 = OpGroupNonUniformAllEqual %2 %12 %19
%22 = OpLogicalAnd %2 %18 %21
OpNoLine
OpReturnValue %22
OpFunctionEnd
error: `u8` type used without `OpCapability Int8`
|
= note: used by unnamed constant
= note: used from within `spirv_std::arch::subgroup::subgroup_all_equal::<subgroup_composite_all_equals::MyStruct>`
note: called by `subgroup_composite_all_equals::disassembly`
--> <$DIR/subgroup_composite_all_equals.rs>:27:5
|
LL | subgroup_all_equal(my_struct)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: called by `subgroup_composite_all_equals::main`
--> <$DIR/subgroup_composite_all_equals.rs>:44:20
|
LL | let bool = disassembly(my_struct);
| ^^^^^^^^^^^^^^^^^^^^^^
note: called by GLCompute entry-point `main`
--> <$DIR/subgroup_composite_all_equals.rs>:31:8
|
LL | pub fn main(
| ^^^^

error: aborting due to 1 previous error

8 changes: 4 additions & 4 deletions tests/compiletests/ui/dis/ptr_copy.normal.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: cannot memcpy dynamically sized data
--> <$CORE_SRC/ptr/mod.rs>:642:9
--> <$CORE_SRC/ptr/mod.rs>:640:9
|
LL | crate::intrinsics::copy(src, dst, count)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: used from within `core::ptr::copy::<f32>`
--> <$CORE_SRC/ptr/mod.rs>:627:21
--> <$CORE_SRC/ptr/mod.rs>:625:21
|
LL | pub const unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
| ^^^^
Expand All @@ -28,7 +28,7 @@ LL | pub fn main(i: f32, o: &mut f32) {
error: cannot cast between pointer types
from `*f32`
to `*struct () { }`
--> <$CORE_SRC/ptr/mod.rs>:630:9
--> <$CORE_SRC/ptr/mod.rs>:628:9
|
LL | / ub_checks::assert_unsafe_precondition!(
LL | | check_language_ub,
Expand All @@ -39,7 +39,7 @@ LL | | );
| |_________^
|
note: used from within `core::ptr::copy::<f32>`
--> <$CORE_SRC/ptr/mod.rs>:630:9
--> <$CORE_SRC/ptr/mod.rs>:628:9
|
LL | / ub_checks::assert_unsafe_precondition!(
LL | | check_language_ub,
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/dis/ptr_read.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%4 = OpFunctionParameter %5
%6 = OpFunctionParameter %5
%7 = OpLabel
OpLine %8 1733 8
OpLine %8 1731 8
%9 = OpLoad %10 %4
OpLine %11 7 13
OpStore %6 %9
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/dis/ptr_read_method.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%4 = OpFunctionParameter %5
%6 = OpFunctionParameter %5
%7 = OpLabel
OpLine %8 1733 8
OpLine %8 1731 8
%9 = OpLoad %10 %4
OpLine %11 7 13
OpStore %6 %9
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/dis/ptr_write.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%7 = OpLabel
OpLine %8 7 35
%9 = OpLoad %10 %4
OpLine %11 1941 40
OpLine %11 1939 40
OpStore %6 %9
OpNoLine
OpReturn
Expand Down
2 changes: 1 addition & 1 deletion tests/compiletests/ui/dis/ptr_write_method.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%7 = OpLabel
OpLine %8 7 37
%9 = OpLoad %10 %4
OpLine %11 1941 40
OpLine %11 1939 40
OpStore %6 %9
OpNoLine
OpReturn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,19 @@ LL | fn h_newtyped(xyz: ((&u32, &u32, &u32),)) -> (u32, u32, u32) {
= note: inlining was required due to illegal parameter type
= note: called from `member_ref_arg_tuples::main`

warning: 4 warnings emitted
error: `u64` type used without `OpCapability Int64`
|
= note: used by unnamed constant
note: used from within `member_ref_arg_tuples::main`
--> <$DIR/member_ref_arg_tuples.rs>:44:13
|
LL | let s = S { x: 2, y: 2 };
| ^^^^^^^^^^^^^^^^
note: called by Fragment entry-point `main`
--> <$DIR/member_ref_arg_tuples.rs>:43:8
|
LL | pub fn main() {
| ^^^^

error: aborting due to 1 previous error; 4 warnings emitted

2 changes: 0 additions & 2 deletions tests/difftests/runner/src/differ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ impl<T: NumericType> Default for NumericDiffer<T> {
}

impl<T: NumericType> OutputDiffer for NumericDiffer<T> {
#[expect(clippy::chunks_exact_to_as_chunks)]
fn compare(&self, output1: &[u8], output2: &[u8], epsilon: Option<f32>) -> Vec<Difference> {
if output1.len() != output2.len() {
return vec![Difference {
Expand Down Expand Up @@ -451,7 +450,6 @@ impl<T: NumericType> DifferenceDisplay for NumericDiffer<T> {
self.format_table(diffs, pkg1, pkg2)
}

#[expect(clippy::chunks_exact_to_as_chunks)]
fn write_human_readable(&self, output: &[u8], path: &std::path::Path) -> std::io::Result<()> {
use std::io::Write;
let mut file = std::fs::File::create(path)?;
Expand Down
Loading