[MLIR][XeVM] Lowering `cf.assert` leaves an undefined `@assert_msg` in the device module
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Lowering a kernel that contains `cf.assert` through `-gpu-lower-to-xevm-pipeline` leaves an `llvm.mlir.addressof @assert_msg` inside the lowered device module, but the corresponding `llvm.mlir.global` is not present there. The LLVM verifier rejects the module.
### Input Program
**input.mlir**
```mlir
module attributes {gpu.container_module} {
gpu.module @kernels {
gpu.func @assert_kernel(%limit : i32) kernel {
%tid = gpu.thread_id x
%tid_i32 = arith.index_cast %tid : index to i32
%ok = arith.cmpi ult, %tid_i32, %limit : i32
cf.assert %ok, "thread id is in range"
gpu.return
}
}
}
```
### Used Command
```bash
mlir-opt input.mlir '-gpu-lower-to-xevm-pipeline=xegpu-op-level=lane zebin-triple=spirv64-unknown-unknown zebin-chip=bmg opt-level=2 binary-format=fatbin' -o /dev/null
```
### Result
```bash
error: 'llvm.mlir.addressof' op must reference a global defined by 'llvm.mlir.global', 'llvm.mlir.alias' or 'llvm.func' or 'llvm.mlir.ifunc'
note: see current operation: %5 = "llvm.mlir.addressof"() <{global_name = @assert_msg}> : () -> !llvm.ptr
```
Version: b07fc8a44aa6ac03ec8e0c79b04134bda87b5279
Contributor guide
Research direction
Start with the input.mlir example and run the provided mlir-opt -gpu-lower-to-xevm-pipeline command. Trace how cf.assert is lowered into the device module and verify that the resulting llvm.mlir.addressof @assert_msg has a corresponding global or other valid definition; done means the LLVM verifier accepts the lowered module.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100