Issue 150163
Summary [MLIR][LLVM] Recursive debug type not imported properly if input is bytecode
Labels mlir
Assignees
Reporter Kuree
    How to reproduce:

`bug.c`:
```C
int main() {
    int a = 0;
    return a;
}
```

```
$ clang -O1 -g bug.c -S -emit-llvm -o - | mlir-translate --import-llvm --mlir-print-debuginfo | mlir-opt --emit-bytecode | mlir-translate --mlir-to-llvmir
mismatched subprogram between #dbg record variable and DILocation
#dbg_value(i32 0, !17, !DIExpression(), !20)
label %0
ptr @main
!17 = !DILocalVariable(name: "a", scope: !18, file: !1, line: 2, type: !14)
!18 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !12, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !19)
!20 = !DILocation(line: 0, scope: !11)
!11 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !12, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
label %0
ptr @main
```

Either replacing `--emit-bytecode` with `--mlir-emit-debuginfo` or skipping `mlir-opt` works:
```shell
// works
clang -O1 -g bug.c -S -emit-llvm -o - | mlir-translate --import-llvm --mlir-print-debuginfo | mlir-opt --mlir-print-debuginfo | mlir-translate --mlir-to-llvmir
// works
clang -O1 -g bug.c -S -emit-llvm -o - | mlir-translate --import-llvm --mlir-print-debuginfo  | mlir-translate --mlir-to-llvmir
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to