diff options
| -rw-r--r-- | llvm/test/DebugInfo/debugify-report-missing-locs-only.ll | 31 | ||||
| -rw-r--r-- | llvm/tools/opt/Debugify.cpp | 12 |
2 files changed, 38 insertions, 5 deletions
diff --git a/llvm/test/DebugInfo/debugify-report-missing-locs-only.ll b/llvm/test/DebugInfo/debugify-report-missing-locs-only.ll new file mode 100644 index 00000000000..c559b9656a5 --- /dev/null +++ b/llvm/test/DebugInfo/debugify-report-missing-locs-only.ll @@ -0,0 +1,31 @@ +; RUN: opt -check-debugify < %s -S -o - 2>&1 | FileCheck %s + +; CHECK: ERROR: Instruction with empty DebugLoc in function foo -- ret void +define void @foo() !dbg !6 { + ret void +} + +; CHECK-NOT: ERROR: Instruction with empty DebugLoc in function bar +define i32 @bar() !dbg !9 { + ret i32 0, !dbg !15 +} + +declare void @llvm.dbg.value(metadata, metadata, metadata) + +!llvm.dbg.cu = !{!0} +!llvm.debugify = !{!3, !4} +!llvm.module.flags = !{!5} + +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) +!1 = !DIFile(filename: "void", directory: "/") +!2 = !{} +!3 = !{i32 6} +!4 = !{i32 1} +!5 = !{i32 2, !"Debug Info Version", i32 3} +!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !2) +!7 = !DISubroutineType(types: !2) +!9 = distinct !DISubprogram(name: "bar", linkageName: "bar", scope: null, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !10) +!10 = !{!11} +!11 = !DILocalVariable(name: "1", scope: !9, file: !1, line: 3, type: !12) +!12 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned) +!15 = !DILocation(line: 0, column: 1, scope: !9) diff --git a/llvm/tools/opt/Debugify.cpp b/llvm/tools/opt/Debugify.cpp index e8437016d94..05ade96a80d 100644 --- a/llvm/tools/opt/Debugify.cpp +++ b/llvm/tools/opt/Debugify.cpp @@ -237,11 +237,13 @@ bool checkDebugifyMetadata(Module &M, continue; } - dbg() << "ERROR: Instruction with empty DebugLoc in function "; - dbg() << F.getName() << " --"; - I.print(dbg()); - dbg() << "\n"; - HasErrors = true; + if (!DL) { + dbg() << "ERROR: Instruction with empty DebugLoc in function "; + dbg() << F.getName() << " --"; + I.print(dbg()); + dbg() << "\n"; + HasErrors = true; + } } // Find missing variables and mis-sized debug values. |

