/// Encodes the SPIR-V module's symbolic name into the name of the entry point
/// function.
static LogicalResult encodeKernelName(spirv::ModuleOp module) {
- StringRef spvModuleName = *module.getSymName();
+ StringRef spvModuleName = module.getSymName().value_or(kSPIRVModule);
// We already know that the module contains exactly one entry point function
// based on `getKernelGlobalVariables()` call. Update this function's name
// to:
-// RUN: mlir-opt --lower-host-to-llvm %s | FileCheck %s
+// RUN: mlir-opt --lower-host-to-llvm %s -split-input-file | FileCheck %s
module attributes {gpu.container_module, spirv.target_env = #spirv.target_env<#spirv.vce<v1.0, [Shader], [SPV_KHR_variable_pointers]>, #spirv.resource_limits<max_compute_workgroup_invocations = 128, max_compute_workgroup_size = [128, 128, 64]>>} {
return
}
}
+
+// -----
+
+// Check using a specified sym_name attribute.
+module {
+ spirv.module Logical GLSL450 attributes { sym_name = "spirv.sym" } {
+ // CHECK: spirv.func @spirv.sym_bar
+ // CHECK: spirv.EntryPoint "GLCompute" @spirv.sym_bar
+ // CHECK: spirv.ExecutionMode @spirv.sym_bar "LocalSize", 1, 1, 1
+ spirv.func @bar() "None" {
+ spirv.Return
+ }
+ spirv.EntryPoint "GLCompute" @bar
+ spirv.ExecutionMode @bar "LocalSize", 1, 1, 1
+ }
+}
+
+// -----
+
+// Check using the default sym_name attribute.
+module {
+ spirv.module Logical GLSL450 {
+ // CHECK: spirv.func @__spv___bar
+ // CHECK: spirv.EntryPoint "GLCompute" @__spv___bar
+ // CHECK: spirv.ExecutionMode @__spv___bar "LocalSize", 1, 1, 1
+ spirv.func @bar() "None" {
+ spirv.Return
+ }
+ spirv.EntryPoint "GLCompute" @bar
+ spirv.ExecutionMode @bar "LocalSize", 1, 1, 1
+ }
+}