[Mlir-commits] [mlir] [mlir][spirv] Enable validation of global vars tests (PR #164974)
Igor Wodiany
llvmlistbot at llvm.org
Fri Oct 24 07:13:11 PDT 2025
IgWod-IMG wrote:
You're right, I confused myself there. I now realised what was the actual reason for the `spirv-val` failure:
```
error: line 12: Initializer type must match the data type
%var2 = OpVariable %_ptr_Uniform_float Uniform %var1
```
So, in the test --- I changed `Input` to `Uniform` because `Input` can never have initializer:
```mlir
spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
spirv.GlobalVariable @var1 : !spirv.ptr<f32, Uniform>
spirv.GlobalVariable @var2 initializer(@var1) bind(1, 0) : !spirv.ptr<f32, Uniform>
}
```
The problem is that we try to initialize `f32` pointer type with `f32` pointer type, but the validator complains because it expects `var1` to be `f32`, not pointer to `f32`. Now `spirv.GlobalVariable` only allows pointer type, so in the current design we cannot initialize one `spirv.GlobalVariable` with `spirv.GlobalVariable`.
So, I guess in the hindsight this patch is mostly correct, as currently we cannot support initializing global variable with global variable if they are required to be pointers. It just needs updated comments and description then. Hope that makes sense.
In the future we may want to re-work global variables if we want to support that.
https://github.com/llvm/llvm-project/pull/164974
More information about the Mlir-commits
mailing list