diff options
| author | yonghong-song <yhs@fb.com> | 2026-02-03 13:55:29 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-03 13:55:29 -0800 |
| commit | 43faefdb12337216957b2fac34ca6bd1bed371b7 (patch) | |
| tree | 5c5c9eec7783d2d42e2168232779ba660395354b /llvm/lib/Bitcode/Reader/MetadataLoader.cpp | |
| parent | d8350712b300bcd4d05240b8edec40cc96e6d588 (diff) | |
| download | llvm-43faefdb12337216957b2fac34ca6bd1bed371b7.tar.gz llvm-43faefdb12337216957b2fac34ca6bd1bed371b7.tar.bz2 llvm-43faefdb12337216957b2fac34ca6bd1bed371b7.zip | |
[ArgPromotion] Add DW_CC_nocall to DISubprogram (#178973)
ArgumentPromotion pass may change function signatures. If this happens
and debuginfo is enabled, adding DW_CC_nocall allows dwarf to generate
DW_AT_calling_convention (DW_CC_nocall)
for DW_TAG_subprogram.
DeadArgumentElimination ([1]) already has similar implementation.
The pahole tool ([2]) is used in linux kernel build to generate vmlinux
BTF. One of its input is linux kernel dwarf. Currently, pahole
checks *all* DW_TAG_subprogram functions and find whether the source
signature matches the architecture ABI or not. If mismatch, pahole will
try to do some adjustment for those parameters. See [3]
and function parameter__new().
The linux kernel typically has ~65K functions and roughly 1100 functions
may have signature changed due to compile optimization. Without
DW_CC_nocall,
signatures of all of 64K functions will be checked in parameter__new().
But with DW_CC_nocall, the number of functions to checked is only 1100,
much smaller.
If DW_CC_nocall is not available, pahole may needs to parse complicated
locations. Even if the signature is not changed, pahole may not be able to
decide that the location matches function signature, and will incorrectly
exclude this function for vmlinux BTF.
So overall, adding DW_CC_nocall in ArgumentPromotion can help pahole
with less build time and more correct function encoding in vmlinux BTF.
With change in ArgumentPromotion.cpp, the test dbg.ll will fail since
the subroutine type is null. The non-null subroutine type is added so
the test can pass.
Without change in ArgumentPromotion.cpp, the dbg.ll will have
...
!3 = distinct !DISubprogram(name: "test", scope: null, file: !2, line: 3, type: !4,
scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !1)
!4 = !DISubroutineType(types: !5)
!5 = !{null, !6}
...
With change in Argumentpromotion.cpp, the dbg.ll will have
...
!3 = distinct !DISubprogram(name: "test", scope: null, file: !2, line: 3, type: !4,
scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !1)
!4 = !DISubroutineType(cc: DW_CC_nocall, types: !5)
!5 = !{null, !6}
Eventually, DW_CC_nocall will be encoded in dwarf.
[1] https://github.com/llvm/llvm-project/commit/340b0ca90095d838f095271aaa1098fa1bd5ecbe
[2] https://git.kernel.org/pub/scm/devel/pahole/pahole.git
[3] https://git.kernel.org/pub/scm/devel/pahole/pahole.git/tree/dwarf_loader.c
Diffstat (limited to 'llvm/lib/Bitcode/Reader/MetadataLoader.cpp')
0 files changed, 0 insertions, 0 deletions
