Skip to content

[SPIRV] SPIR-V module layout doesn't respect the spec. #66261

Closed
@Keenuts

Description

@Keenuts

The layout of a SPIR-V module is very strict (https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.html#_logical_layout_of_a_module).

Example:

  • An OpVariable instruction cannot be present outside of the first block of a function.

As-is, the backend doesn't respect those rules, but lower IR instructions to SPIR-V in place.
This means the following LLVM IR won't build to a valid SPIR-V module:

define void @main() #1 {
entry:
  %0 = alloca <2 x i32>, align 4
  %1 = getelementptr <2 x i32>, ptr %0, i32 0, i32 0
  %2 = alloca float, align 4
  ret void
}

attributes #1 = { "hlsl.numthreads"="4,8,16" "hlsl.shader"="compute" }

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions