-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
Description
How to reproduce:
bug.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:
// 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