<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/62346>62346</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Assignment Tracking][DebugInfo] Improve scalable vector store handling
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
            OCHyams
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          OCHyams
      </td>
    </tr>
</table>

<pre>
    AssignmentTrackingAnalysis ignores some stores, including scalable vector stores, resulting in incorrect variable locations.

```
target triple = "aarch64"

define dso_local void @square(ptr %0) local_unnamed_addr #0 !dbg !9 {
entry:
 %1 = alloca <32 x i8>, !DIAssignID !18
   call void @llvm.dbg.assign(metadata i1 poison, metadata !19, metadata !DIExpression(), metadata !18, metadata ptr %1, metadata !DIExpression()), !dbg !21
   %2 = load <vscale x 8 x i8>, ptr %0, align 1
   call void @llvm.dbg.assign(metadata i256 0, metadata !19, metadata !DIExpression(), metadata !22, metadata ptr %1, metadata !DIExpression()), !dbg !21
 store <vscale x 8 x i8> %2, ptr %1, align 1
   ret void
}

declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)

attributes #0 = { vscale_range(1,16) "target-cpu"="generic" "target-features"="+sve" }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !7}
!llvm.ident = !{!8}

!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "/app/example.c", directory: "/app")
!2 = !{i32 7, !"Dwarf Version", i32 4}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!7 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
!8 = !{!"clang version 17.0.0"}
!9 = distinct !DISubprogram(name: "square", scope: !10, file: !10, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17)
!10 = !DIFile(filename: "example.c", directory: "/app")
!11 = !DISubroutineType(types: !12)
!12 = !{null, !13, !14, !16}
!13 = !DIDerivedType(tag: DW_TAG_restrict_type, baseType: !14)
!14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64)
!15 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!17 = !{}
!18 =  distinct !DIAssignID()
!19 = !DILocalVariable(name: "i", scope: !9, file: !10, line: 2, type: !20)
!20 = !DIBasicType(name: "cats", size: 256, encoding: DW_ATE_signed)
!21 = !DILocation(line: 0, scope: !9)
```

`$ llc test2.ll -stop-after=finalize-isel -o -`

```
body: |
  bb.0.entry:
    liveins: $x0
  
    %0:gpr64common = COPY $x0
    DBG_VALUE %stack.0, $noreg, !16, !DIExpression(DW_OP_deref), debug-location !18
    %1:ppr_3b = PTRUE_H 31
    %2:zpr = LD1B_H_IMM %1, %0, 0 :: (load unknown-size from %ir.0, align 1)
    %3:gpr64sp = ADDXri %stack.0, 0, 0
    DBG_VALUE i256 0, $noreg, !16, !DIExpression(), debug-location !18
    ST1B_H_IMM killed %2, %1, killed %3, 0 :: (store unknown-size into %ir.1, align 32)
    RET_ReallyLR
```

The store `ST1B_H_IMM` should restore the stack location of the variable.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysWF9z2joW_zTiRQNjywbMAw8Eh5bZ3DbT0nb3ySPLwmgjS15Jpkk-_Y5kGduUtrl3OpMJcHz-_vQ70pGx1qwUlK7B_A4g9HH7_gVXGiAE5ukEN-Yk1doLJ7ksXtYbZ1BRYQ4Kkycmyo3A_EUzDVkppKIaallRqI39DtAWMkF4UzBRQk0wxzmn8EyJkWqgo6huuLE6TFgDqRQlBp6xYs6AS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