[Mlir-commits] [mlir] [MLIR][GPUToLLVMSPV] Fix subgroup ops mangling (PR #126111)

Artem Kroviakov llvmlistbot at llvm.org
Sat Feb 15 02:09:31 PST 2025


akroviakov wrote:

As an example, this mlir:
```mlir
module @gemm attributes {gpu.container_module} {
  gpu.module @kernel {
    gpu.func @store_constant(%ptr: !llvm.ptr<1>) kernel {
      %const_val = arith.constant 42.0 : f32
      %laneid = gpu.lane_id
      %laneid _i64 = arith.index_cast %laneid : index to i64
      %ptr_next_1 = llvm.getelementptr %ptr[%laneid] : (!llvm.ptr<1>, i64) -> !llvm.ptr<1>, i32
      llvm.store %const_val, %ptr_next_1 : f32, !llvm.ptr<1>
      gpu.return
    }
  }
```
results in this LLVM IR that later leads to  `unresolved external symbol` error:
```mlir
; ModuleID = 'LLVMDialectModule'
source_filename = "LLVMDialectModule"
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1"
target triple = "spirv64-unknown-unknown"

; Function Attrs: mustprogress nounwind willreturn
declare spir_func i32 @_Z22get_sub_group_local_id() local_unnamed_addr #0

; Function Attrs: mustprogress nounwind willreturn
define spir_kernel void @store_constant(ptr addrspace(1) writeonly captures(none) %0) local_unnamed_addr #0 !intel_reqd_sub_group_size !1 {
  %2 = tail call spir_func i32 @_Z22get_sub_group_local_id() #1
  %3 = zext i32 %2 to i64
  %4 = getelementptr i32, ptr addrspace(1) %0, i64 %3
  store float 4.200000e+01, ptr addrspace(1) %4, align 4
  ret void
}

attributes #0 = { mustprogress nounwind willreturn }
attributes #1 = { nounwind willreturn }

!llvm.module.flags = !{!0}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 16}
```

https://github.com/llvm/llvm-project/pull/126111


More information about the Mlir-commits mailing list