Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,18 +558,14 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU,

// Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
// was inlined from another compile unit.
if (useSplitDwarf() && !shareAcrossDWOCUs() && !SP->getUnit()->getSplitDebugInlining())
// Avoid building the original CU if it won't be used
SrcCU.constructAbstractSubprogramScopeDIE(Scope);
else {
auto &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
if (auto *SkelCU = CU.getSkeleton()) {
(shareAcrossDWOCUs() ? CU : SrcCU)
.constructAbstractSubprogramScopeDIE(Scope);
if (CU.getCUNode()->getSplitDebugInlining())
SkelCU->constructAbstractSubprogramScopeDIE(Scope);
} else
CU.constructAbstractSubprogramScopeDIE(Scope);
auto &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
if (auto *SkelCU = CU.getSkeleton()) {
(shareAcrossDWOCUs() ? CU : SrcCU)
.constructAbstractSubprogramScopeDIE(Scope);
if (CU.getCUNode()->getSplitDebugInlining())
SkelCU->constructAbstractSubprogramScopeDIE(Scope);
} else {
CU.constructAbstractSubprogramScopeDIE(Scope);
}
}

Expand Down
36 changes: 36 additions & 0 deletions llvm/test/DebugInfo/X86/split-dwarf-inline.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
; RUN: llc -split-dwarf-file=foo.dwo %s -filetype=obj -o - | llvm-dwarfdump -debug-info - | FileCheck %s

; CHECK: .debug_info contents:
; CHECK: DW_TAG_subprogram
; CHECK: caller_func
; CHECK: DW_TAG_inlined_subroutine
; CHECK: inlined_func

; CHECK: .debug_info.dwo contents
; CHECK: DW_TAG_subprogram
; CHECK: caller_func
; CHECK: DW_TAG_inlined_subroutine
; CHECK: inlined_func

target triple = "x86_64-unknown-linux-gnu"

define void @caller_func() !dbg !9 {
entry:
ret void, !dbg !13
}

!llvm.dbg.cu = !{!0, !3}
!llvm.module.flags = !{!5, !6}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang trunk", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false)
!1 = !DIFile(filename: "a.cpp", directory: "/tmp")
!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang trunk", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: true)
!4 = !DIFile(filename: "b.cpp", directory: "/tmp")
!5 = !{i32 2, !"Dwarf Version", i32 4}
!6 = !{i32 2, !"Debug Info Version", i32 3}
!9 = distinct !DISubprogram(name: "caller_func", scope: !4, file: !4, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, unit: !3)
!10 = !DISubroutineType(types: !11)
!11 = !{null}
!12 = distinct !DISubprogram(name: "inlined_func", scope: !1, file: !1, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, unit: !0)
!13 = !DILocation(line: 1, column: 5, scope: !12, inlinedAt: !14)
!14 = distinct !DILocation(line: 3, column: 3, scope: !9)