Skip to content

Conversation

IgWod-IMG
Copy link
Contributor

It fixes the problem where the execution mode is not valid for the given entry point (LocalSizeHint requires Kernel) and where an Input storage class pointer is incorrectly passed to a function call (there is a restriction on what storage classes are allowed for pointer operands to an OpFunctionCall, see "2.16.1. Universal Validation Rules").

It fixes the problem where the execution mode is not valid for the
given entry point (`LocalSizeHint` requires `Kernel`) and where an
`Input` storage class pointer is incorrectly passed to a function
call (there is a restriction on what storage classes are allowed
for pointer operands to an `OpFunctionCall`, see "2.16.1. Universal
Validation Rules").
@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-mlir-spirv

Author: Igor Wodiany (IgWod-IMG)

Changes

It fixes the problem where the execution mode is not valid for the given entry point (LocalSizeHint requires Kernel) and where an Input storage class pointer is incorrectly passed to a function call (there is a restriction on what storage classes are allowed for pointer operands to an OpFunctionCall, see "2.16.1. Universal Validation Rules").


Full diff: https://github.com/llvm/llvm-project/pull/159323.diff

2 Files Affected:

  • (modified) mlir/test/Target/SPIRV/execution-mode.mlir (+7-2)
  • (modified) mlir/test/Target/SPIRV/function-call.mlir (+15-10)
diff --git a/mlir/test/Target/SPIRV/execution-mode.mlir b/mlir/test/Target/SPIRV/execution-mode.mlir
index e51ba7c0269a4..2178a8a77a225 100644
--- a/mlir/test/Target/SPIRV/execution-mode.mlir
+++ b/mlir/test/Target/SPIRV/execution-mode.mlir
@@ -1,10 +1,15 @@
 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
+
+spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel], []> {
   spirv.func @foo() -> () "None" {
     spirv.Return
   }
-  spirv.EntryPoint "GLCompute" @foo
+  spirv.EntryPoint "Kernel" @foo
   // CHECK: spirv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
   spirv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
 }
diff --git a/mlir/test/Target/SPIRV/function-call.mlir b/mlir/test/Target/SPIRV/function-call.mlir
index a7473a8ccd7ba..2e94ded3401ce 100644
--- a/mlir/test/Target/SPIRV/function-call.mlir
+++ b/mlir/test/Target/SPIRV/function-call.mlir
@@ -1,26 +1,31 @@
 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
