[DWARF]Why debug-location have been removed for function parameters in clang-trunk?

Hello,
I am trying to find out the reason, Why debug-locations for function parameters have been removed in clang-trunk.
In clang-15 and clang-16 the debug-locations are present.
Attaching the MachineFunction information for clang-16 and clang-trunk…

Clang-16

bb.0.entry:
  successors: %bb.1(0x80000000); %bb.1(100.00%)
  liveins: $x10, $x11, $x12, $x13, $x14, $x1 
  DBG_VALUE $x11, 0, !"linked_list1", !DIExpression(), debug-location !1449; jira.c:827:30 line no:827 indirect
  DBG_VALUE $x12, 0, !"linked_list2", !DIExpression(), debug-location !1451; jira.c:828:30 line no:828 indirect
  DBG_VALUE $x13, 0, !"linked_list3", !DIExpression(), debug-location !1453; jira.c:829:30 line no:829 indirect
  DBG_VALUE $x14, 0, !"linked_list4", !DIExpression(), debug-location !1455; jira.c:830:30 line no:830 indirect
  $x2 = frame-setup ADDI $x2, -64 
  frame-setup CFI_INSTRUCTION def_cfa_offset 64
  ***SD killed $x1, $x2, 56, debug-location !1455 :: (store (s64) into %stack.7); jira.c:830:30***
***  SD killed $x8, $x2, 48, debug-location !1455 :: (store (s64) into %stack.8); jira.c:830:30***
  frame-setup CFI_INSTRUCTION offset $x1, -8
  frame-setup CFI_INSTRUCTION offset $x8, -16 
  $x8 = frame-setup ADDI $x2, 64
  frame-setup CFI_INSTRUCTION def_cfa $x8, 0
  SD killed $x14, $x8, -64, debug-location !1455 :: (store (s64) into %stack.6); jira.c:830:30
  DBG_VALUE $x8, 0, !"linked_list4", !DIExpression(DW_OP_constu, 64, DW_OP_minus, DW_OP_deref), debug-location !1455; jira.c:830:30 line no:830 indirect
  DBG_VALUE $x8, 0, !"linked_list4", !DIExpression(DW_OP_constu, 64, DW_OP_minus, DW_OP_deref), debug-location !1455; jira.c:830:30 line no:830 indirect
  DBG_VALUE renamable $x14, 0, !"linked_list4", !DIExpression(), debug-location !1455; jira.c:830:30 line no:830 indirect
  SD killed $x13, $x8, -56, debug-location !1453 :: (store (s64) into %stack.5); jira.c:829:30
  DBG_VALUE $x8, 0, !"linked_list3", !DIExpression(DW_OP_constu, 56, DW_OP_minus, DW_OP_deref), debug-location !1453; jira.c:829:30 line no:829 indirect
  DBG_VALUE $x8, 0, !"linked_list3", !DIExpression(DW_OP_constu, 56, DW_OP_minus, DW_OP_deref), debug-location !1453; jira.c:829:30 line no:829 indirect
  DBG_VALUE renamable $x13, 0, !"linked_list3", !DIExpression(), debug-location !1453; jira.c:829:30 line no:829 indirect
  SD killed $x12, $x8, -48, debug-location !1451 :: (store (s64) into %stack.4); jira.c:828:30
  DBG_VALUE $x8, 0, !"linked_list2", !DIExpression(DW_OP_constu, 48, DW_OP_minus, DW_OP_deref), debug-location !1451; jira.c:828:30 line no:828 indirect
  DBG_VALUE $x8, 0, !"linked_list2", !DIExpression(DW_OP_constu, 48, DW_OP_minus, DW_OP_deref), debug-location !1451; jira.c:828:30 line no:828 indirect
  DBG_VALUE renamable $x12, 0, !"linked_list2", !DIExpression(), debug-location !1451; jira.c:828:30 line no:828 indirect
  SD killed $x11, $x8, -40, debug-location !1449 :: (store (s64) into %stack.3); jira.c:827:30
  DBG_VALUE $x8, 0, !"linked_list1", !DIExpression(DW_OP_constu, 40, DW_OP_minus, DW_OP_deref), debug-location !1449; jira.c:827:30 line no:827 indirect
  DBG_VALUE $x8, 0, !"linked_list1", !DIExpression(DW_OP_constu, 40, DW_OP_minus, DW_OP_deref), debug-location !1449; jira.c:827:30 line no:827 indirect
  DBG_VALUE renamable $x11, 0, !"linked_list1", !DIExpression(), debug-location !1449; jira.c:827:30 line no:827 indirect
  dead renamable $x11 = KILL renamable $x10
  SW killed renamable $x10, $x8, -20 :: (store (s32) into %ir.seed.addr)
  renamable $x10 = LUI target-flags(riscv-hi) @.str.64, debug-location !1460; jira.c:835:6
  renamable $x10 = ADDI killed renamable $x10, target-flags(riscv-lo) @.str.64, debug-location !1460; jira.c:835:6

Clang-Trunk

bb.0.entry:
  successors: %bb.1(0x80000000); %bb.1(100.00%)
  liveins: $x10, $x11, $x12, $x13, $x14, $x1 
  $x2 = frame-setup ADDI $x2, -96 
  frame-setup CFI_INSTRUCTION def_cfa_offset 96
  SD killed $x1, $x2, 88 :: (store (s64) into %stack.11)
  SD killed $x8, $x2, 80 :: (store (s64) into %stack.12)
  frame-setup CFI_INSTRUCTION offset $x1, -8
  frame-setup CFI_INSTRUCTION offset $x8, -16 
  $x8 = frame-setup ADDI $x2, 96
  frame-setup CFI_INSTRUCTION def_cfa $x8, 0
  SD $x14, $x8, -96 :: (store (s64) into %stack.10)
  SD $x13, $x8, -88 :: (store (s64) into %stack.9)
  SD $x12, $x8, -80 :: (store (s64) into %stack.8)
  SD $x11, $x8, -72 :: (store (s64) into %stack.7)
  dead renamable $x15 = KILL renamable $x10
  SW killed renamable $x10, $x8, -20 :: (store (s32) into %ir.seed.addr)
  SD renamable $x11, $x8, -32 :: (store (s64) into %ir.linked_list1.indirect_addr)
  SD renamable $x12, $x8, -40 :: (store (s64) into %ir.linked_list2.indirect_addr)
  SD renamable $x13, $x8, -48 :: (store (s64) into %ir.linked_list3.indirect_addr)
  SD renamable $x14, $x8, -56 :: (store (s64) into %ir.linked_list4.indirect_addr)
  renamable $x10 = LUI target-flags(riscv-hi) @.str.64, debug-location !1460; jira.c:835:6
  renamable $x10 = ADDI killed renamable $x10, target-flags(riscv-lo) @.str.64, debug-location !1460; jira.c:835:6
  PseudoCALL target-flags(riscv-call) @printf, <regmask $vlenb $x0 $x1 $x3 $x4 $x8 $x9 $x18 $x19 $x20 $x21 $x22 $x23 $x24 $x25 $x26 $x27 $x8_pd $x18_pd $x20_pd $x22_pd $x24_pd $x26_pd>, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def $x10, debug-location !1460; jira.c:835:6

Are you able to construct a sample input file (.c or .ll) that demonstrates the issue?

I Found the Cause!

