[MLIR][LLVM] LLVM IR import drops unknown function entry count metadata
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
## Summary
`mlir-translate -import-llvm` emits an `unhandled function metadata` warning for valid function-level `!prof` metadata of the form `!{!"unknown", !"pass-name"}`. The imported `llvm.func` has no representation of the attachment. An LLVM IR to LLVM dialect to LLVM IR round trip removes the explicit unknown entry count and its origin pass name.
## Version
commit 36c3b79de6442f9b6a9756822d57d0fe7af6f23e
## Reproducer
Save the following as `input.ll`:
```llvm
define void @unknown_entry_count() !prof !0 {
ret void
}
!0 = !{!"unknown", !"sample-pass"}
```
## Command
```sh
llvm-as -disable-output input.ll
mlir-translate -import-llvm input.ll | mlir-translate -mlir-to-llvmir
```
## Actual behavior
`llvm-as` accepts the input. The round-trip command emits:
```text
warning: unhandled function metadata: !0 = !{!"unknown", !"sample-pass"} on define void @unknown_entry_count() !prof !0
```
The resulting LLVM IR has no `!prof` attachment:
```llvm
define void @unknown_entry_count() {
ret void
}
```
## Expected behavior
The LLVM IR to LLVM dialect to LLVM IR round trip should retain a function-level `!prof` attachment equivalent to `!{!"unknown", !"sample-pass"}`.
Contributor guide
Research direction
Start with the provided input.ll and run the llvm-as and mlir-translate round trip to reproduce the unhandled function metadata warning. Trace the -import-llvm handling of function-level !prof metadata, then verify that the round-tripped LLVM IR retains an attachment equivalent to !{"unknown", !"sample-pass"}.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100