[llvm] [RFC] Emit dwarf data for signature-changed or new functions (PR #157349)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 19 20:58:58 PDT 2025
yonghong-song wrote:
@dzhidzhoev @OCHyams I tried another approach. Basically, I will add a 'declaration' for the func whose signature changed. The 'declaration' will have the source level signature and the signature-changed func will have *real* signature.
See my github branch:
https://github.com/llvm/llvm-project/compare/main...yonghong-song:llvm-project:dwarf-signature-change/dwarf-signature-change-extra-unit-v6-1
esp. this commit:
https://github.com/llvm/llvm-project/commit/a8ff54bca542d2dcd0e269a77c656052c87fec40
This approach still has the difference with lldb. For example, for my previous example without lto:
```
So comparing this backtrace:
* frame #0: 0x0000555555555161 ex2`inc(x=41) at ex2.c:5:18
frame https://github.com/llvm/llvm-project/pull/1: 0x0000555555555146 ex2`do_work(n=41) at ex2.c:11:13 [inlined]
frame https://github.com/llvm/llvm-project/pull/2: 0x0000555555555140 ex2`main at ex2.c:17:12
frame https://github.com/llvm/llvm-project/pull/3: 0x00007ffff7c2a610 libc.so.6`__libc_start_call_main + 128
frame https://github.com/llvm/llvm-project/pull/4: 0x00007ffff7c2a6c0 libc.so.6`__libc_start_main@@GLIBC_2.34 + 128
frame https://github.com/llvm/llvm-project/pull/5: 0x0000555555555075 ex2`_start + 37
vs. the same backtrace without this pull request:
* frame #0: 0x0000555555555161 ex2`inc(x=41, y=<unavailable>) at ex2.c:5:18
frame https://github.com/llvm/llvm-project/pull/1: 0x0000555555555146 ex2`do_work(n=41) at ex2.c:11:13 [inlined]
frame https://github.com/llvm/llvm-project/pull/2: 0x0000555555555140 ex2`main at ex2.c:17:12
frame https://github.com/llvm/llvm-project/pull/3: 0x00007ffff7c2a610 libc.so.6`__libc_start_call_main + 128
frame https://github.com/llvm/llvm-project/pull/4: 0x00007ffff7c2a6c0 libc.so.6`__libc_start_main@@GLIBC_2.34 + 128
frame https://github.com/llvm/llvm-project/pull/5: 0x0000555555555075 ex2`_start + 37
```
You can see func `ex2()` will have two parameters without this pull request and will have one parameter with this pull request.
The following is the difference with lto enabled.
```
So comparing this backtrace:
* frame #0: 0x0000555555555781 app_lto`api_internal.llvm.36994223926077692(n=5) at lib.c:6:30
frame https://github.com/llvm/llvm-project/pull/1: 0x000055555555574b app_lto`api(n=5) at lib.c:12:10 [inlined]
frame https://github.com/llvm/llvm-project/pull/2: 0x0000555555555740 app_lto`main at main.c:6:13
frame https://github.com/llvm/llvm-project/pull/3: 0x00007ffff7c2a610 libc.so.6`__libc_start_call_main + 128
frame https://github.com/llvm/llvm-project/pull/4: 0x00007ffff7c2a6c0 libc.so.6`__libc_start_main@@GLIBC_2.34 + 128
frame https://github.com/llvm/llvm-project/pull/5: 0x0000555555555675 app_lto`_start + 37
vs. the same backtrace without this pull request:
* frame #0: 0x0000555555555781 app_lto`api_internal(n=5, y=<unavailable>) at lib.c:6:30
frame https://github.com/llvm/llvm-project/pull/1: 0x000055555555574b app_lto`api(n=5) at lib.c:12:10 [inlined]
frame https://github.com/llvm/llvm-project/pull/2: 0x0000555555555740 app_lto`main at main.c:6:13
frame https://github.com/llvm/llvm-project/pull/3: 0x00007ffff7c2a610 libc.so.6`__libc_start_call_main + 128
frame https://github.com/llvm/llvm-project/pull/4: 0x00007ffff7c2a6c0 libc.so.6`__libc_start_main@@GLIBC_2.34 + 128
frame https://github.com/llvm/llvm-project/pull/5: 0x0000555555555675 app_lto`_start + 37
```
You can see with this pull request, we have
```
* frame #0: 0x0000555555555781 app_lto`api_internal.llvm.36994223926077692(n=5) at lib.c:6:30
```
The func name changed to the real func name and the argument becomes one instead of source level 2.
Although the simple non-lto and lto example works fine in the above, when I tried to build linux kernel (more complicated codes), I got a crash like below:
```
#9 0x00007fdf91429873 abort (/lib64/libc.so.6+0x29873)
#10 0x00007fdf9142979b _nl_load_domain.cold (/lib64/libc.so.6+0x2979b)
#11 0x00007fdf914388c6 (/lib64/libc.so.6+0x388c6)
#12 0x00000000096d9731 llvm::DwarfFile::addScopeVariable(llvm::LexicalScope*, llvm::DbgVariable*) /home/yhs/work/yhs/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:112:3
#13 0x00000000096388d3 llvm::DwarfDebug::createConcreteEntity(llvm::DwarfCompileUnit&, llvm::LexicalScope&, llvm::DINode const*, llvm::DILocation const*, llvm::MCSymbol const*) /home/yhs/work/yhs/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1897:3
#14 0x000000000963919c llvm::DwarfDebug::collectEntityInfo(llvm::DwarfCompileUnit&, llvm::DISubprogram const*, llvm::DenseSet<std::pair<llvm::DINode const*, llvm::DILocation const*>, llvm::DenseMapInfo<std::pair<llvm::DINode const*, llvm::DILocation const*>, void>>&) /home/yhs/work/yhs/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2024:5
#15 0x000000000963bc31 llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) /home/yhs/work/yhs/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2757:3
#16 0x00000000096150ff llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) /home/yhs/work/yhs/llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp:0:5
#17 0x00000000095e0a21 llvm::AsmPrinter::emitFunctionBody() /home/yhs/work/yhs/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:2269:22
```
I have not figured out what is the problem and I want to hear expert opinion first about my suggestions.
https://github.com/llvm/llvm-project/pull/157349
More information about the llvm-commits
mailing list