Here’s the simple testCase

 25 void sum_array_print (
 26      int seed,
 27      struct array_rep_info_t linked_list1,
 28      struct array_rep_info_t linked_list2,
 29      struct array_rep_info_t linked_list3,
 30      struct array_rep_info_t linked_list4)
 31 {
 32      int index;
 33      int sum;
 34 
 35      printf("Sum of 4 arrays, by element (add in seed as well): \n\n");
 36      printf("Seed: %d\n", seed);

For this case the value of prologue_end was coming 30 in assembly Instead of 35, Making GDB does crazy things.
Thats beacuse in clang-16, frontend was passing direct values of function parameters to llvm.dbg.declare,
and thats why backend was creating debug-information for line 30.
Don’t know Why but this case is only for structures …

In latest clang-trunk frontend, Values of function parameters are passed Indirectly using Allocas.

Attaching IRs and Review link : https://reviews.llvm.org/D141381

Clang-16

define dso_local void @sum_array_print(i32 noundef signext %seed, ptr noundef %linked_list1, ptr noundef %linked_list2, ptr noundef %linked_list3, ptr noundef %linked_list4) #0 !dbg !40 {
entry:
  %seed.addr = alloca i32, align 4
  %index = alloca i32, align 4
  %sum = alloca i32, align 4
  store i32 %seed, ptr %seed.addr, align 4
  call void @llvm.dbg.declare(metadata ptr %seed.addr, metadata !51, metadata !DIExpression()), !dbg !52
  call void @llvm.dbg.declare(metadata ptr %linked_list1, metadata !53, metadata !DIExpression()), !dbg !54
  call void @llvm.dbg.declare(metadata ptr %linked_list2, metadata !55, metadata !DIExpression()), !dbg !56
  call void @llvm.dbg.declare(metadata ptr %linked_list3, metadata !57, metadata !DIExpression()), !dbg !58
  call void @llvm.dbg.declare(metadata ptr %linked_list4, metadata !59, metadata !DIExpression()), !dbg !60
  call void @llvm.dbg.declare(metadata ptr %index, metadata !61, metadata !DIExpression()), !dbg !62
  call void @llvm.dbg.declare(metadata ptr %sum, metadata !63, metadata !DIExpression()), !dbg !64

clang-trunk

define dso_local void @sum_array_print(i32 noundef signext %seed, ptr noundef %linked_list1, ptr noundef %linked_list2, ptr noundef %linked_list3, ptr noundef %linked_list4) #0 !dbg !40 {
entry:
  %seed.addr = alloca i32, align 4
  %linked_list1.indirect_addr = alloca ptr, align 8
  %linked_list2.indirect_addr = alloca ptr, align 8
  %linked_list3.indirect_addr = alloca ptr, align 8
  %linked_list4.indirect_addr = alloca ptr, align 8
  %index = alloca i32, align 4
  %sum = alloca i32, align 4
  store i32 %seed, ptr %seed.addr, align 4
  call void @llvm.dbg.declare(metadata ptr %seed.addr, metadata !51, metadata !DIExpression()), !dbg !52
  store ptr %linked_list1, ptr %linked_list1.indirect_addr, align 8
  call void @llvm.dbg.declare(metadata ptr %linked_list1.indirect_addr, metadata !53, metadata !DIExpression(DW_OP_deref)), !dbg !54
  store ptr %linked_list2, ptr %linked_list2.indirect_addr, align 8
  call void @llvm.dbg.declare(metadata ptr %linked_list2.indirect_addr, metadata !55, metadata !DIExpression(DW_OP_deref)), !dbg !56
  store ptr %linked_list3, ptr %linked_list3.indirect_addr, align 8
  call void @llvm.dbg.declare(metadata ptr %linked_list3.indirect_addr, metadata !57, metadata !DIExpression(DW_OP_deref)), !dbg !58
  store ptr %linked_list4, ptr %linked_list4.indirect_addr, align 8
  call void @llvm.dbg.declare(metadata ptr %linked_list4.indirect_addr, metadata !59, metadata !DIExpression(DW_OP_deref)), !dbg !60
  call void @llvm.dbg.declare(metadata ptr %index, metadata !61, metadata !DIExpression()), !dbg !62
  call void @llvm.dbg.declare(metadata ptr %sum, metadata !63, metadata !DIExpression()), !dbg !64
  %call = call signext i32 (ptr, ...) @printf(ptr noundef @.str), !dbg !65
  %0 = load i32, ptr %seed.addr, align 4, !dbg !66
  %call1 = call signext i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef signext %0), !dbg !67
  %call2 = call signext i32 (ptr, ...) @printf(ptr noundef @.str.2), !dbg !68