Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2090,7 +2090,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()) return MI.getDebugLoc(); return DebugLoc(); } Index: llvm/test/CodeGen/X86/line-zero-prologue-end.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/line-zero-prologue-end.ll @@ -0,0 +1,60 @@ +; RUN: llc -filetype=asm -mtriple=x86_64-apple-macosx11.0.0 -O0 %s -o - | FileCheck %s +%swift.type = type { i64 } +%swift.opaque = type opaque +; CHECK-LABEL: Lfunc_begin0: +; CHECK-NEXT: .loc 1 5 0 +; CHECK-NEXT: .cfi_startproc +; CHECK-NEXT: ## %bb.{{[0-9]+}}: +; CHECK-NEXT: .loc 1 0 0 is_stmt +define hidden swiftcc void @"$s4test8markUsedyyxlF"(%swift.opaque* noalias nocapture %0, %swift.type* %T) #0 !dbg !61 { + %t.debug = alloca %swift.opaque*, align 8 + store %swift.opaque* %0, %swift.opaque** %t.debug, align 8, !dbg !73 + ret void, !dbg !75 ; CHECK: .loc{{ +}}1 5 27 prologue_end +} +!llvm.dbg.cu = !{!10, !19} +!llvm.module.flags = !{!22, !28, !33} +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "a", linkageName: "$s4test1aSivp", scope: !2, file: !3, line: 13, type: !4, isLocal: false, isDefinition: true) +!2 = !DIModule(scope: null, name: "test", includePath: "../../../swift/test/DebugInfo") +!3 = !DIFile(filename: "../../../swift/test/DebugInfo/top_level_code.swift", directory: "/Users/shubham/Development/apple/_build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64") +!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "Int", scope: !6, file: !5, size: 64, elements: !7, runtimeLang: DW_LANG_Swift, identifier: "$sSiD") +!5 = !DIFile(filename: "lib/swift/macosx/Swift.swiftmodule/x86_64-apple-macos.swiftmodule", directory: "/Users/shubham/Development/apple/_build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64") +!6 = !DIModule(scope: null, name: "Swift", includePath: "/Users/shubham/Development/apple/_build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/lib/swift/macosx/Swift.swiftmodule/x86_64-apple-macos.swiftmodule") +!7 = !{} +!8 = !DIGlobalVariableExpression(var: !9, expr: !DIExpression()) +!9 = distinct !DIGlobalVariable(name: "b", linkageName: "$s4test1bSivp", scope: !2, file: !3, line: 14, type: !4, isLocal: false, isDefinition: true) +!10 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !3, producer: "Swift version 5.6-dev (LLVM 86aaebfb3241be9, Swift 0977c1b7f9e41e8)", isOptimized: false, runtimeVersion: 5, emissionKind: FullDebug, enums: !7, globals: !11, imports: !12) +!11 = !{!0, !8} +!12 = !{!13, !17} +!13 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !3, entity: !2, file: !3) +!17 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !3, entity: !18, file: !3) +!18 = !DIModule(scope: null, name: "SwiftOnoneSupport", includePath: "/Users/shubham/Development/apple/_build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/lib/swift/macosx/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftmodule") +!19 = distinct !DICompileUnit(language: DW_LANG_ObjC, file: !20, producer: "clang version 10.0.0 (git@github.com:apple/llvm-project.git 86aaebfb3241be9519cef1a8bd2d3941e8790ae4)", isOptimized: false, runtimeVersion: 2, emissionKind: FullDebug, enums: !7, splitDebugInlining: false, nameTableKind: None, sysroot: "/") +!20 = !DIFile(filename: "", directory: "/Users/shubham/Development/apple/_build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64") +!22 = !{i32 1, !"Objective-C Version", i32 2} +!28 = !{i32 2, !"Debug Info Version", i32 3} +!33 = !{i32 1, !"Swift Version", i32 7} +!40 = !{!41, !42} +!41 = !DICompositeType(tag: DW_TAG_structure_type, name: "Int32", scope: !6, file: !5, size: 32, elements: !7, runtimeLang: DW_LANG_Swift, identifier: "$ss5Int32VD") +!42 = !DICompositeType(tag: DW_TAG_structure_type, scope: !6, file: !5, size: 64, elements: !43, runtimeLang: DW_LANG_Swift) +!43 = !{!44} +!44 = !DIDerivedType(tag: DW_TAG_member, scope: !6, file: !5, baseType: !45, size: 64) +!45 = !DICompositeType(tag: DW_TAG_structure_type, name: "UnsafeMutablePointer", scope: !6, file: !5, flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, templateParams: !46, identifier: "$sSpySpys4Int8VGSgGD") +!46 = !{!47} +!47 = !DITemplateTypeParameter(type: !48) +!48 = !DICompositeType(tag: DW_TAG_structure_type, name: "$sSpys4Int8VGSgD", scope: !6, flags: DIFlagFwdDecl, runtimeLang: DW_LANG_Swift, identifier: "$sSpys4Int8VGSgD") +!56 = !DIFile(filename: "", directory: "") +!61 = distinct !DISubprogram(name: "markUsed", linkageName: "$s4test8markUsedyyxlF", scope: !2, file: !3, line: 5, type: !62, scopeLine: 5, spFlags: DISPFlagDefinition, unit: !10, retainedNodes: !66) +!62 = !DISubroutineType(types: !63) +!63 = !{!64, !65} +!64 = !DICompositeType(tag: DW_TAG_structure_type, name: "$sytD", file: !3, elements: !7, runtimeLang: DW_LANG_Swift, identifier: "$sytD") +!65 = !DICompositeType(tag: DW_TAG_structure_type, name: "$sxD", file: !3, runtimeLang: DW_LANG_Swift, identifier: "$sxD") +!66 = !{!67, !71} +!67 = !DILocalVariable(name: "$\CF\84_0_0", scope: !61, file: !3, type: !68, flags: DIFlagArtificial) +!68 = !DIDerivedType(tag: DW_TAG_typedef, name: "T", scope: !69, file: !56, baseType: !70) +!69 = !DIModule(scope: null, name: "Builtin") +!70 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "$sBpD", baseType: null, size: 64) +!71 = !DILocalVariable(name: "t", arg: 1, scope: !61, file: !3, line: 5, type: !72) +!72 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !65) +!73 = !DILocation(line: 0, scope: !61) +!75 = !DILocation(line: 5, column: 27, scope: !61) Index: llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir =================================================================== --- llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir +++ llvm/test/DebugInfo/MIR/X86/debug-loc-0.mir @@ -3,9 +3,9 @@ # 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-NOT: .loc 1 0 0 prologue_end +# CHECK: .loc 1 37 1 prologue_end --- | ; ModuleID = '' Index: llvm/test/DebugInfo/X86/dbg-prolog-end.ll =================================================================== --- llvm/test/DebugInfo/X86/dbg-prolog-end.ll +++ 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: