[clang] [llvm] [DebugInfo] Place local ODR-uniqued types in decl DISubprograms (PR #119001)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 10 11:26:25 PST 2024
dwblaikie wrote:
> > Maybe it's too big/complex a problem to try to think about, and incremental development should overrule here - but may be worth thinking about?
>
> Urgh. I'll admit that I hadn't thought that far ahead, I just wanted to get the patch-series going again now that the root problem is identified.
>
> The DWARF in the existing patch series [0] seems to take a similar direction to this patch, of putting information into declarations where possible. Have a look at the check-lines for llvm/test/DebugInfo/Generic/lexical-block-static-var.ll:
> the static-local variables are defined and given a location inside DW_TAG_lexical_blocks within the abstract definitions of functions,
Ah, fair enough, because the subprogram will contian a list of these local types, then the local type's scope will be a (potentially series of) lexical scope - so the lexical scopes are preserved? That's OK-ish, at least not as problematic as I was imagining. (rest of the discussion below here is just discussion - this point ^ is enough to satisfy my concerns for this patch direction, at least)
> and then there are some other DW_TAG_lexical_blocks inside the inlined instances. It's not clear to me how the inlined-lexical-blocks refer back to the abstract ones.
Yeah, that's probably missing - the ideal would be the inlined/concrete non-inlined instance's lexical blocks should have abstract_origins that refer to the abstract lexical blocks.
> Given that the ODR-uniquing issue was only found experimentally in-the-field, I think we have to accept the incremental approach and discover problems by experience.
Not sure I follow this.
> Stepping back slightly: I think the ODR-uniquing of these types is directly opposed to scope-precision: reducing the number of type definitions down to one _necessarily_ means discarding the extra locality information about where it's scoped in different function instances.
Not sure I follow this either - I think that if each concrete lexical scope references the abstract ones, we could emit correct abstract origins to get the local static variables and types to be scoped appropriately in the resulting DWARF/for the consumer.
GCC does this: https://godbolt.org/z/Khrzdq1Wx
https://github.com/llvm/llvm-project/pull/119001
More information about the llvm-commits
mailing list