diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1876,7 +1876,7 @@ for (const auto &MBB : *MF) for (const auto &MI : MBB) if (!MI.isMetaInstruction() && !MI.getFlag(MachineInstr::FrameSetup) && - MI.getDebugLoc()) + MI.getDebugLoc() && (MI.getDebugLoc().getLine() != 0)) return MI.getDebugLoc(); return DebugLoc(); } diff --git a/llvm/test/DebugInfo/AArch64/prologue_end_line_0.ll b/llvm/test/DebugInfo/AArch64/prologue_end_line_0.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/AArch64/prologue_end_line_0.ll @@ -0,0 +1,43 @@ +; Check whether prologue_end was marked correctly. The IR in this test is +; reduced form this C program: +; +; int var1; +; int main() { +; var1 = 2; +; return 0; +; } + +; RUN: llc -O0 %s -o - | FileCheck %s + +; CHECK: .loc 1 0 0 +; CHECK: .loc 1 3 8 prologue_end + +@var1 = common dso_local global i32 0, align 4, !dbg !0 + +; Function Attrs: noinline nounwind optnone +define dso_local i32 @main() #0 !dbg !11 { +entry: + %retval = alloca i32, align 4 + store i32 0, i32* %retval, align 4 + store i32 2, i32* @var1, align 4, !dbg !14 + ret i32 0, !dbg !15 +} + +!llvm.dbg.cu = !{!2} +!llvm.module.flags = !{!7, !8, !9} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "var1", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true) +!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None) +!3 = !DIFile(filename: "test.c", directory: "/tmp") +!4 = !{} +!5 = !{!0} +!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!7 = !{i32 7, !"Dwarf Version", i32 4} +!8 = !{i32 2, !"Debug Info Version", i32 3} +!9 = !{i32 1, !"wchar_size", i32 4} +!11 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 2, type: !12, scopeLine: 2, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !4) +!12 = !DISubroutineType(types: !13) +!13 = !{!6} +!14 = !DILocation(line: 3, column: 8, scope: !11) +!15 = !DILocation(line: 4, column: 3, scope: !11) diff --git a/llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir b/llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir --- a/llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir +++ b/llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir @@ -3,9 +3,8 @@ # RUN: llc -start-before=machine-cp -O2 -filetype=asm -mtriple=x86_64-apple-macosx10.9.0 -o - %s | FileCheck %s # CHECK: Ltmp0: -# CHECK: .loc 1 0 0 prologue_end -# CHECK-NOT: .loc 1 0 0 -# CHECK: .loc 1 37 1 +# CHECK: .loc 1 0 0 +# CHECK: .loc 1 37 1 prologue_end --- | ; ModuleID = '' diff --git a/llvm/test/DebugInfo/X86/dbg-prolog-end.ll b/llvm/test/DebugInfo/X86/dbg-prolog-end.ll --- a/llvm/test/DebugInfo/X86/dbg-prolog-end.ll +++ b/llvm/test/DebugInfo/X86/dbg-prolog-end.ll @@ -26,7 +26,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone ;CHECK-LABEL: main: -;CHECK: .loc 1 0 0 prologue_end +;CHECK: .loc 1 8 2 prologue_end define i32 @main() nounwind ssp !dbg !6 { entry: