[PATCH] D135267: [DWARF] Share across CUs only when order free
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 14:37:01 PDT 2022
dblaikie added a comment.
In D135267#3839218 <https://reviews.llvm.org/D135267#3839218>, @DianQK wrote:
> In D135267#3837570 <https://reviews.llvm.org/D135267#3837570>, @dblaikie wrote:
>
>> Sorry, I'm not really understanding most of this - could you explain further what you mean by "successor" nodes and what "order free" means in this context?
>
> Sorry I didn't explain clearly.
>
> In this context,
>
> !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !4, file: !1, runtimeLang: DW_LANG_Swift)
> !21 = distinct !DISubprogram(name: "hashValue.get", linkageName: "$hashValueGetInFoo2", scope: !10, file: !14, type: !15, spFlags: DISPFlagDefinition, unit: !0)
>
> !21 is a "successor" node of !10 (link by scope).
OK - I don't think that's a term we've historically used in describing debug info metadata, so it might be a bit confusing in this review and moreso in any comments/variable names, etc.
So `!21` is a member function of `!10`, likely - `!21` probably (but doesn't have to be) listed in the `members` list of `!10`.
Oh... I think I see the problem. Perhaps Swift should produce debug info that looks more like Clang's debug info - where all member functions are declarations, and are not scoped inside the type that they're a member of.
take for example this C++:
struct t1 {
void f1() {
}
};
int main() {
t1().f1();
}
it produces this IR:
17 = distinct !DISubprogram(name: "f1", linkageName: "_ZN2t12f1Ev", scope: !18, file: !1, line: 2, type: !21, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !20, retainedNodes: !14)
!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "t1", file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !19, identifier: "_ZTS2t1")
!19 = !{!20}
!20 = !DISubprogram(name: "f1", linkageName: "_ZN2t12f1Ev", scope: !18, file: !1, line: 2, type: !21, scopeLine: 2, flags: DIFlagPrototyped, spFlags: 0)
Hmm, well "f1" is scoped to `!18`, my mistake. But this, one way or another, still doesn't try to put the definition of "f1" inside the definition of "t1" in LLVM's DWARF generation - so maybe it's the presence of a declaration that makes this work for C++ but not for swift?
Given this is pretty common in C++, and C++, as far as I understand, has been working OK with cross-CU sharing in LTO for many years now - it'd be worth better understanding what's different about Swift's debug info that's causing problems here, and consider where best to fix the issue - whether to make Swift's debug info look more like the C++ debug info we've had for a while, or to support some new case.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135267/new/
https://reviews.llvm.org/D135267
More information about the llvm-commits
mailing list