[llvm] [RFC] Emit dwarf data for signature-changed or new functions (PR #157349)
Vladislav Dzhidzhoev via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 23 04:32:32 PDT 2025
dzhidzhoev wrote:
> @dzhidzhoev I found one problem if `EmitChangedFuncDebugInfo()` logic in DwarfDebug. For example, let us say we have a function like
>
> ```
> struct foo { long a; long b; long c; ... };
> int bar(struct foo arg) { ... }
> ```
>
> The compiler will transfer `int bar(struct foo arg)` to `int bar(struct foo *arg)`. In the debuginfo, initially we will have
>
> ```
> DICompositeType(tag: DW_TAG_structure_type, ...)
> ```
>
> but we do not have a pointer type pointing to the above DICompositeType.
>
> Eventually we want to generate a debuginfo like
>
> ```
> pointer -> DICompositeType(tag: DW_TAG_structure_type, ...)
> ```
>
> We can do this at current IR pass with DIBuilder. But it will be hard to do it in DwarfDebug since in DwarfDebug, we have
>
> ```
> void DwarfDebug::endFunctionImpl(const MachineFunction *MF)
> ```
>
> since MF is a constant pointer, the subsequent SP is also constant. DIBuilder needs a non-constant DIType, e.g.
>
> ```
> createPointerType(DIType *PointeeTy, uint64_t SizeInBits, ...)
> ```
>
> Do you have any suggestions for this?
My proposal was a bit different: LLVM metadata nodes (DI...) is created/modified before DwarfDebug stage, as it is currently done in EmitChangedFuncDebugInfo, and DIEs emission should be performed in DwarfDebug::endFunctionImpl(). So, essentially, my proposal is to remove DwarfDebug::addChangedSubprograms(), and replace it with something performed in DwarfDebug::endFunctionImpl().
For example, if we have functions A(), B(), C(), and after EmitChangedFuncDebugInfo we have A(), B(), C(), DummyA(), DummyB(), DummyC() then AsmPrinter will invoke DwarfDebug::endFunctionImpl() for each of these functions. And DW_TAG_inlined_subroutines should be generated there (as well as the rest of metadata).
https://github.com/llvm/llvm-project/pull/157349
More information about the llvm-commits
mailing list