[llvm] [RFC] Emit dwarf data for signature-changed or new functions (PR #157349)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 23:31:49 PDT 2025


yonghong-song wrote:

@dzhidzhoev For the following dwarf:
```
DW_TAG_subprogram
                DW_AT_low_pc	(0x0000000000000000)
                DW_AT_high_pc	(0x0000000000000006)
                DW_AT_frame_base	(DW_OP_reg7 RSP)
                DW_AT_call_all_calls	(true)
                DW_AT_linkage_name	("_Z3mulii")
                DW_AT_name	("mul")
                ...

              DW_TAG_formal_parameter
                  DW_AT_location	(DW_OP_reg5 RDI)
                  DW_AT_name	("num1")
                  DW_AT_decl_file	("/app/example.cpp")
                  DW_AT_decl_line	(...)
                  DW_AT_type	(0x0000003d "int")

              DW_TAG_inlined_subroutine
                  DW_AT_abstract_origin	(LOC_A "mul")
                  DW_AT_low_pc	(...)
                  DW_AT_high_pc	(...)
                  DW_AT_call_file	("/app/example.cpp")
                  DW_AT_call_line	(...)
                  DW_AT_call_column	(...)

                    DW_TAG_formal_parameter
                            DW_AT_location	(DW_OP_reg5 RDI)
                            DW_AT_abstract_origin	(LOC_B "num1")
                    DW_TAG_formal_parameter
                            DW_AT_location	(DW_OP_reg5 RDI)
                            DW_AT_abstract_origin	(LOC_C "num2")
             NULL
NULL
```
If the tool tries to find the original signature based on 
```
DW_TAG_subprogram
                DW_AT_low_pc	(0x0000000000000000)
                DW_AT_high_pc	(0x0000000000000006)
                DW_AT_frame_base	(DW_OP_reg7 RSP)
                DW_AT_call_all_calls	(true)
                DW_AT_linkage_name	("_Z3mulii")
                DW_AT_name	("mul")
                ...

              DW_TAG_formal_parameter
                  DW_AT_location	(DW_OP_reg5 RDI)
                  DW_AT_name	("num1")
                  DW_AT_decl_file	("/app/example.cpp")
                  DW_AT_decl_line	(...)
                  DW_AT_type	(0x0000003d "int")
```
the tool may get incorrect result.
The current dwarf without this patch allows getting correct original function signature based on
```
DW_TAG_subprogram
  ...
  DW_TAG_formal_parameter
  ...
  DW_TAG_formal_parameter
  ...
```
WDYT? Could your proposed dwarf solution break some tools? Or this is something we can tolerate?



https://github.com/llvm/llvm-project/pull/157349


More information about the llvm-commits mailing list