Issue |
60222
|
Summary |
[mlir] MLIR -> LLVM IR debug location mapping fails on name-only locations
|
Labels |
new issue
|
Assignees |
|
Reporter |
benvanik
|
I ran into an issue where LLVM's verifier was failing saying there was no location information even though I did have that information in MLIR:
```
llvm.dbg.value intrinsic requires a !dbg attachment
call void @llvm.dbg.value(metadata ptr %1, metadata !79, metadata !DIExpression())
label %3
ptr @predict_dispatch_0_generic_128
```
This op originated from the following MLIR:
```mlir
#loc15 = loc("Mul:")
#loc16 = loc("bert/Mul@__inference_predict_6353")
#loc17 = loc("Cast:")
#loc18 = loc("bert/Cast@__inference_predict_6353")
#loc19 = loc("Const:")
#loc20 = loc("bert/Const_1@__inference_predict_6353")
#loc524 = loc(fused[#loc15, #loc16, #loc17, #loc18, #loc19, #loc20])
llvm.intr.dbg.value #di_local_variable = %arg1 : !llvm.ptr<struct<"iree_hal_executable_dispatch_state_v0_t", (i32, i32, i16, i16, i32, i32, i16, i8, i8, ptr<i32>, ptr<ptr<i8>>, ptr<i64>)>> loc(#loc524)
```
The culprit is the recursive location transformation walking NamedLoc children until it bottoms out on an UnknownLoc:
https://github.com/llvm/llvm-project/blob/8ab77a78ba059c0f5f357d7b1062b25b5ab0cb61/mlir/lib/Target/LLVMIR/DebugTranslation.cpp#L300-L301
The result of the translation is then a `@llvm.dbg.value` without any location information and LLVM does not like that.
I'm not quite sure how to map NamedLoc-only locations to DILocation but to prevent compilation errors the export for these debug intrinsics could check to see if location translation produces null locations and drop the op.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs