Skip to content

Commit b1357f0

Browse files
committed
[DebugInfo] Emit skeleton to avoid mismatching inlining flags
This actually reverts 4181205. The original commit omits unit with all symbols inlined into current one, which leads to crash when a module using split-dwarf inlined a function from another module with mismatched split-dwarf-inlining option. This revert guarantees that DIEs are created in both DWO and the skeleton sections whenever split-dwarf is active.
1 parent e75f054 commit b1357f0

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -558,18 +558,14 @@ void DwarfDebug::constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU,
558558

559559
// Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
560560
// was inlined from another compile unit.
561-
if (useSplitDwarf() && !shareAcrossDWOCUs() && !SP->getUnit()->getSplitDebugInlining())
562-
// Avoid building the original CU if it won't be used
563-
SrcCU.constructAbstractSubprogramScopeDIE(Scope);
564-
else {
565-
auto &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
566-
if (auto *SkelCU = CU.getSkeleton()) {
567-
(shareAcrossDWOCUs() ? CU : SrcCU)
568-
.constructAbstractSubprogramScopeDIE(Scope);
569-
if (CU.getCUNode()->getSplitDebugInlining())
570-
SkelCU->constructAbstractSubprogramScopeDIE(Scope);
571-
} else
572-
CU.constructAbstractSubprogramScopeDIE(Scope);
561+
auto &CU = getOrCreateDwarfCompileUnit(SP->getUnit());
562+
if (auto *SkelCU = CU.getSkeleton()) {
563+
(shareAcrossDWOCUs() ? CU : SrcCU)
564+
.constructAbstractSubprogramScopeDIE(Scope);
565+
if (CU.getCUNode()->getSplitDebugInlining())
566+
SkelCU->constructAbstractSubprogramScopeDIE(Scope);
567+
} else {
568+
CU.constructAbstractSubprogramScopeDIE(Scope);
573569
}
574570
}
575571

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; RUN: llc -split-dwarf-file=foo.dwo %s -filetype=obj -o - | llvm-dwarfdump -debug-info - | FileCheck %s
2+
3+
; CHECK: .debug_info contents:
4+
; CHECK: DW_TAG_subprogram
5+
; CHECK: caller_func
6+
; CHECK: DW_TAG_inlined_subroutine
7+
; CHECK: inlined_func
8+
9+
; CHECK: .debug_info.dwo contents
10+
; CHECK: DW_TAG_subprogram
11+
; CHECK: caller_func
12+
; CHECK: DW_TAG_inlined_subroutine
13+
; CHECK: inlined_func
14+
15+
target triple = "x86_64-unknown-linux-gnu"
16+
17+
define void @caller_func() !dbg !9 {
18+
entry:
19+
ret void, !dbg !13
20+
}
21+
22+
!llvm.dbg.cu = !{!0, !3}
23+
!llvm.module.flags = !{!5, !6}
24+
25+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang trunk", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false)
26+
!1 = !DIFile(filename: "a.cpp", directory: "/tmp")
27+
!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !4, producer: "clang trunk", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: true)
28+
!4 = !DIFile(filename: "b.cpp", directory: "/tmp")
29+
!5 = !{i32 2, !"Dwarf Version", i32 4}
30+
!6 = !{i32 2, !"Debug Info Version", i32 3}
31+
!9 = distinct !DISubprogram(name: "caller_func", scope: !4, file: !4, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, unit: !3)
32+
!10 = !DISubroutineType(types: !11)
33+
!11 = !{null}
34+
!12 = distinct !DISubprogram(name: "inlined_func", scope: !1, file: !1, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, unit: !0)
35+
!13 = !DILocation(line: 1, column: 5, scope: !12, inlinedAt: !14)
36+
!14 = distinct !DILocation(line: 3, column: 3, scope: !9)

0 commit comments

Comments
 (0)