[Migrated] Malformed SPIR-V when compiling a simple loop
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1076
Old labels: t: bug
Originally creatd by Patryk27 on 2023-06-16T15:19:59Z
Hi,
Compiling this code:
#[spirv(compute(threads(8, 8)))]
pub fn main(#[spirv(descriptor_set = 0, binding = 0)] out: TexRgba32f) {
let mut value = vec3(0.1, 0.2, 0.3);
let mut i = 0;
loop {
if i >= 32 {
break;
}
i += 1;
}
unsafe {
out.write(uvec2(0, 0), value.extend(1.0));
}
}
... will work, but adding a seemingly no-op value = value into that loop:
loop {
value = value;
if i >= 32 {
break;
}
i += 1;
}
... will panic the compiler, saying:
error: malformed SPIR-V (in OpCompositeExtract: undefined ID %4547)
Meta:
rustc 1.71.0-nightly (1a5f8bce7 2023-05-26)
SPIRV-Tools v2023.2 unknown hash, 1980-01-01T00:00:00
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the Rust reproducer with and without the no-op value = value inside the loop, then inspect the generated SPIR-V and the OpCompositeExtract diagnostic. Done means both versions compile without a malformed-SPIR-V error and produce valid output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100