-  spirv.GlobalVariable @var1 : !spirv.ptr<!spirv.array<4xf32>, Input>
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
+
+spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, VariablePointers, Linkage], [SPV_KHR_storage_buffer_storage_class, SPV_KHR_variable_pointers]> {
+  spirv.GlobalVariable @var1 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
   spirv.func @fmain() -> i32 "None" {
     %0 = spirv.Constant 16 : i32
-    %1 = spirv.mlir.addressof @var1 : !spirv.ptr<!spirv.array<4xf32>, Input>
+    %1 = spirv.mlir.addressof @var1 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
     // CHECK: {{%.*}} = spirv.FunctionCall @f_0({{%.*}}) : (i32) -> i32
     %3 = spirv.FunctionCall @f_0(%0) : (i32) -> i32
-    // CHECK: spirv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (i32, !spirv.ptr<!spirv.array<4 x f32>, Input>) -> ()
-    spirv.FunctionCall @f_1(%3, %1) : (i32, !spirv.ptr<!spirv.array<4xf32>, Input>) ->  ()
-    // CHECK: {{%.*}} =  spirv.FunctionCall @f_2({{%.*}}) : (!spirv.ptr<!spirv.array<4 x f32>, Input>) -> !spirv.ptr<!spirv.array<4 x f32>, Input>
-    %4 = spirv.FunctionCall @f_2(%1) : (!spirv.ptr<!spirv.array<4xf32>, Input>) -> !spirv.ptr<!spirv.array<4xf32>, Input>
+    // CHECK: spirv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (i32, !spirv.ptr<!spirv.array<4 x f32>, StorageBuffer>) -> ()
+    spirv.FunctionCall @f_1(%3, %1) : (i32, !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) ->  ()
+    // CHECK: {{%.*}} =  spirv.FunctionCall @f_2({{%.*}}) : (!spirv.ptr<!spirv.array<4 x f32>, StorageBuffer>) -> !spirv.ptr<!spirv.array<4 x f32>, StorageBuffer>
+    %4 = spirv.FunctionCall @f_2(%1) : (!spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) -> !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
     spirv.ReturnValue %3 : i32
   }
   spirv.func @f_0(%arg0 : i32) -> i32 "None" {
     spirv.ReturnValue %arg0 : i32
   }
-  spirv.func @f_1(%arg0 : i32, %arg1 : !spirv.ptr<!spirv.array<4xf32>, Input>) -> () "None" {
+  spirv.func @f_1(%arg0 : i32, %arg1 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) -> () "None" {
     spirv.Return
   }
-  spirv.func @f_2(%arg0 : !spirv.ptr<!spirv.array<4xf32>, Input>) -> !spirv.ptr<!spirv.array<4xf32>, Input> "None" {
-    spirv.ReturnValue %arg0 : !spirv.ptr<!spirv.array<4xf32>, Input>
+  spirv.func @f_2(%arg0 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) -> !spirv.ptr<!spirv.array<4xf32>, StorageBuffer> "None" {
+    spirv.ReturnValue %arg0 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
   }
 
   spirv.func @f_loop_with_function_call(%count : i32) -> () "None" {

@llvmbot
Copy link
Member

llvmbot commented Sep 17, 2025

@llvm/pr-subscribers-mlir

Author: Igor Wodiany (IgWod-IMG)

Changes

It fixes the problem where the execution mode is not valid for the given entry point (LocalSizeHint requires Kernel) and where an Input storage class pointer is incorrectly passed to a function call (there is a restriction on what storage classes are allowed for pointer operands to an OpFunctionCall, see "2.16.1. Universal Validation Rules").


Full diff: https://github.com/llvm/llvm-project/pull/159323.diff

2 Files Affected:

  • (modified) mlir/test/Target/SPIRV/execution-mode.mlir (+7-2)
  • (modified) mlir/test/Target/SPIRV/function-call.mlir (+15-10)
diff --git a/mlir/test/Target/SPIRV/execution-mode.mlir b/mlir/test/Target/SPIRV/execution-mode.mlir
index e51ba7c0269a4..2178a8a77a225 100644
--- a/mlir/test/Target/SPIRV/execution-mode.mlir
+++ b/mlir/test/Target/SPIRV/execution-mode.mlir
@@ -1,10 +1,15 @@
 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
+
+spirv.module Logical OpenCL requires #spirv.vce<v1.0, [Kernel], []> {
   spirv.func @foo() -> () "None" {
     spirv.Return
   }
-  spirv.EntryPoint "GLCompute" @foo
+  spirv.EntryPoint "Kernel" @foo
   // CHECK: spirv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
   spirv.ExecutionMode @foo "LocalSizeHint", 3, 4, 5
 }
diff --git a/mlir/test/Target/SPIRV/function-call.mlir b/mlir/test/Target/SPIRV/function-call.mlir
index a7473a8ccd7ba..2e94ded3401ce 100644
--- a/mlir/test/Target/SPIRV/function-call.mlir
+++ b/mlir/test/Target/SPIRV/function-call.mlir
@@ -1,26 +1,31 @@
 // RUN: mlir-translate -no-implicit-module -test-spirv-roundtrip %s | FileCheck %s
 
-spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader], []> {
-  spirv.GlobalVariable @var1 : !spirv.ptr<!spirv.array<4xf32>, Input>
+// RUN: %if spirv-tools %{ rm -rf %t %}
+// RUN: %if spirv-tools %{ mkdir %t %}
+// RUN: %if spirv-tools %{ mlir-translate --no-implicit-module --serialize-spirv --split-input-file --spirv-save-validation-files-with-prefix=%t/module %s %}
+// RUN: %if spirv-tools %{ spirv-val %t %}
+
+spirv.module Logical GLSL450 requires #spirv.vce<v1.0, [Shader, VariablePointers, Linkage], [SPV_KHR_storage_buffer_storage_class, SPV_KHR_variable_pointers]> {
+  spirv.GlobalVariable @var1 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
   spirv.func @fmain() -> i32 "None" {
     %0 = spirv.Constant 16 : i32
-    %1 = spirv.mlir.addressof @var1 : !spirv.ptr<!spirv.array<4xf32>, Input>
+    %1 = spirv.mlir.addressof @var1 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
     // CHECK: {{%.*}} = spirv.FunctionCall @f_0({{%.*}}) : (i32) -> i32
     %3 = spirv.FunctionCall @f_0(%0) : (i32) -> i32
-    // CHECK: spirv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (i32, !spirv.ptr<!spirv.array<4 x f32>, Input>) -> ()
-    spirv.FunctionCall @f_1(%3, %1) : (i32, !spirv.ptr<!spirv.array<4xf32>, Input>) ->  ()
-    // CHECK: {{%.*}} =  spirv.FunctionCall @f_2({{%.*}}) : (!spirv.ptr<!spirv.array<4 x f32>, Input>) -> !spirv.ptr<!spirv.array<4 x f32>, Input>
-    %4 = spirv.FunctionCall @f_2(%1) : (!spirv.ptr<!spirv.array<4xf32>, Input>) -> !spirv.ptr<!spirv.array<4xf32>, Input>
+    // CHECK: spirv.FunctionCall @f_1({{%.*}}, {{%.*}}) : (i32, !spirv.ptr<!spirv.array<4 x f32>, StorageBuffer>) -> ()
+    spirv.FunctionCall @f_1(%3, %1) : (i32, !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) ->  ()
+    // CHECK: {{%.*}} =  spirv.FunctionCall @f_2({{%.*}}) : (!spirv.ptr<!spirv.array<4 x f32>, StorageBuffer>) -> !spirv.ptr<!spirv.array<4 x f32>, StorageBuffer>
+    %4 = spirv.FunctionCall @f_2(%1) : (!spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) -> !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
     spirv.ReturnValue %3 : i32
   }
   spirv.func @f_0(%arg0 : i32) -> i32 "None" {
     spirv.ReturnValue %arg0 : i32
   }
-  spirv.func @f_1(%arg0 : i32, %arg1 : !spirv.ptr<!spirv.array<4xf32>, Input>) -> () "None" {
+  spirv.func @f_1(%arg0 : i32, %arg1 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) -> () "None" {
     spirv.Return
   }
-  spirv.func @f_2(%arg0 : !spirv.ptr<!spirv.array<4xf32>, Input>) -> !spirv.ptr<!spirv.array<4xf32>, Input> "None" {
-    spirv.ReturnValue %arg0 : !spirv.ptr<!spirv.array<4xf32>, Input>
+  spirv.func @f_2(%arg0 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>) -> !spirv.ptr<!spirv.array<4xf32>, StorageBuffer> "None" {
+    spirv.ReturnValue %arg0 : !spirv.ptr<!spirv.array<4xf32>, StorageBuffer>
   }
 
   spirv.func @f_loop_with_function_call(%count : i32) -> () "None" {

@IgWod-IMG
Copy link
Contributor Author

ping

@IgWod-IMG IgWod-IMG merged commit bcc1e75 into llvm:main Sep 23, 2025
13 checks passed
@IgWod-IMG IgWod-IMG deleted the img_fix-tests-2 branch September 23, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants