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/X86/debug-loc-0.ll =================================================================== --- /dev/null +++ test/DebugInfo/X86/debug-loc-0.ll @@ -0,0 +1,114 @@ +; REQUIRES: object-emission + +; Check that subsequent .loc 0 0 directives are collapsed. + +; RUN: llc -O2 -filetype=asm -mtriple=x86_64-apple-macosx10.9.0 < %s \ +; RUN: | FileCheck %s + +; CHECK: Ltmp0: +; CHECK: .loc 1 0 0 prologue_end +; CHECK-NOT: .loc 1 0 0 +; CHECK: .loc 1 24 12 + +; ModuleID = '/tmp/extracted' +source_filename = "/Users/jonas/llvm/git-svn/llvm/test/DebugInfo/X86/debug-loc-0.ll" +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"() #0 !dbg !27 { +entry: + %s1.addr = alloca i8*, align 8 + call void @llvm.dbg.declare(metadata i8** %s1.addr, metadata !31, metadata !DIExpression(DW_OP_deref)), !dbg !35 + %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) #3, !dbg !36 + %2 = extractvalue %swift.metadata_response %1, 0, !dbg !36 + %3 = bitcast %swift.type* %2 to i8***, !dbg !36 + %4 = getelementptr inbounds i8**, i8*** %3, i64 -1, !dbg !36 + %.valueWitnesses = load i8**, i8*** %4, align 8, !dbg !36, !invariant.load !2, !dereferenceable !37 + %5 = getelementptr inbounds i8*, i8** %.valueWitnesses, i32 9, !dbg !36 + %6 = load i8*, i8** %5, align 8, !dbg !36, !invariant.load !2 + %size = ptrtoint i8* %6 to i64, !dbg !36 + %s1 = alloca i8, i64 %size, align 16, !dbg !36 + call void @llvm.lifetime.start.p0i8(i64 -1, i8* %s1), !dbg !36 + %7 = bitcast i8* %s1 to %swift.opaque*, !dbg !36 + store i8* %s1, i8** %s1.addr, align 8, !dbg !36 + call swiftcc void @"$S16resilient_struct4SizeV1w1hACSi_SitcfC"(%swift.opaque* noalias nocapture sret %7, i64 1, i64 2), !dbg !38 + %8 = getelementptr inbounds i8*, i8** %.valueWitnesses, i32 1, !dbg !39 + %9 = load i8*, i8** %8, align 8, !dbg !39, !invariant.load !2 + %destroy = bitcast i8* %9 to void (%swift.opaque*, %swift.type*)*, !dbg !39 + call void %destroy(%swift.opaque* noalias %7, %swift.type* %2) #4, !dbg !39 + %10 = bitcast %swift.opaque* %7 to i8*, !dbg !36 + call void @llvm.lifetime.end.p0i8(i64 -1, i8* %10), !dbg !36 + ret void, !dbg !40 +} + +; Function Attrs: nounwind readnone speculatable +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +declare swiftcc %swift.metadata_response @"$S16resilient_struct4SizeVMa"(i64) #0 + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2 + +declare swiftcc void @"$S16resilient_struct4SizeV1w1hACSi_SitcfC"(%swift.opaque* noalias nocapture sret, i64, i64) #0 + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2 + +attributes #0 = { "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "target-cpu"="core2" "target-features"="+cx16,+fxsr,+mmx,+sahf,+sse,+sse2,+sse3,+ssse3,+x87" } +attributes #1 = { nounwind readnone speculatable } +attributes #2 = { argmemonly nounwind } +attributes #3 = { nounwind readnone } +attributes #4 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!13, !14, !15, !16, !17, !18, !19, !20, !21, !22} +!llvm.linker.options = !{!23, !24, !25} +!llvm.asan.globals = !{!26} + +!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: !3) +!1 = !DIFile(filename: "/Users/jonas/swift/swift/test/DebugInfo/struct_resilience.swift", directory: "/Users/jonas/swift") +!2 = !{} +!3 = !{!4, !7, !9, !11} +!4 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !6, file: !5) +!5 = !DIFile(filename: "struct_resilience.swift", directory: "/Users/jonas/swift/swift/test/DebugInfo") +!6 = !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") +!7 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !8, file: !5) +!8 = !DIModule(scope: null, name: "Swift", includePath: "/Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/lib/swift/macosx/x86_64/Swift.swiftmodule", isysroot: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk") +!9 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !10, file: !5, line: 14) +!10 = !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") +!11 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !12, file: !5) +!12 = !DIModule(scope: null, name: "SwiftOnoneSupport", includePath: "/Users/jonas/swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/lib/swift/macosx/x86_64/SwiftOnoneSupport.swiftmodule", isysroot: "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk") +!13 = !{i32 1, !"Objective-C Version", i32 2} +!14 = !{i32 1, !"Objective-C Image Info Version", i32 0} +!15 = !{i32 1, !"Objective-C Image Info Section", !"__DATA,__objc_imageinfo,regular,no_dead_strip"} +!16 = !{i32 4, !"Objective-C Garbage Collection", i32 1536} +!17 = !{i32 1, !"Objective-C Class Properties", i32 64} +!18 = !{i32 2, !"Dwarf Version", i32 4} +!19 = !{i32 2, !"Debug Info Version", i32 3} +!20 = !{i32 1, !"wchar_size", i32 4} +!21 = !{i32 7, !"PIC Level", i32 2} +!22 = !{i32 1, !"Swift Version", i32 6} +!23 = !{!"-lswiftSwiftOnoneSupport"} +!24 = !{!"-lswiftCore"} +!25 = !{!"-lobjc"} +!26 = distinct !{null, null, null, i1 false, i1 true} +!27 = distinct !DISubprogram(name: "f", linkageName: "$S4main1fyyF", scope: !6, file: !5, line: 23, type: !28, scopeLine: 23, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) +!28 = !DISubroutineType(types: !29) +!29 = !{!30} +!30 = !DICompositeType(tag: DW_TAG_structure_type, name: "$SytD", file: !5, elements: !2, runtimeLang: DW_LANG_Swift, identifier: "$SytD") +!31 = !DILocalVariable(name: "s1", scope: !32, file: !5, line: 24, type: !33) +!32 = distinct !DILexicalBlock(scope: !27, file: !5, line: 23, column: 10) +!33 = !DICompositeType(tag: DW_TAG_structure_type, name: "Size", scope: !10, file: !34, size: 512, elements: !2, runtimeLang: DW_LANG_Swift, identifier: "$S16resilient_struct4SizeVD") +!34 = !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") +!35 = !DILocation(line: 24, column: 7, scope: !32) +!36 = !DILocation(line: 0, scope: !32) +!37 = !{i64 96} +!38 = !DILocation(line: 24, column: 12, scope: !32) +!39 = !DILocation(line: 25, column: 3, scope: !32) +!40 = !DILocation(line: 37, column: 1, scope: !32)