Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1489,7 +1489,7 @@ // We have an explicit location, different from the previous location. // Don't repeat a line-0 record, but otherwise emit the new location. // (The new location might be an explicit line 0, which we do emit.) - if (PrevInstLoc && DL.getLine() == 0 && LastAsmLine == 0) + if (DL.getLine() == 0 && LastAsmLine == 0) return; unsigned Flags = 0; if (DL == PrologEndLoc) { Index: test/DebugInfo/MIR/X86/debug-loc-0.mir =================================================================== --- /dev/null +++ test/DebugInfo/MIR/X86/debug-loc-0.mir @@ -0,0 +1,116 @@ +# Check that subsequent .loc 0 0 directives are collapsed. + +# RUN: llc -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 + +--- | + ; ModuleID = '' + source_filename = "" + target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" + target triple = "x86_64-apple-macosx10.9.0" + + %swift.opaque = type opaque + %swift.metadata_response = type { %swift.type*, i64 } + %swift.type = type { i64 } + + define hidden swiftcc void @"$S4main1fyyF"() !dbg !5 { + entry: + %s1.addr = alloca i8*, align 8 + call void @llvm.dbg.declare(metadata i8** %s1.addr, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !16 + %0 = bitcast i8** %s1.addr to %swift.opaque** + store %swift.opaque* null, %swift.opaque** %0, align 8 + %1 = call swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"(i64 0) #2, !dbg !17 + %2 = extractvalue %swift.metadata_response %1, 0, !dbg !17 + %3 = bitcast %swift.type* %2 to i8***, !dbg !17 + %4 = getelementptr inbounds i8**, i8*** %3, i64 -1, !dbg !17 + ret void, !dbg !18 + } + + ; Function Attrs: nounwind readnone speculatable + declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 + + declare swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"(i64) + + ; Function Attrs: nounwind + declare void @llvm.stackprotector(i8*, i8**) #1 + + attributes #0 = { nounwind readnone speculatable } + attributes #1 = { nounwind } + attributes #2 = { nounwind readnone } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4} + + !0 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !1, producer: "Swift version 4.2.1-dev effective-3.4.1 (LLVM 4ba03d9389, Clang 78aa734eee, Swift f4134ebef6)", isOptimized: false, flags: "-target x86_64-apple-macosx10.9 -module-cache-path /Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/./swift-test-results/x86_64-apple-macosx10.9/clang-module-cache -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -swift-version 3 -g -I /Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/test-macosx-x86_64/DebugInfo/Output/struct_resilience.swift.tmp -emit-ir -enable-resilience /Users/jonas/swift/swift/test/DebugInfo/struct_resilience.swift -o /tmp/41.ll -resource-dir /Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/lib/swift", runtimeVersion: 4, emissionKind: FullDebug, enums: !2, imports: !2) + !1 = !DIFile(filename: "/Users/jonas/swift/swift/test/DebugInfo/struct_resilience.swift", directory: "/Users/jonas/swift") + !2 = !{} + !3 = !{i32 2, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = distinct !DISubprogram(name: "f", linkageName: "$S4main1fyyF", scope: !7, file: !6, line: 23, type: !8, scopeLine: 23, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) + !6 = !DIFile(filename: "struct_resilience.swift", directory: "/Users/jonas/swift/swift/test/DebugInfo") + !7 = !DIModule(scope: null, name: "main", includePath: "/Users/jonas/swift/swift/test/DebugInfo", isysroot: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk") + !8 = !DISubroutineType(types: !9) + !9 = !{!10} + !10 = !DICompositeType(tag: DW_TAG_structure_type, name: "$SytD", file: !6, elements: !2, runtimeLang: DW_LANG_Swift, identifier: "$SytD") + !11 = !DILocalVariable(name: "s1", scope: !12, file: !6, line: 24, type: !13) + !12 = distinct !DILexicalBlock(scope: !5, file: !6, line: 23, column: 10) + !13 = !DICompositeType(tag: DW_TAG_structure_type, name: "Size", scope: !15, file: !14, size: 512, elements: !2, runtimeLang: DW_LANG_Swift, identifier: "$S16resilient_struct4SizeVD") + !14 = !DIFile(filename: "resilient_struct.swiftmodule", directory: "/Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/test-macosx-x86_64/DebugInfo/Output/struct_resilience.swift.tmp") + !15 = !DIModule(scope: null, name: "resilient_struct", includePath: "/Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/test-macosx-x86_64/DebugInfo/Output/struct_resilience.swift.tmp/resilient_struct.swiftmodule", isysroot: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk") + !16 = !DILocation(line: 24, column: 7, scope: !12) + !17 = !DILocation(line: 0, scope: !12) + !18 = !DILocation(line: 37, column: 1, scope: !12) + +... +--- +name: '$S4main1fyyF' +alignment: 4 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +registers: [] +liveins: [] +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 0 + offsetAdjustment: 0 + maxAlignment: 8 + adjustsStack: false + hasCalls: true + stackProtector: '' + maxCallFrameSize: 4294967295 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: s1.addr, type: default, offset: 0, size: 8, alignment: 8, + stack-id: 0, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '!11', debug-info-expression: '!DIExpression(DW_OP_deref)', + debug-info-location: '!16' } +constants: [] +body: | + bb.0.entry: + MOV64mi32 %stack.0.s1.addr, 1, $noreg, 0, $noreg, 0 :: (store 8 into %ir.0) + ADJCALLSTACKDOWN64 0, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !17 + dead $edi = MOV32r0 implicit-def dead $eflags, implicit-def $rdi, debug-location !17 + CALL64pcrel32 @"$S16resilient_struct4SizeVMa", csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def dead $rax, implicit-def dead $rdx, debug-location !17 + ADJCALLSTACKUP64 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp, debug-location !17 + RET 0, debug-location !18 + +...