[PATCH] D147620: [DebugInfo] Keep the CU consistent for operating `DISubprogram`.

DianQK via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 05:18:16 PDT 2023


DianQK added a comment.

In D147620#4311265 <https://reviews.llvm.org/D147620#4311265>, @dblaikie wrote:

>> This has nothing to do with members, just a declaration to switch the parent DIE from scope to unit. I don't think this makes sense.
>
> Could you explain in more detail why you don't think this makes sense?

This is my consideration only from **the perspective of code implementation**.
See DwarfUnit.cpp#L1157-L1166 <https://github.com/llvm/llvm-project/blob/fe3ed6550ef277f5c47a9ccdbdd466fa225f4a99/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp#L1157-L1166>:

  DIE *ContextDIE =
      Minimal ? &getUnitDie() : getOrCreateContextDIE(SP->getScope());
  
  if (DIE *SPDie = getDIE(SP))
    return SPDie;
  
  if (auto *SPDecl = SP->getDeclaration()) {
    if (!Minimal) {
      // Add subprogram definitions to the CU die directly.
      ContextDIE = &getUnitDie();

As above code, the `ParentDIE` of `distinct !DISubprogram(name: "foo", scope: !21, spFlags: DISPFlagDefinition, unit: !1)` is `scope`.
However, the `ParentDIE` of `distinct !DISubprogram(name: "foo", scope: !21, spFlags: DISPFlagDefinition, unit: !1, declaration: !40)` is `unit`. **Just a declaration** makes such a difference. So I don't think this makes sense.

> Note that this has nothing to do with the `members` of `DICompositeType`.

I blame this code to Debug Info: use createAndAddDIE for newly-created Subprogram DIEs <https://github.com/llvm/llvm-project/commit/73d697c641f18c093a9d801c82f914e255c15072#diff-26b268e302c98242dfd5e53d101d8d15cab2b41ed7ecde9c60a5fc4ef7d320b0R1360-R1362>. Interestingly, I found this code to solve the DIE across CU/LTO problem.
>From this patch, I am more convinced that my patch is a more suitable solution.
The declaration should not control the `ContextDIE` here.

---

> That's the fix at the source here - producers should produce declarations for these member functions and then it'll work.

Based on the above explanation of declarations deciding DIE, I think the declaration and members should play some role in other debugging structures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147620/new/

https://reviews.llvm.org/D147620



More information about the llvm-commits mailing list