diff --git a/tests/ui/dis/entry-pass-mode-cast.rs b/tests/ui/dis/entry-pass-mode-cast.rs new file mode 100644 index 0000000000..2f6d366471 --- /dev/null +++ b/tests/ui/dis/entry-pass-mode-cast.rs @@ -0,0 +1,15 @@ +// This is a similar setup to the `issue-731` test, but instead of "just" the +// missing copy out of the global (`Input`) `OpVariable`, small enough types +// would fail much earlier, as they would use `PassMode::Cast`, through the +// default Rust ABI adjustments (that we now override through query hooks). + +// build-pass +// compile-flags: -C llvm-args=--disassemble-entry=main + +use spirv_std as _; + +#[spirv(fragment)] +pub fn main(mut in_array: [f32; 2], out_array: &mut [f32; 2]) { + in_array[0] += 1.0; + *out_array = in_array; +} diff --git a/tests/ui/dis/entry-pass-mode-cast.stderr b/tests/ui/dis/entry-pass-mode-cast.stderr new file mode 100644 index 0000000000..6a39fb8429 --- /dev/null +++ b/tests/ui/dis/entry-pass-mode-cast.stderr @@ -0,0 +1,21 @@ +%1 = OpFunction %2 None %3 +%4 = OpLabel +%5 = OpVariable %6 Function +%7 = OpVariable %6 Function +OpLine %8 12 12 +%9 = OpLoad %10 %11 +OpLine %8 12 0 +OpStore %5 %9 +OpLine %8 13 4 +%12 = OpInBoundsAccessChain %13 %5 %14 +%15 = OpInBoundsAccessChain %13 %5 %14 +%16 = OpLoad %17 %15 +%18 = OpFAdd %17 %16 %19 +OpStore %12 %18 +OpLine %8 14 17 +OpCopyMemory %7 %5 +OpLine %8 14 4 +OpCopyMemory %20 %7 +OpLine %8 15 1 +OpReturn +OpFunctionEnd diff --git a/tests/ui/dis/issue-723-indirect-input.rs b/tests/ui/dis/issue-723-indirect-input.rs deleted file mode 100644 index 6995b37e0b..0000000000 --- a/tests/ui/dis/issue-723-indirect-input.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Test that interface (global) `OpVariable`s mentioned by `OpEntryPoint` don't -// have to be used by the shader, for storage class inference to succeed. - -// NOTE(eddyb) this test will likely become useless (won't fail without the fix) -// once we start doing the copy out of the `Input` and into a `Function`-scoped -// `OpVariable` (see #731), that's why there is another `issue-723-*` test. - -// build-pass -// compile-flags: -C llvm-args=--disassemble-globals -// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> "" -// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> "" -// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple" - -use spirv_std as _; - -#[spirv(fragment)] -pub fn main(/* unused Input */ _: [f32; 3]) {} diff --git a/tests/ui/dis/issue-723-indirect-input.stderr b/tests/ui/dis/issue-723-indirect-input.stderr deleted file mode 100644 index 2b511a952b..0000000000 --- a/tests/ui/dis/issue-723-indirect-input.stderr +++ /dev/null @@ -1,23 +0,0 @@ -OpCapability Float64 -OpCapability Int16 -OpCapability Int64 -OpCapability Int8 -OpCapability ShaderClockKHR -OpCapability Shader -OpExtension "SPV_KHR_shader_clock" -OpMemoryModel Logical Simple -OpEntryPoint Fragment %1 "main" %2 -OpExecutionMode %1 OriginUpperLeft -%3 = OpString "$OPSTRING_FILENAME/issue-723-indirect-input.rs" -OpName %4 "issue_723_indirect_input::main" -OpDecorate %5 ArrayStride 4 -OpDecorate %2 Location 0 -%6 = OpTypeVoid -%7 = OpTypeFloat 32 -%8 = OpTypeInt 32 0 -%9 = OpConstant %8 3 -%5 = OpTypeArray %7 %9 -%10 = OpTypeFunction %6 %5 -%11 = OpTypeFunction %6 -%12 = OpTypePointer Input %5 -%2 = OpVariable %12 Input diff --git a/tests/ui/dis/issue-731.rs b/tests/ui/dis/issue-731.rs new file mode 100644 index 0000000000..2617c5ad85 --- /dev/null +++ b/tests/ui/dis/issue-731.rs @@ -0,0 +1,14 @@ +// Test that non-immediate (i.e. not one of scalar/scalar-pair/vector) inputs +// get properly copied out of the global (`Input`) `OpVariable` and mutation is +// only ever done on `fn`-local `OpVariable`s, not on the original global. + +// build-pass +// compile-flags: -C llvm-args=--disassemble-entry=main + +use spirv_std as _; + +#[spirv(fragment)] +pub fn main(mut in_array: [f32; 3], out_array: &mut [f32; 3]) { + in_array[0] += 1.0; + *out_array = in_array; +} diff --git a/tests/ui/dis/issue-731.stderr b/tests/ui/dis/issue-731.stderr new file mode 100644 index 0000000000..98540db57f --- /dev/null +++ b/tests/ui/dis/issue-731.stderr @@ -0,0 +1,21 @@ +%1 = OpFunction %2 None %3 +%4 = OpLabel +%5 = OpVariable %6 Function +%7 = OpVariable %6 Function +OpLine %8 11 12 +%9 = OpLoad %10 %11 +OpLine %8 11 0 +OpStore %5 %9 +OpLine %8 12 4 +%12 = OpInBoundsAccessChain %13 %5 %14 +%15 = OpInBoundsAccessChain %13 %5 %14 +%16 = OpLoad %17 %15 +%18 = OpFAdd %17 %16 %19 +OpStore %12 %18 +OpLine %8 13 17 +OpCopyMemory %7 %5 +OpLine %8 13 4 +OpCopyMemory %20 %7 +OpLine %8 14 1 +OpReturn +OpFunctionEnd