[RFC] Identify Func Signature Change in LLVM Compiled Kernel Image

Based on the above discussion, the recommendation is to avoid make debuginfo changes for each optimization pass which implies to make debuginfo change in some central place. The changed debuginfo will be reflected in dwarf. The following are some progress since the above discussion:

First, in [Dwarf][Transforms] Add dwarf support when func signature changed by yonghong-song · Pull Request #127855 · llvm/llvm-project · GitHub

the consensus for a dwarf format likes below:
``

DW_TAG_subprogram
DW_AT_low_pc (0x0000000100003ed8)
DW_AT_high_pc (0x0000000100003f18)
DW_AT_frame_base (…)
DW_AT_name (“foo”)

            DW_TAG_formal_parameter
               DW_AT_name	("a")
               DW_AT_type	(0x0000000000000091 "int")

            DW_TAG_formal_parameter
               DW_AT_location
               DW_AT_name	("b")
               DW_AT_type	(0x0000000000000095 "float")

            DW_TAG_formal_parameter
               DW_AT_location
               DW_AT_name	("c")
               DW_AT_type	(0x0000000000000025 "char")

NULL

   DW_TAG_inlined_subroutine
            DW_AT_name	("foo")    
            DW_AT_type	(0x0000000000000091 "int")
            DW_AT_artificial (true)
            DW_AT_specificiation (original DW_TAG_subprogram)

            DW_TAG_formal_parameter
              DW_AT_name	("b")
              DW_AT_type	(0x0000000000000091 "int")

           DW_TAG_formal_parameter
              DW_AT_name	("c")
              DW_AT_type	(0x0000000000000095 "float")

   DW_TAG_inlined_subroutine
            DW_AT_name	("foo.1")    
            DW_AT_type	(0x0000000000000091 "int")
            DW_AT_artificial (true)
            DW_AT_specificiation (original DW_TAG_subprogram)

            DW_TAG_formal_parameter
              DW_AT_name	("b")
              DW_AT_type	(0x0000000000000091 "int")

```

Basic idea is to have new signature encoded in DW_TAG_inlined_subroutine, at the same level as DW_TAG_subprogram. This will not impact existing functionality since the new DW_TAG_inlined_subroutine is not inside DW_TAG_subprogram and we do not have a use case for it. This idea is implemented in
[LLVM] Emit dwarf data after optimizations · yonghong-song/llvm-project@be0cdea · GitHub

But this pattern seems against the normal dwarf pattern. Per suggestion from Vladislav Dzhidzhoev, we decided to encode the actual signature in the function itself and the source code signature is encoded as an artificial inlined function. This is what current implementation in [RFC] Emit dwarf data for signature-changed or new functions by yonghong-song · Pull Request #157349 · llvm/llvm-project · GitHub

The latest approach may cause issues related lldb debugger. I am not an expert so it would be great if somebody can help from debugger perspective.

Note that my initial intention to have this signature change is for BPF tracing. What we really need is to encode actual signature in dwarf. debugger is not really relevant to BPF tracing. My current implementation only supports C language which matches linux kernel language for BPF tracing.