[PATCH] D113741: [RFC][DwarfDebug][AsmPrinter] Support emitting function-local declaration for a lexical block
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 31 06:51:35 PDT 2022
krisb added a comment.
In D113741#3543156 <https://reviews.llvm.org/D113741#3543156>, @dblaikie wrote:
> In D113741#3538747 <https://reviews.llvm.org/D113741#3538747>, @dblaikie wrote:
>
>> Right, so this does only reproduce with Split DWARF + Split DWARF inlining + ThinLTO, I think. The CUs for the imported units Split DWARF inlining are being designated as split units, but then split units aren't actually emitted (because of the single-unit limitation of Split DWARF) and so the pubnames are emitted for DIEs that were never layed out/emitted, by the looks of it, so they get an offset of zero, which looks like/creates a truncated pubnames contribution.
>>
>> Trying to make a small reproducer.
>
> OK, think I've got something in IR at least. Looks like it could be reproduced from source + LTO probably. With an assertions-enabled build of LLVM/Clang:
>
> define void @f1() !dbg !13 {
> lbl:
> ret void, !dbg !16
> }
>
> define void @f2() !dbg !22 {
> lbl:
> ret void, !dbg !23
> }
>
> !llvm.dbg.cu = !{!0, !2, !10}
> !llvm.module.flags = !{!12}
>
> !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug)
> !1 = !DIFile(filename: "a.cc", directory: "")
> !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, emissionKind: FullDebug, imports: !4)
> !3 = !DIFile(filename: "b.cc", directory: "")
> !4 = !{!5}
> !5 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !6, entity: !7)
> !6 = !DISubprogram(scope: null, spFlags: DISPFlagOptimized)
> !7 = !DINamespace(scope: !2)
> !8 = !DISubroutineType(types: !9)
> !9 = !{}
> !10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11, emissionKind: FullDebug)
> !11 = !DIFile(filename: "c.cc", directory: "")
> !12 = !{i32 2, !"Debug Info Version", i32 3}
> !13 = distinct !DISubprogram(scope: null, type: !8, spFlags: DISPFlagDefinition, unit: !0)
> !16 = !DILocation(line: 0, scope: !17, inlinedAt: !18)
> !17 = distinct !DISubprogram(scope: null, unit: !10)
> !18 = !DILocation(line: 0, scope: !21)
> !21 = !DILexicalBlockFile(scope: !13, discriminator: 0)
> !22 = distinct !DISubprogram(scope: null, type: !8, spFlags: DISPFlagDefinition, unit: !0)
> !23 = !DILocation(line: 0, scope: !24, inlinedAt: !25)
> !24 = distinct !DISubprogram(scope: null, unit: !2)
> !25 = !DILocation(line: 0, scope: !22)
>
> clang -cc1 -emit-obj -split-dwarf-file x.dwo x.ll
>
> Does that work for you?
Okay, I got what's wrong.
auto getCUs = [this](const DIScope *S, DwarfCompileUnit *const *TheCU) {
if (auto *LScope = dyn_cast_or_null<DILocalScope>(S)) {
auto CUIt = SPCUsMap.find(LScope->getSubprogram());
if (CUIt != SPCUsMap.end()) {
auto &CUs = CUIt->second;
return llvm::make_range(CUs.begin(), CUs.end());
}
}
return llvm::make_range(TheCU, TheCU + 1);
};
Doing this I was assuming that if SP is not in SPCUsMap, we should fall back to current CU and emit a local entity anyway.
But actually we should skip emitting any local entities if we haven't emitted their parent subprogram by this time. This corresponds to previous behavior of DwarfDebug/DwarfCompileUnit.
I'll update this patch with a fix and a test soon (at least for history).
D125693 <https://reviews.llvm.org/D125693> doesn't suffer from the same issue, as we can decide whether we need to create a local entity while emitting its parent subprogram (so when we skip emission of a subprogram, we also skip emission of all its local entities).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113741/new/
https://reviews.llvm.org/D113741
More information about the llvm-commits
mailing list