diff --git a/crates/rustc_codegen_spirv/src/abi.rs b/crates/rustc_codegen_spirv/src/abi.rs index f1453a8c5f8..4d322ce7c9f 100644 --- a/crates/rustc_codegen_spirv/src/abi.rs +++ b/crates/rustc_codegen_spirv/src/abi.rs @@ -3,7 +3,7 @@ use crate::attr::{AggregatedSpirvAttributes, IntrinsicType}; use crate::codegen_cx::CodegenCx; -use crate::spirv_type::SpirvType; +use crate::spirv_type::{SpirvType, name_type_id}; use itertools::Itertools; use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word}; use rustc_abi::ExternAbi as Abi; @@ -321,6 +321,33 @@ impl<'tcx> ConvSpirvType<'tcx> for FnAbi<'tcx, Ty<'tcx>> { } } +/// If `layout` has exactly one non-ZST field positioned at offset 0 with size and +/// alignment matching the outer layout, returns that field. +/// +/// This captures the structural shape of a "newtype wrapper" — a single meaningful +/// field padded out to the outer type, which can be substituted for the outer type +/// in a SPIR-V type graph as long as the caller has *independently* verified that +/// the ABIs match (either via `BackendRepr::eq_up_to_validity`, or via +/// `#[repr(transparent)]`, which guarantees full ABI identity by construction). +fn sole_structural_newtype_field<'tcx>( + cx: &CodegenCx<'tcx>, + layout: TyAndLayout<'tcx>, +) -> Option> { + let mut non_zst = (0..layout.fields.count()).filter(|&i| !layout.field(cx, i).is_zst()); + let i = non_zst.next()?; + if non_zst.next().is_some() { + return None; + } + let field = layout.field(cx, i); + // Only unpack a newtype if the field and the newtype line up + // perfectly, in every way that could potentially affect ABI. + (layout.fields.offset(i) == Size::ZERO + && field.size == layout.size + && field.align.abi == layout.align.abi + && field.backend_repr.eq_up_to_validity(&layout.backend_repr)) + .then_some(field) +} + impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> { fn spirv_type(&self, mut span: Span, cx: &CodegenCx<'tcx>) -> Word { if let TyKind::Adt(adt, args) = *self.ty.kind() { @@ -379,23 +406,8 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> { // a new one, offering the `(a, b)` shape `rustc_codegen_ssa` // expects, while letting noop pointercasts access the sole // `BackendRepr::ScalarPair` field - this is the approach taken here - let mut non_zst_fields = (0..self.fields.count()) - .map(|i| (i, self.field(cx, i))) - .filter(|(_, field)| !field.is_zst()); - let sole_non_zst_field = match (non_zst_fields.next(), non_zst_fields.next()) { - (Some(field), None) => Some(field), - _ => None, - }; - if let Some((i, field)) = sole_non_zst_field { - // Only unpack a newtype if the field and the newtype line up - // perfectly, in every way that could potentially affect ABI. - if self.fields.offset(i) == Size::ZERO - && field.size == self.size - && field.align.abi == self.align.abi - && field.backend_repr.eq_up_to_validity(&self.backend_repr) - { - return field.spirv_type(span, cx); - } + if let Some(field) = sole_structural_newtype_field(cx, *self) { + return field.spirv_type(span, cx); } // Note: We can't use auto_struct_layout here because the spirv types here might be undefined due to @@ -447,7 +459,24 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> { .tcx .dcx() .fatal("scalable vectors are not supported in SPIR-V backend"), - BackendRepr::Memory { sized: _ } => trans_aggregate(cx, span, *self), + BackendRepr::Memory { sized: _ } => { + // For `#[repr(transparent)]` newtypes, reuse the single non-ZST + // field's SPIR-V type directly instead of wrapping it in an + // `OpTypeStruct`, if the type is `#[repr(transparent)]`. + // Otherwise, we're manipulating the abi too much and the + // format args decompiler fails. + if let TyKind::Adt(adt, _) = self.ty.kind() + && adt.repr().transparent() + && let Some(field) = sole_structural_newtype_field(cx, *self) + { + let inner_id = field.spirv_type(span, cx); + // Preserve the wrapper's name as an `OpName` alias on the + // inner SPIR-V type so disassembly still shows it. + name_type_id(cx, inner_id, TyLayoutNameKey::from(*self)); + return inner_id; + } + trans_aggregate(cx, span, *self) + } } } } diff --git a/crates/rustc_codegen_spirv/src/spirv_type.rs b/crates/rustc_codegen_spirv/src/spirv_type.rs index f10e09e28ec..85d8f0be61f 100644 --- a/crates/rustc_codegen_spirv/src/spirv_type.rs +++ b/crates/rustc_codegen_spirv/src/spirv_type.rs @@ -92,6 +92,17 @@ pub enum SpirvType<'tcx> { RayQueryKhr, } +/// Emit an `OpName` for a type `id`, deduplicated per `(id, name_key)` pair. +/// Unlike [`SpirvType::def_with_name`], this operates on an existing `id` - useful +/// for types reused across multiple Rust types (e.g. `#[repr(transparent)]` +/// newtype collapse, where the wrapper's name is attached to the inner's id). +pub fn name_type_id<'tcx>(cx: &CodegenCx<'tcx>, id: Word, name_key: TyLayoutNameKey<'tcx>) { + let mut type_names = cx.type_cache.type_names.borrow_mut(); + if type_names.entry(id).or_default().insert(name_key) { + cx.emit_global().name(id, name_key.to_string()); + } +} + impl SpirvType<'_> { /// Note: `Builder::type_*` should be called *nowhere else* but here, to ensure /// `CodegenCx::type_defs` stays up-to-date @@ -266,13 +277,7 @@ impl SpirvType<'_> { name_key: TyLayoutNameKey<'tcx>, ) -> Word { let id = self.def(def_span, cx); - - // Only emit `OpName` if this is the first time we see this name. - let mut type_names = cx.type_cache.type_names.borrow_mut(); - if type_names.entry(id).or_default().insert(name_key) { - cx.emit_global().name(id, name_key.to_string()); - } - + name_type_id(cx, id, name_key); id } diff --git a/tests/compiletests/README.md b/tests/compiletests/README.md index 374bb0130ba..0f6c6ff65c9 100644 --- a/tests/compiletests/README.md +++ b/tests/compiletests/README.md @@ -79,7 +79,7 @@ contents of `path/to/test.rs.stderr`. * `// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""` remove the vulkan memory model *capability*, only used by `vulkan` targets * `// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""` remove the vulkan memory model *extension*, only used by `vulkan` targets * `// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"` replace the `Vulkan` memory model with `Simple`, which `spv` targets use - * `// normalize-stderr-test "; .*\n" -> ""` remove comments on spirv version by rspirv + * `// normalize-stderr-test "^(; .*\n)*" -> ""` remove comments on spirv version by rspirv * remove rustc error src paths: * `// normalize-stderr-test "\S*/lib/rustlib/" -> "$$SYSROOT/lib/rustlib/"` normalize path to crates delivered with rustc, such as `core` * `// normalize-stderr-test "\S*/crates/spirv-std/src/" -> "$$SPIRV_STD_SRC/"` normalize path to the `spirv-std` crate diff --git a/tests/compiletests/ui/dis/spec_constant_array.rs b/tests/compiletests/ui/dis/spec_constant_array.rs index 8c700030512..a0ae8b28a68 100644 --- a/tests/compiletests/ui/dis/spec_constant_array.rs +++ b/tests/compiletests/ui/dis/spec_constant_array.rs @@ -9,7 +9,7 @@ // ignore-vulkan1.1 // compile-flags: -C llvm-args=--disassemble -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" diff --git a/tests/compiletests/ui/dis/spec_constant_array.stderr b/tests/compiletests/ui/dis/spec_constant_array.stderr index 9533cdb38ab..5c066dc2c9d 100644 --- a/tests/compiletests/ui/dis/spec_constant_array.stderr +++ b/tests/compiletests/ui/dis/spec_constant_array.stderr @@ -3,6 +3,7 @@ OpMemoryModel Logical Simple OpEntryPoint GLCompute %1 "main" %2 OpExecutionMode %1 LocalSize 1 1 1 %3 = OpString "$DIR/spec_constant_array.rs" +OpName %2 "out" OpDecorate %4 Block OpMemberDecorate %4 0 Offset 0 OpDecorate %2 Binding 0 diff --git a/tests/compiletests/ui/entry/asm/entry1_global_asm.rs b/tests/compiletests/ui/entry/asm/entry1_global_asm.rs index 43149bf28d0..8030f57910f 100644 --- a/tests/compiletests/ui/entry/asm/entry1_global_asm.rs +++ b/tests/compiletests/ui/entry/asm/entry1_global_asm.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry1_reference.rs b/tests/compiletests/ui/entry/asm/entry1_reference.rs index b8d3a483e29..6ad5dc3942c 100644 --- a/tests/compiletests/ui/entry/asm/entry1_reference.rs +++ b/tests/compiletests/ui/entry/asm/entry1_reference.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry2_global_asm.rs b/tests/compiletests/ui/entry/asm/entry2_global_asm.rs index 92cca43c4c5..50cb0957fe4 100644 --- a/tests/compiletests/ui/entry/asm/entry2_global_asm.rs +++ b/tests/compiletests/ui/entry/asm/entry2_global_asm.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry2_reference.rs b/tests/compiletests/ui/entry/asm/entry2_reference.rs index 39e6b0cfe04..4b73baffba8 100644 --- a/tests/compiletests/ui/entry/asm/entry2_reference.rs +++ b/tests/compiletests/ui/entry/asm/entry2_reference.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry3_generic_asm.rs b/tests/compiletests/ui/entry/asm/entry3_generic_asm.rs index 2c5711cb455..f13a3266a54 100644 --- a/tests/compiletests/ui/entry/asm/entry3_generic_asm.rs +++ b/tests/compiletests/ui/entry/asm/entry3_generic_asm.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry3_global_asm.rs b/tests/compiletests/ui/entry/asm/entry3_global_asm.rs index 3b5d66d5fba..365556be2f4 100644 --- a/tests/compiletests/ui/entry/asm/entry3_global_asm.rs +++ b/tests/compiletests/ui/entry/asm/entry3_global_asm.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry3_reference.rs b/tests/compiletests/ui/entry/asm/entry3_reference.rs index 6263dcd28db..bc1a590d5b4 100644 --- a/tests/compiletests/ui/entry/asm/entry3_reference.rs +++ b/tests/compiletests/ui/entry/asm/entry3_reference.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry_fragment_global_asm.rs b/tests/compiletests/ui/entry/asm/entry_fragment_global_asm.rs index 981d271e251..0093e6854c4 100644 --- a/tests/compiletests/ui/entry/asm/entry_fragment_global_asm.rs +++ b/tests/compiletests/ui/entry/asm/entry_fragment_global_asm.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/entry/asm/entry_fragment_reference.rs b/tests/compiletests/ui/entry/asm/entry_fragment_reference.rs index e4bb8593fa2..c8f80bcae40 100644 --- a/tests/compiletests/ui/entry/asm/entry_fragment_reference.rs +++ b/tests/compiletests/ui/entry/asm/entry_fragment_reference.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/glam/offsets_vec3_vec3a.rs b/tests/compiletests/ui/glam/offsets_vec3_vec3a.rs index 6d1e56cf843..26ec8bb0b29 100644 --- a/tests/compiletests/ui/glam/offsets_vec3_vec3a.rs +++ b/tests/compiletests/ui/glam/offsets_vec3_vec3a.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-vulkan1.0 diff --git a/tests/compiletests/ui/image/write_comp.rs b/tests/compiletests/ui/image/write_comp.rs index 067734de806..a2eefd7e495 100644 --- a/tests/compiletests/ui/image/write_comp.rs +++ b/tests/compiletests/ui/image/write_comp.rs @@ -4,7 +4,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-vulkan1.0 diff --git a/tests/compiletests/ui/image/write_comp_format.rs b/tests/compiletests/ui/image/write_comp_format.rs index a3bbf6d9da5..f8bb8df8b6f 100644 --- a/tests/compiletests/ui/image/write_comp_format.rs +++ b/tests/compiletests/ui/image/write_comp_format.rs @@ -4,7 +4,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-vulkan1.0 diff --git a/tests/compiletests/ui/lang/abi/transparent.rs b/tests/compiletests/ui/lang/abi/transparent.rs new file mode 100644 index 00000000000..7f1a5e13a87 --- /dev/null +++ b/tests/compiletests/ui/lang/abi/transparent.rs @@ -0,0 +1,91 @@ +// build-pass +// compile-flags: -C llvm-args=--disassemble +// normalize-stderr-test "OpSource .*\n" -> "" +// normalize-stderr-test "OpLine .*\n" -> "" +// normalize-stderr-test "%\d+ = OpString .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" +// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" +// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" +// ignore-spv1.0 +// ignore-spv1.1 +// ignore-spv1.2 +// ignore-spv1.3 +// ignore-vulkan1.0 +// ignore-vulkan1.1 + +use core::marker::PhantomData; +use spirv_std::glam::*; +use spirv_std::spirv; + +#[repr(C)] +#[derive(Default)] +struct SomeStruct { + a: u32, + b: f32, + c: Vec3, +} + +#[derive(Default)] +pub struct A(u32); +#[repr(transparent)] +#[derive(Default)] +pub struct ATrans(u32); + +#[derive(Default)] +pub struct B(Vec3); +#[repr(transparent)] +#[derive(Default)] +pub struct BTrans(Vec3); + +#[derive(Default)] +pub struct C(SomeStruct); +#[repr(transparent)] +#[derive(Default)] +pub struct CTrans(SomeStruct); + +#[derive(Default)] +pub struct D<'a>(u32, PhantomData<&'a ()>); +#[repr(transparent)] +#[derive(Default)] +pub struct DTrans<'a>(u32, PhantomData<&'a ()>); + +#[derive(Default)] +pub struct E(ATrans); +#[repr(transparent)] +#[derive(Default)] +pub struct ETrans(ATrans); + +#[derive(Default)] +pub struct Zst; +#[repr(transparent)] +#[derive(Default)] +pub struct ZstTrans; + +#[spirv(vertex)] +pub fn main( + a: &mut A, + a_trans: &mut ATrans, + b: &mut B, + b_trans: &mut BTrans, + c: &mut C, + c_trans: &mut CTrans, + d: &mut D<'static>, + d_trans: &mut DTrans<'static>, + e: &mut E, + e_trans: &mut ETrans, + zst: &mut Zst, + zst_trans: &mut ZstTrans, +) { + *a = Default::default(); + *a_trans = Default::default(); + *b = Default::default(); + *b_trans = Default::default(); + *c = Default::default(); + *c_trans = Default::default(); + *d = Default::default(); + *d_trans = Default::default(); + *e = Default::default(); + *e_trans = Default::default(); + *zst = Default::default(); + *zst_trans = Default::default(); +} diff --git a/tests/compiletests/ui/lang/abi/transparent.stderr b/tests/compiletests/ui/lang/abi/transparent.stderr new file mode 100644 index 00000000000..c1f0d72973f --- /dev/null +++ b/tests/compiletests/ui/lang/abi/transparent.stderr @@ -0,0 +1,100 @@ +OpCapability Shader +OpMemoryModel Logical Simple +OpEntryPoint Vertex %1 "main" %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 +OpName %13 "BTrans" +OpName %14 "B" +OpMemberName %14 0 "0" +OpName %15 "SomeStruct" +OpMemberName %15 0 "a" +OpMemberName %15 1 "b" +OpMemberName %15 2 "c" +OpName %16 "C" +OpMemberName %16 0 "0" +OpName %2 "a" +OpName %3 "a_trans" +OpName %4 "b" +OpName %5 "b_trans" +OpName %17 "SomeStruct" +OpMemberName %17 0 "a" +OpMemberName %17 1 "b" +OpMemberName %17 2 "c" +OpName %6 "c" +OpName %7 "c_trans" +OpName %8 "d" +OpName %9 "d_trans" +OpName %10 "e" +OpName %11 "e_trans" +OpName %18 " as core::default::Default>::default" +OpDecorate %2 Location 0 +OpDecorate %3 Location 1 +OpDecorate %4 Location 2 +OpDecorate %5 Location 3 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 4 +OpMemberDecorate %17 2 Offset 8 +OpDecorate %6 Location 4 +OpDecorate %7 Location 7 +OpDecorate %8 Location 10 +OpDecorate %9 Location 11 +OpDecorate %10 Location 12 +OpDecorate %11 Location 13 +%19 = OpTypeInt 32 0 +%20 = OpTypePointer Output %19 +%21 = OpTypeFloat 32 +%13 = OpTypeVector %21 3 +%14 = OpTypeStruct %13 +%22 = OpTypePointer Output %14 +%23 = OpTypePointer Output %13 +%15 = OpTypeStruct %19 %21 %13 +%16 = OpTypeStruct %15 +%24 = OpTypePointer Output %16 +%25 = OpTypePointer Output %15 +%26 = OpTypeVoid +%27 = OpTypeFunction %26 +%2 = OpVariable %20 Output +%28 = OpConstant %19 0 +%3 = OpVariable %20 Output +%4 = OpVariable %22 Output +%29 = OpConstant %21 0 +%30 = OpConstantComposite %13 %29 %29 %29 +%5 = OpVariable %23 Output +%17 = OpTypeStruct %19 %21 %13 +%6 = OpVariable %24 Output +%7 = OpVariable %25 Output +%8 = OpVariable %20 Output +%9 = OpVariable %20 Output +%10 = OpVariable %20 Output +%11 = OpVariable %20 Output +%1 = OpFunction %26 None %27 +%31 = OpLabel +OpStore %2 %28 +OpStore %3 %28 +%32 = OpInBoundsAccessChain %23 %4 %28 +OpStore %32 %30 +OpStore %5 %30 +%33 = OpCompositeConstruct %17 %28 %29 %30 +%34 = OpInBoundsAccessChain %25 %6 %28 +%35 = OpCompositeExtract %19 %33 0 +%36 = OpCompositeExtract %21 %33 1 +%37 = OpCompositeExtract %13 %33 2 +%38 = OpCompositeConstruct %15 %35 %36 %37 +OpStore %34 %38 +%39 = OpCompositeConstruct %17 %28 %29 %30 +%40 = OpCompositeExtract %19 %39 0 +%41 = OpCompositeExtract %21 %39 1 +%42 = OpCompositeExtract %13 %39 2 +%43 = OpCompositeConstruct %15 %40 %41 %42 +OpStore %7 %43 +%44 = OpFunctionCall %26 %18 +OpStore %8 %28 +%45 = OpFunctionCall %26 %18 +OpStore %9 %28 +OpStore %10 %28 +OpStore %11 %28 +OpNoLine +OpReturn +OpFunctionEnd +%18 = OpFunction %26 None %27 +%46 = OpLabel +OpReturn +OpFunctionEnd diff --git a/tests/compiletests/ui/lang/asm/fn_ptr_call_float.rs b/tests/compiletests/ui/lang/asm/fn_ptr_call_float.rs index 968b1655eb8..7b8be39cac6 100644 --- a/tests/compiletests/ui/lang/asm/fn_ptr_call_float.rs +++ b/tests/compiletests/ui/lang/asm/fn_ptr_call_float.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/lang/asm/fn_ptr_call_vec.rs b/tests/compiletests/ui/lang/asm/fn_ptr_call_vec.rs index b94d3d5cc20..3627d08cc71 100644 --- a/tests/compiletests/ui/lang/asm/fn_ptr_call_vec.rs +++ b/tests/compiletests/ui/lang/asm/fn_ptr_call_vec.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/lang/asm/fn_ptr_call_void.rs b/tests/compiletests/ui/lang/asm/fn_ptr_call_void.rs index 833819a13b6..ff8cdc37686 100644 --- a/tests/compiletests/ui/lang/asm/fn_ptr_call_void.rs +++ b/tests/compiletests/ui/lang/asm/fn_ptr_call_void.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.rs b/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.rs index c643a45e4ba..8ed15fd8ff3 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.stderr b/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.stderr index c73ab9c004d..1b43c99c9f2 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.stderr +++ b/tests/compiletests/ui/spirv-attr/location_assignment/array_f32.stderr @@ -3,7 +3,8 @@ OpMemoryModel Logical Simple OpEntryPoint Vertex %1 "main" %2 %3 OpName %2 "out1" OpName %3 "out2" -OpName %6 "<[f32OpDecorate %7 ArrayStride 4 +OpName %6 "<[f32; 3] as core::default::Default>::default" +OpDecorate %7 ArrayStride 4 OpDecorate %2 Location 0 OpDecorate %3 Location 3 %8 = OpTypeFloat 32 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/explicit_overlap.rs b/tests/compiletests/ui/spirv-attr/location_assignment/explicit_overlap.rs index 2181f3c5ad0..dc77780b943 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/explicit_overlap.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/explicit_overlap.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // normalize-stderr-test "= note: module `.*`" -> "= note: module ``" diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/explict.rs b/tests/compiletests/ui/spirv-attr/location_assignment/explict.rs index 4f25e131eeb..14bbd1e8ab1 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/explict.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/explict.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/geometry_shader.rs b/tests/compiletests/ui/spirv-attr/location_assignment/geometry_shader.rs index cda93b86269..0bb0a73af79 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/geometry_shader.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/geometry_shader.rs @@ -4,7 +4,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/many_f32_struct.rs b/tests/compiletests/ui/spirv-attr/location_assignment/many_f32_struct.rs index ffc4ea4facc..430fdd50009 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/many_f32_struct.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/many_f32_struct.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.rs b/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.rs index 3c464be35f9..5f30f48d273 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.rs @@ -4,7 +4,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.stderr b/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.stderr index c6073a1bcbf..6e8216235ec 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.stderr +++ b/tests/compiletests/ui/spirv-attr/location_assignment/mesh_shader.stderr @@ -7,17 +7,18 @@ OpExecutionMode %1 LocalSize 1 1 1 OpExecutionMode %1 OutputVertices 9 OpExecutionMode %1 OutputPrimitivesNV 3 OpExecutionMode %1 OutputTrianglesNV -OpName %16 "core::ops::Range" -OpMemberName %16 0 "start" -OpMemberName %16 1 "end" +OpName %16 "ops::try_trait::NeverShortCircuit<[char; 3]>" +OpName %17 "core::ops::Range" +OpMemberName %17 0 "start" +OpMemberName %17 1 "end" OpName %2 "positions" OpName %3 "out_per_vertex" OpName %4 "out_per_vertex2" OpName %5 "indices" OpName %6 "out_per_primitive" OpName %7 "out_per_primitive2" -OpMemberDecorate %16 0 Offset 0 -OpMemberDecorate %16 1 Offset 4 +OpMemberDecorate %17 0 Offset 0 +OpMemberDecorate %17 1 Offset 4 OpDecorate %2 BuiltIn Position OpDecorate %3 Location 0 OpDecorate %4 Location 1 @@ -26,48 +27,48 @@ OpDecorate %6 Location 2 OpDecorate %6 PerPrimitiveNV OpDecorate %7 Location 3 OpDecorate %7 PerPrimitiveNV -%17 = OpTypeFloat 32 -%18 = OpTypeVector %17 4 -%19 = OpTypeInt 32 0 -%20 = OpConstant %19 9 -%21 = OpTypeArray %18 %20 -%22 = OpTypePointer Output %21 -%23 = OpTypeVector %19 3 -%24 = OpConstant %19 3 -%25 = OpTypeArray %23 %24 -%26 = OpTypePointer Output %25 -%27 = OpTypeArray %19 %20 -%28 = OpTypePointer Output %27 -%29 = OpTypeArray %17 %20 -%30 = OpTypePointer Output %29 -%31 = OpTypeArray %19 %24 -%32 = OpTypePointer Output %31 -%33 = OpTypeArray %17 %24 +%18 = OpTypeFloat 32 +%19 = OpTypeVector %18 4 +%20 = OpTypeInt 32 0 +%21 = OpConstant %20 9 +%22 = OpTypeArray %19 %21 +%23 = OpTypePointer Output %22 +%24 = OpTypeVector %20 3 +%25 = OpConstant %20 3 +%26 = OpTypeArray %24 %25 +%27 = OpTypePointer Output %26 +%28 = OpTypeArray %20 %21 +%29 = OpTypePointer Output %28 +%30 = OpTypeArray %18 %21 +%31 = OpTypePointer Output %30 +%16 = OpTypeArray %20 %25 +%32 = OpTypePointer Output %16 +%33 = OpTypeArray %18 %25 %34 = OpTypePointer Output %33 %35 = OpTypeVoid %36 = OpTypeFunction %35 -%16 = OpTypeStruct %19 %19 -%37 = OpConstant %19 0 -%38 = OpUndef %16 +%17 = OpTypeStruct %20 %20 +%37 = OpConstant %20 0 +%38 = OpUndef %17 %39 = OpTypeBool %40 = OpConstantFalse %39 -%41 = OpConstant %19 1 +%41 = OpConstant %20 1 %42 = OpTypeInt 32 1 %43 = OpConstant %42 0 -%44 = OpConstant %17 3204448256 -%45 = OpConstant %17 1056964608 -%46 = OpConstant %17 0 -%47 = OpConstant %17 1065353216 -%48 = OpTypePointer Output %18 -%2 = OpVariable %22 Output -%49 = OpConstant %19 2 -%50 = OpTypePointer Output %19 -%3 = OpVariable %28 Output -%51 = OpTypePointer Output %17 -%4 = OpVariable %30 Output -%52 = OpTypePointer Output %23 -%5 = OpVariable %26 Output +%44 = OpConstant %18 3204448256 +%45 = OpConstant %18 1056964608 +%46 = OpConstant %18 0 +%47 = OpConstant %18 1065353216 +%48 = OpTypePointer Output %19 +%2 = OpVariable %23 Output +%49 = OpConstant %20 2 +%50 = OpTypePointer Output %20 +%3 = OpVariable %29 Output +%51 = OpTypePointer Output %18 +%4 = OpVariable %31 Output +%52 = OpTypePointer Output %24 +%5 = OpVariable %27 Output %6 = OpVariable %32 Output -%53 = OpConstant %19 42 +%53 = OpConstant %20 42 %7 = OpVariable %34 Output -%54 = OpConstant %17 1116340224 +%54 = OpConstant %18 1116340224 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/struct.rs b/tests/compiletests/ui/spirv-attr/location_assignment/struct.rs index d11bb8f8103..30e5ef3a5c5 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/struct.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/struct.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0 diff --git a/tests/compiletests/ui/spirv-attr/location_assignment/vec3_f32.rs b/tests/compiletests/ui/spirv-attr/location_assignment/vec3_f32.rs index 0a7d754e26f..e8474ee7ead 100644 --- a/tests/compiletests/ui/spirv-attr/location_assignment/vec3_f32.rs +++ b/tests/compiletests/ui/spirv-attr/location_assignment/vec3_f32.rs @@ -3,7 +3,7 @@ // normalize-stderr-test "OpSource .*\n" -> "" // normalize-stderr-test "OpLine .*\n" -> "" // normalize-stderr-test "%\d+ = OpString .*\n" -> "" -// normalize-stderr-test "; .*\n" -> "" +// normalize-stderr-test "^(; .*\n)*" -> "" // normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" // normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" // ignore-spv1.0